summaryrefslogtreecommitdiffstats
path: root/kspread/dialogs
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kspread/dialogs
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kspread/dialogs')
-rw-r--r--kspread/dialogs/Makefile.am74
-rw-r--r--kspread/dialogs/SheetSelectWidget.ui270
-rw-r--r--kspread/dialogs/font_cell_format.ui226
-rw-r--r--kspread/dialogs/kspread_dlg_angle.cc86
-rw-r--r--kspread/dialogs/kspread_dlg_angle.h52
-rw-r--r--kspread/dialogs/kspread_dlg_area.cc101
-rw-r--r--kspread/dialogs/kspread_dlg_area.h55
-rw-r--r--kspread/dialogs/kspread_dlg_comment.cc83
-rw-r--r--kspread/dialogs/kspread_dlg_comment.h55
-rw-r--r--kspread/dialogs/kspread_dlg_conditional.cc679
-rw-r--r--kspread/dialogs/kspread_dlg_conditional.h103
-rw-r--r--kspread/dialogs/kspread_dlg_cons.cc687
-rw-r--r--kspread/dialogs/kspread_dlg_cons.h83
-rw-r--r--kspread/dialogs/kspread_dlg_csv.cc735
-rw-r--r--kspread/dialogs/kspread_dlg_csv.h130
-rw-r--r--kspread/dialogs/kspread_dlg_database.cc1179
-rw-r--r--kspread/dialogs/kspread_dlg_database.h143
-rw-r--r--kspread/dialogs/kspread_dlg_find.cc167
-rw-r--r--kspread/dialogs/kspread_dlg_find.h97
-rw-r--r--kspread/dialogs/kspread_dlg_format.cc352
-rw-r--r--kspread/dialogs/kspread_dlg_format.h81
-rw-r--r--kspread/dialogs/kspread_dlg_formula.cc763
-rw-r--r--kspread/dialogs/kspread_dlg_formula.h179
-rw-r--r--kspread/dialogs/kspread_dlg_goalseek.cc486
-rw-r--r--kspread/dialogs/kspread_dlg_goalseek.h116
-rw-r--r--kspread/dialogs/kspread_dlg_goto.cc87
-rw-r--r--kspread/dialogs/kspread_dlg_goto.h55
-rw-r--r--kspread/dialogs/kspread_dlg_insert.cc148
-rw-r--r--kspread/dialogs/kspread_dlg_insert.h65
-rw-r--r--kspread/dialogs/kspread_dlg_layout.cc3928
-rw-r--r--kspread/dialogs/kspread_dlg_layout.h636
-rw-r--r--kspread/dialogs/kspread_dlg_list.cc321
-rw-r--r--kspread/dialogs/kspread_dlg_list.h71
-rw-r--r--kspread/dialogs/kspread_dlg_paperlayout.cc554
-rw-r--r--kspread/dialogs/kspread_dlg_paperlayout.h94
-rw-r--r--kspread/dialogs/kspread_dlg_pasteinsert.cc77
-rw-r--r--kspread/dialogs/kspread_dlg_pasteinsert.h53
-rw-r--r--kspread/dialogs/kspread_dlg_preference.cc1042
-rw-r--r--kspread/dialogs/kspread_dlg_preference.h223
-rw-r--r--kspread/dialogs/kspread_dlg_reference.cc368
-rw-r--r--kspread/dialogs/kspread_dlg_reference.h92
-rw-r--r--kspread/dialogs/kspread_dlg_resize2.cc183
-rw-r--r--kspread/dialogs/kspread_dlg_resize2.h74
-rw-r--r--kspread/dialogs/kspread_dlg_series.cc213
-rw-r--r--kspread/dialogs/kspread_dlg_series.h66
-rw-r--r--kspread/dialogs/kspread_dlg_show.cc112
-rw-r--r--kspread/dialogs/kspread_dlg_show.h54
-rw-r--r--kspread/dialogs/kspread_dlg_showColRow.cc152
-rw-r--r--kspread/dialogs/kspread_dlg_showColRow.h56
-rw-r--r--kspread/dialogs/kspread_dlg_sort.cc748
-rw-r--r--kspread/dialogs/kspread_dlg_sort.h111
-rw-r--r--kspread/dialogs/kspread_dlg_special.cc135
-rw-r--r--kspread/dialogs/kspread_dlg_special.h55
-rw-r--r--kspread/dialogs/kspread_dlg_styles.cc332
-rw-r--r--kspread/dialogs/kspread_dlg_styles.h77
-rw-r--r--kspread/dialogs/kspread_dlg_subtotal.cc321
-rw-r--r--kspread/dialogs/kspread_dlg_subtotal.h72
-rw-r--r--kspread/dialogs/kspread_dlg_validity.cc814
-rw-r--r--kspread/dialogs/kspread_dlg_validity.h81
-rw-r--r--kspread/dialogs/kspreadsubtotal.ui222
-rw-r--r--kspread/dialogs/link.cc288
-rw-r--r--kspread/dialogs/link.h57
-rw-r--r--kspread/dialogs/position_cell_format.ui411
-rw-r--r--kspread/dialogs/protection_cell_format.ui180
-rw-r--r--kspread/dialogs/sheet_properties.cc192
-rw-r--r--kspread/dialogs/sheet_properties.h93
-rw-r--r--kspread/dialogs/sheet_properties_base.ui258
67 files changed, 20153 insertions, 0 deletions
diff --git a/kspread/dialogs/Makefile.am b/kspread/dialogs/Makefile.am
new file mode 100644
index 00000000..71d7a476
--- /dev/null
+++ b/kspread/dialogs/Makefile.am
@@ -0,0 +1,74 @@
+KDE_CXXFLAGS = $(USE_RTTI)
+
+INCLUDES = \
+ $(KOFFICE_INCLUDES) \
+ $(KOTEXT_INCLUDES) \
+ -I$(srcdir)/.. \
+ $(all_includes)
+
+noinst_LTLIBRARIES = \
+ libdialogs.la
+
+libdialogs_la_SOURCES = \
+ kspread_dlg_angle.cc \
+ kspread_dlg_area.cc \
+ kspread_dlg_comment.cc \
+ kspread_dlg_conditional.cc \
+ kspread_dlg_cons.cc \
+ kspread_dlg_csv.cc \
+ kspread_dlg_database.cc \
+ kspread_dlg_format.cc \
+ kspread_dlg_formula.cc \
+ kspread_dlg_goalseek.cc \
+ kspread_dlg_goto.cc \
+ kspread_dlg_insert.cc \
+ kspread_dlg_layout.cc \
+ kspread_dlg_list.cc \
+ kspread_dlg_paperlayout.cc \
+ kspread_dlg_pasteinsert.cc \
+ kspread_dlg_preference.cc \
+ kspread_dlg_reference.cc \
+ kspread_dlg_resize2.cc \
+ kspread_dlg_series.cc \
+ kspread_dlg_show.cc \
+ kspread_dlg_showColRow.cc \
+ kspread_dlg_sort.cc \
+ kspread_dlg_special.cc \
+ kspread_dlg_styles.cc \
+ kspread_dlg_subtotal.cc \
+ kspread_dlg_validity.cc \
+ kspreadsubtotal.ui \
+ link.cc \
+ sheet_properties_base.ui \
+ sheet_properties.cc \
+ kspread_dlg_find.cc \
+ position_cell_format.ui \
+ font_cell_format.ui \
+ protection_cell_format.ui \
+ SheetSelectWidget.ui
+
+noinst_HEADERS = \
+ kspread_dlg_angle.h \
+ kspread_dlg_area.h \
+ kspread_dlg_comment.h \
+ kspread_dlg_conditional.h \
+ kspread_dlg_cons.h \
+ kspread_dlg_csv.h \
+ kspread_dlg_database.h \
+ kspread_dlg_format.h \
+ kspread_dlg_formula.h \
+ kspread_dlg_goalseek.h \
+ kspread_dlg_goto.h \
+ kspread_dlg_insert.h \
+ kspread_dlg_layout.h \
+ kspread_dlg_list.h \
+ kspread_dlg_paperlayout.h \
+ kspread_dlg_pasteinsert.h \
+ kspread_dlg_preference.h \
+ kspread_dlg_reference.h \
+ kspread_dlg_resize2.h \
+ link.h \
+ kspread_dlg_find.h
+
+METASOURCES = AUTO
+
diff --git a/kspread/dialogs/SheetSelectWidget.ui b/kspread/dialogs/SheetSelectWidget.ui
new file mode 100644
index 00000000..c42989ae
--- /dev/null
+++ b/kspread/dialogs/SheetSelectWidget.ui
@@ -0,0 +1,270 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SheetSelectWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SheetSelectWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>527</width>
+ <height>160</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Sheet Selection</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>ButtonSelectAll</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image0</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Select all sheets.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>ButtonSelect</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image1</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Select sheets.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="3" column="1">
+ <property name="name">
+ <cstring>ButtonRemoveAll</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image2</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Clear Selection.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="2" column="1">
+ <property name="name">
+ <cstring>ButtonRemove</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image3</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Remove sheets.</string>
+ </property>
+ </widget>
+ <widget class="KListView" row="0" column="0" rowspan="4" colspan="1">
+ <column>
+ <property name="text">
+ <string>Available Sheets</string>
+ </property>
+ <property name="clickable">
+ <bool>false</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>ListViewAvailable</cstring>
+ </property>
+ <property name="resizePolicy">
+ <enum>AutoOneFit</enum>
+ </property>
+ <property name="selectionMode" stdset="0">
+ <enum>Extended</enum>
+ </property>
+ <property name="fullWidth">
+ <bool>true</bool>
+ </property>
+ <property name="dragEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Available sheets.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;b&gt;List of all available sheets.&lt;/b&gt;&lt;br&gt;
+To print a sheet you have to select one or more sheets in this list and use the buttons to insert the selected sheet(s) in the right-hand list, which lists all sheets that are printed.&lt;br&gt;
+You can insert a sheet as often as you like, this way it will be printed multiple times. This is useful for dividers or title pages, for example.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="0" column="3">
+ <property name="name">
+ <cstring>ButtonMoveTop</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image4</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Move selected sheet to the top.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="1" column="3">
+ <property name="name">
+ <cstring>ButtonMoveUp</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image5</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Move selected sheet up.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="2" column="3">
+ <property name="name">
+ <cstring>ButtonMoveDown</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image6</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Move selected sheet down.</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="3" column="3">
+ <property name="name">
+ <cstring>ButtonMoveBottom</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image7</pixmap>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Move selected sheet to the bottom.</string>
+ </property>
+ </widget>
+ <widget class="KListView" row="0" column="2" rowspan="4" colspan="1">
+ <column>
+ <property name="text">
+ <string>Selected Sheets</string>
+ </property>
+ <property name="clickable">
+ <bool>false</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>ListViewSelected</cstring>
+ </property>
+ <property name="acceptDrops">
+ <bool>true</bool>
+ </property>
+ <property name="resizePolicy">
+ <enum>AutoOneFit</enum>
+ </property>
+ <property name="selectionMode" stdset="0">
+ <enum>Extended</enum>
+ </property>
+ <property name="fullWidth">
+ <bool>true</bool>
+ </property>
+ <property name="dragEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>List of sheets to print in given order.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;b&gt;List of sheets to print.&lt;/b&gt;&lt;br&gt;
+Only the sheets listed here will be printed in the order of listing. You can change the print order with the up and down buttons.&lt;br&gt;
+It is even possible to print a sheet more than once. Just insert the desired sheet again and order the list to your needs.</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<images>
+ <image name="image0">
+ <data format="PNG" length="905">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000035049444154388db5955f685b5518c07fb9f7a6c9bab44b6a52eb74a5ce2a8e31e87c5126686548fd33b7b921139c985870b80759f1c1a7dac9180c645d611044376e35455199d1271f04d9cb26286c3e0d9982a0334ddac595adc9cd9ff39de3c3ad6db334d1977df071e1f0fb7ef7bbe71cee1730c6702722f0d0e8f7c34674d6888e6a250b46c9d8ef5fee9a5e0df50d6786d026ab950c1825682553c54b87c6da892da34db6d8737f74e3c8d3541edc1e55586effeeaf920d9436a7caf76c1e78f87092ee3d7bd1b67324b6f5b4db5e2c12dd32b499ec7ef874f46ebc6d3b106cf7de91cf97e546f4f0e0f607c8ee87ef0edf45ff4bbb113b98ec1e9c6c29b78cd2d43514cbb03102670e6cc07be40904cbed7b329304d022743a8662199486b307e3dcf7f23eb4ed24d76f3ab1a6dcd222d405e6cb7e263ae1e48b512a8fee442cdb4d3c76f69451424d9965a62a30792041df9b6f20b17832dc7bac496e1925d435cc9556321a82f1e762541f1f415bce11239a9a34325e1d267686e84bbe82ee49243bbac7dd46f15251a1d498eb837074570f91679f47853aa984ba9a98520ddeda11a677f43524de9bb443ef2ccb039b5e3867ec67f691dab6f621780a2e5e832d71ff0c5a31ee4f15e64e7f80f9ebcf9f313ce518e5779c5f6c75beb035ee3fdb31fd893085d70fc147e9216673ae63447c71a975d17f455dc39522105e070753f0fef1bd8e56be78b64d37ed62b106bfdcf0afe1ea708c686a0a666ff90b4a4345fc2b0510b2216841870d81a52203d4046e56a1ac56d92a1eccb8005ffb5b5183bc0691e637ffef0fa978e0a6219f3b0fa41cad0434d46b7e2bd66d7ca058c0f9f60bea7b5e85ae684ba9fe380df9dc344ca696b76243686d5ecf15a87e93c1944a44bc05ec44b3d8781e373f6994fa6225c4c2cdd25aa1c0dfe732e095df33221391a0217c1b279e47ee4c1a3ddb2805ffef46344c4386170adcf82c83f6bc54e5fac451ad345d1d8d4cc77c8e6bc78e53cf354b011cad34b1752b0b8bb90257a76790b297aaccbf3b0d604488040dd125eed61f397e9b4a239eb7a6f4df8e178a177e201686eaaf57b9f2e10cca5b91021825e7af5ffcd1dfb27c8ecb27d2a8726b2940a07bf0e4b0563a6b94f8a349ebb1cadcf87423f5f610c6648181a59529986c3b9a02776a98fe032baad331ecd127a50000000049454e44ae426082</data>
+ </image>
+ <image name="image1">
+ <data format="PNG" length="657">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000025849444154388d9dd54f48545114c7f1af36e98c5a8eff3057cea23434e815eefa43b68a60a2082417198981d02a0822da05120482b5186a11a3eba0d9b489a07117410b17ad024b178e992659396f66eeb9f7b618a171ded5193b703687773feff72e8f7b6bacb59456efd8ac678d49192531a3045390a9855797eeb0c7aa29877b46df7ddd68ea8cf50df4b2bcbcc1e687f7e0fb73466470e9edf0cf6ae1daf281151debeaef253514e2cd781b1d674f23d47a46e974e7a9e9e87fc346847038c4ba0fdac08be128adf13885c841cf2849b79d7856151e8495461958f38bad343cbd58c7b1a10ba8a6a86745a7a3479f54c45d5b81d2b096fdd779817b67ea181889a30eb47846e97453f7e35d714762411958cd06fbfac97a8e8f5e459a5b3dab241de978b823eed8e362e2d54d775feeafa7efd635a4a5dd334aa7f7373e70e2cec4050ddfb33bf7f99e3087c747d06d1d9e1149d7d4de0de0ee3d36b0b2b97b0f7487e9be3d86693fe4616daadc0905b742105d5c5c5a62b616944439d21566f5e60d7e4f4c9cab0c2b4dc1016b03fb4ad0bc06638b735705602b9a82c0ca9fe0c3ca405620abb606391fa69300b355241694147faf6d2f34a04b8f959c0fc9042c67e6802b9561d158015df2d9d602e5e84c02be65e680416b27038793337143605af2929c4f6e2681dd0575c25634cd61376a7c9f1fc9cae88e89a30e58677d169f27904c65d40d8ba6b97efb2cb7b6cee74492fc5275a813b64a68b439429162ec5f8b193e3d4a2059bf6a14dc87d0c29797af69d03ef9f9793e16d1d9bda0e0b8f34291fb9e119db2a2635ba3296b27f77c99fe05fc2089421fcaadf90000000049454e44ae426082</data>
+ </image>
+ <image name="image2">
+ <data format="PNG" length="968">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000038f49444154388db5955f685b551cc73ff79e9bf4264dd69bb6595d5b35db8ad4ad8ed63d2873b8c9748cc2b44145c416133a644cd0b2175fc4e27cd98b8d201419d5c4cd0785c91cbe083ee81e5ca0cc3f0fba9659e774d8b5b6a5ad6dfef4e69e737d48d6348d6b41d8811f97c3f9dceff9fecebf9fe6ba2e77a3699b010d5d1f2434430ce8864033c40d4dd7a35397fa7e5acb449efb32a61b22a119c2d20db180ae45f58d44ad5def27953006ea7aa2b4bf1a27d7bc23e22a9558cbdc7bf4f398444fe61fe8b25a8e1c66ae7ebb85722f1877120dee7c37a98411dbfefc335c78a5813a139ebcd9c65f37270ede665a0e7f1a9388a4bde731cebf5cc7435be169b583e9af7fb3fe53b8b6f57452094fecfe179fe5c3be461c057359f01b2eae9400dcf3f8d9a2e8de037cf4421dcd81225350a01c4995b0193e9594a1c6586b7f2f43476b589130932d8e15a48beb28c28f8c24a42e060a8f1e2211b508fbd732e0ca75c29ee09b49591f8eb5c45f62f0500db902e40ae571db01252578bd03cefe230c7687b06ae0ef4c992928701d5516d6bd6f245563536cdbb118afed33c9d890b12bb3c99b41a4598bd5ddcdeb4fd5e3f7c074a692b1657172034e5ac0376eb8a9337cfc18bd7b4d966c585a270a70605790b1137dec6be58e8cbd6629926c6bee74fb8f735fd864310f8bd57c312b6077231b32b604bdb4143df4c6c1f471750e9a6ac1b3e1e9deb8d912bceb372f5380af7e87f61004bcff5fd85372fc059f247be83f01a60f47c1cf33e037604b0d7845f9debba51f0b0a568ac7991a01a600a394a5ed80bfe438cead498b91e183c48be2005909d995cd1d2e97be860e4240a1742405a4f390fe98e58e0813e39dfaee2e34e14173a98ec505bc9f9d81e6089a2f5031e62a50aa9896efda0f88f2dce98b2c7744b4ebe39d5b1eeec2f479300d2ac2333785bc92465c1fc3dfd686af2e50c5980668bf5c61ddfe0fc5d5adc9546664982d6e8e904945043c2e4a2adc5cf66dfbfc596a17a7ab9890597c2b04552d7d512d7544962fa73bb7ee6927d8105c75c2e23cf3a3df53f8e79d270ceffe3f56c6c77a1a1fdc49c0aa743e3f3abade71d9b9cce55213ef0d63cc4c12f241c807412fabaf5b7e763025b3b9f89fa97378e6a7579990afc86c701586e24e3697faf1f4304c4d123261e6f228ca51dfde26f2b36fa59c6c2e7ef5cc39f2bf5e2364c2ec77695c472e6c5a9ae064021828756e005118aa284d66f8544cd3f5d5d2a41922aaddad62fa2fb812750e71873b130000000049454e44ae426082</data>
+ </image>
+ <image name="image3">
+ <data format="PNG" length="663">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000025e49444154388d9d95bf6b13611cc69fbb5e72494c9bd7d8a606145390223af4745041a4899b438b010545d05a444597dacd417010ecd40cc241c15a1d9c042bf8075c07371d6e10d1a118215e13511b699abbe4de1f0ed290341772c9179ee5deef7d78dee7fdbebc921002cd254912bad5a10b6f7372509993030a6445c94b0372f6eb72c66cee51ba529a2a79ee1591038a41216bd113a7904c127cfef02515ab9456018cf5054e9c7e4e0465060b04b5e4e459bcb9414054206d1f41e5bd95dadd2ffb81c62774c22935ea91212d3e358d67970918077edb4028a480bbb4ed9fae8e87c67384bbcc607b87b5894be7f1301384cb805fd5ffeb2e070465bd81f71c5820c265068d8f6827af4fe3fe99201c0a384d065d06f05ec0eabe4784536af0e184767cf622ae6a2a7e6eb7f7d519fc47a1841f10ee32432492dab15b573075d41b0af414c53ce19419d2fea4367ee71a260f8750aa76da576f8e57f9c8a896ba7713dac1104a95ced01db0e433e37474660663a361143b6c7fa71807361d80f8cd980aa0d8c529e54061bbb7715b735eaca4bfdfbe0b351a6e7ce402a8b1d6516bac7938f6ba79596c586675494779d346d901ca36f0d7069c3a00de2eaf39f6002f960164b06199625987d8b2212800d659c2f5056e82172d537aa9234c6d44147414a7fea268818ba265ba2b3a06858d58089ef219453b9c5a96595ed231c86d9010da247c1e9e27bcf6c3320b4f75a85b7f1053d1a23e1cb7c2ab05cbfcf4781152c96ac410e10eb8ffc3eb0ca7557bede3131db5f57544988d6fafdf81539adfdd2df5f39802f33900730020c9725e0e0c64a9b3d0f298fe035d3d29db4f6561c90000000049454e44ae426082</data>
+ </image>
+ <image name="image4">
+ <data format="PNG" length="873">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000033049444154388da5d4cb4f5c6518c7f1ef993903cc8dce34582ca56955a6c6c40525c54b0206e874d745e72fe01c8d1bddd08d8946132f0b5704a309b11a73a61a20a926e2dd289376e1c24663bdb021510224e53e3094b930c379cfe30266803267a2ed6ff3e6bcef793e79cf9bf7399a88a0691a6e89f54f44441c4b9473c9b11562ab71c756e6dc17898c5b8d88a0bb8ae59790ebc5ba50fb426b3b203c3075f392beb516017a6bd5796a2db6f5ff68157dc1f6ec994e52a69fbf0702343dd345d11fee69898f59f704c7fa27ac625dc8b813ebe4ca459da37ed82cc1fb177d447b7a29051a8de6eeabaeb856ed8c63c684b5e50b1a9947cef156af4e5bf46051b6042f4f94d8f8fe3b3ce995e4ea2fcf9bfbd745e4301c3353d6962f60ac3d748e173a754e3656df517e1bdefbb944f69baff0ae2e25d7fe7cb1821f826366ca52788cf9581789c7748e05dc3e7427451b3e9b2cb23df63114f2c98da901f3101c7b366529f11a4ba73a387b3a4ca4a1366a3b9029427a0ba6ff5921f0ed3524974f66675f322bf0a3cf5d1fb2f10cdc6eeda0b9294ca0c625b405d677c1fdf1a49769181f4572f977f20baf5cd6448433664ae64e3d41b13e8c57032f80dc256a3b53db77cfefc75797a8fbe4030acbaf693a80a314c5fa30004a4055abaa0196e3343523f64eb50e20b633d334f7c7e96cf40422b2838860d70751fe60f5dd65efa06d6e8048a5c6f3d72d1ce5ccecc14a2582cbb34381f9e99eddff018eadb07d7e56ba135561ffd7d7d036d6716c1bb19df27843442e834b831cef1b1972347d20dd11c70e1fadbee3f4320d5f8e2085fc1b85c5575f3f706ad51ae478df88e168ba956e8f6387aaa3157c7509dff8552497334b993793ae704bdf88e178752bd77101158aba7907b3b2c8f6e84738b99ca90a6f270fc12de7470df1ea96f6641c69fc8fe86ed4e2026b1f5ec1decc9ac860b2029fb83066e0d5ad50571ccf91ff879653ba3dcfecbbc3a842c114194c6a2242cbf9d1f5635ddd117febc97b42cb59ff7d92a9612b2332182d5fb7c8836df787021c79ea71a68689c05e8364d2bfdd8a3cfcf4d9fb82273ffd012053811da512333ffdfaf9f48d9b917273b88ff6deb372400ef47a064800fc0bff20c9075c6bda090000000049454e44ae426082</data>
+ </image>
+ <image name="image5">
+ <data format="PNG" length="653">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000025449444154388dedd54b48546114c0f1ff9db933a5a33651a21934168e11045e7c1521d92c0ab39541ee72ca966d5ab6095ab52d08722556502004838bcaf031aea255cc426c11e64483f94891a679dcb9dfa3c5e8d094a354b808fae0f2c1e1dc1fe71ceefd3e436bcd4e2cd78ea8ff246c6c97d0d037e6d74a45b490679423508e98528eec49bcbcb4f6c7704378cc8fd2d1ac596ed5b435039a44f435eeb52f31e588d0c2d4e59278c95104c3e379d4e3b33a2eb4331a2e63345c4ea8b7935c5995a5858c569f18f4977adfbd297a65dcafb58e66bd3eabf96c1bb73a3d247390cc4147c0cdfbf20073339f6a4925bbcaaacf0f67165f64b785835727f2a8c7671d3dddcef5760f5f6d8a9e96836ee27b8e9098f958cbb76497d77f6ed85e7d558417cd38d83f519869ddc936fa9acc529d02f0e8adcdccd03358fc1cd38e0ca512370b332fc08dfd937ead54346bfaacaae656ba1b8b515be6f75d3ff5f8fc9dcddce05358988f294784ec95db6b05b8f1daa45faf57aa8eb572ead0e695daf25778350b6fe2599c278f613e11538e0c89f49d3513406b1d91da65ad045a0956987cd8f20b85740e9652b092d988ecc6e8eec53d74df52193b02848c60ffc45da55d37160eb4e0aeacc4ed290d1a1aec1cd84e8984a579e4c301743a7dcf68088f69fb700bb2622f004a434e83a3406af0b8c06d80d700d7b6ff2938b3b32c0f3cc0d442b27f5f05ae2d2afd9d2582752c03a612322e67a7eb6b9a8e637aff4ecfa5324c474600e246e0e288a5858c2847d4e70f19c9fa618372047a232644517c234f3b0225e48f7e1ce831fedf203b0e7f07b6cc32072013e5190000000049454e44ae426082</data>
+ </image>
+ <image name="image6">
+ <data format="PNG" length="592">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000021749444154388dedd54d48545114c0f1ff9b79e37c68cd1327923ee0419144050f174111a1084614d46c5c044510ed825ab66b958ba0d1454c848151db6008dc3f2122ca84592a6d2274b2b20f317d2fef578b57e9cce844c82c822e5cb8e79ccbef9ebbb9d732c6d08c116b8afa4fc2d6be4bbe67b42e69215d2d245a488c506821d1328aa3a958ad57c7abfb1446c8375aaabc6db42e2db46d7773fbbb684ddb9bea72712160ead11397c989926da472771dea62e8c4e6d068a4b96a9fa13c39e1da5a2ae63f2c30fda9834c6273ecb280d9d715006c2de5b029bfb836183fca85230ea9bf68fcfd124c7d8ed66e16c69e56f8786f1460d802d87dfab1af4cac471febe7e4815612f1c6e097109e576066714d320ce0d64d08837128f4da005aaa3c62c517cf7c6f2cde4ff7ce963a4c1ab02df826e0e51c085d838e14210cca401ec0fa55eb3cfed0d152f92b99ac17eb3b452e5b8d2b1d61b34ba0d6be024100f78bf0ae52067aa1f0b50a06c81d1e718c50be6875bca0ef2cb164f277cd18585135d7080318ad47eb6080f683771c2d952fdbdabdeffd03d092acdd121d1406a8074598ab47d78501b6eebded68a17cb21dde96817358a954555d0701f3778bc8cafae886304066c7a0a3a5f213b99cb7e7f245e2e90897cb01d38522e1ccc6684318a0a5fd866384f2339ddbbcee2be7c1185e0d8db2f8b631fa4718209ebaee68a94a46aa9e9fa97120df0805b0feff204d877f007cf8163df7483bad0000000049454e44ae426082</data>
+ </image>
+ <image name="image7">
+ <data format="PNG" length="803">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000002ea49444154388da5d44f68147714c0f1ef8c937f6be34e4c1ab7fec16cc45aa42da5399460c5b407912ad4804a0f016741f09c2a8542411b697b31d1aa2c82d259a145d1c37a10050f8d624e068d2715a117d1352a1b7763b213777fbfdff3b0c926319b0d350f667ef0667e9ff9f1786f2c1161c3befe0ed12669b47645698cd2bcdfaa32a24ce778eae71b0e801849e6235177db96561613d7feb9e5beb87e3309341461addd8f3f6fa573fda25cc6776fe6d2d57f5d8022ac4ce6defde7eec0ca15acfae0fdd040c140ff43449b4c09365a77d73d1af24f38edec6a0bd354b730f46004069fc1f038449642fed93063e79388986e004b44b02c8bb53b2f7b0adbcf7cb6994d9fb82cab290f160cdc7a022313d339ebc53055e71348908b15468f2444641a0658bdeda2a72cdb1f6bfb96d6350dd8d66cd408fc370ae38577d00b090872b17cf64802600e0cf0d1377f7bda5ae28f7eb595aa86e5a5bc0081062d33d09793682e88e5b33d89d2bbe56080e6f6bf0e6bdb3994ddf41dca6d2c5b12ebe5f3a993fe9acff41c9ef9ac04afda7ae10bd1e69828dd31b3e9756d88cc8eaeb270f5993f61248d510651aa3824dadc00ba457aef3993c54be622d19660651411400444d0a1fab2284061cf5ec8be0291e93d77063bb83b9804a253edd692fdb47d5ea45c48d885b03b3b195d0777075b006c00510627330286c55da954e91b4558abe3e1812b38afd28b43cfc6018ec38c0169fcf2b4af2dc77bfdf5f768b7e97f9585e1149c8bc3449080bed89c7673379ef48ded78aa3306d5f38cde3b21130141ef6f2514e6e9e3fa75bdbee5367aa1ce1fb06a2ae32608489f8ea352a9123a2f0cb074f51ffe92e54d5ea4ab0bbbb6b62caa8380c727e2bc793a1bad0803d436f5f835cd1f7aebf77b3875b371950bb87f344eeec95c744118a0aafe173f1469f6da0eeca32a54fc97167201b77f8f33f6b83c3a05176f15c2aefea9df8df6c9f65369d97e2a2de1b547057e1caab467c1130358f641578cf1819d93a9cb400cfa3295e0b7368fded24916db230000000049454e44ae426082</data>
+ </image>
+</images>
+<tabstops>
+ <tabstop>ListViewAvailable</tabstop>
+ <tabstop>ListViewSelected</tabstop>
+ <tabstop>ButtonSelectAll</tabstop>
+ <tabstop>ButtonSelect</tabstop>
+ <tabstop>ButtonRemove</tabstop>
+ <tabstop>ButtonRemoveAll</tabstop>
+ <tabstop>ButtonMoveTop</tabstop>
+ <tabstop>ButtonMoveUp</tabstop>
+ <tabstop>ButtonMoveDown</tabstop>
+ <tabstop>ButtonMoveBottom</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klistview.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klistview.h</includehint>
+</includehints>
+</UI>
diff --git a/kspread/dialogs/font_cell_format.ui b/kspread/dialogs/font_cell_format.ui
new file mode 100644
index 00000000..fa56db72
--- /dev/null
+++ b/kspread/dialogs/font_cell_format.ui
@@ -0,0 +1,226 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>FontTab</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>FontTab</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>480</height>
+ </rect>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>You can select here the font style, size and color, including some additional options like underlined or striked out text for the current cell text. The lower part of the page gives a preview of the selected text format.
+The default font is set for all cells in the Format -&gt; Style Manager menu with the currently used style.</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="1">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox" row="0" column="1">
+ <item>
+ <property name="text">
+ <string>Varying (No Change)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Roman</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Italic</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>style_combo</cstring>
+ </property>
+ <property name="insertionPolicy">
+ <enum>NoInsertion</enum>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Choose the style for your font for the currently selected cells. When you select several cells with different styles, the displayed style is set to Varying (No Change) and leaving it that way will keep all your current style settings for each cell. Changing to Roman for example will change all the selected cells style text to Roman.</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="2" column="1">
+ <item>
+ <property name="text">
+ <string>Varying (No Change)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Normal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Bold</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>weight_combo</cstring>
+ </property>
+ <property name="insertionPolicy">
+ <enum>NoInsertion</enum>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Choose the weight for your font for the currently selected cells. When you select several cells with different font weight, the displayed weight is set to Varying (No Change) and leaving it that way will keep all your current weight settings for each cell. Changing to Bold for example will change all the selected cells font weight to Bold.</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Color:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="4" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>underline</cstring>
+ </property>
+ <property name="text">
+ <string>Underline</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If this is checked, the current cell text wil be underlined.</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Size:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Weight:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Style:</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="3" column="1">
+ <property name="name">
+ <cstring>textColorButton</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Choose the color for the current cell text. Clicking on the color bar will bring you the standard KDE Select Color dialog where you will be able to choose the new color.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="5" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>strike</cstring>
+ </property>
+ <property name="text">
+ <string>Strike out</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This will strike out the current cell text if this is checked.</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="1" column="1">
+ <property name="name">
+ <cstring>size_combo</cstring>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Choose the style for your font for the currently selected cells. When you select several cells with different styles, the displayed style is set to Varying (No Change) and leaving it that way will keep all your current style settings for each cell. Changing to Roman for example will change all the selected cells style text to Roman.</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="1" column="1">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QListBox" row="0" column="0" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>family_combo</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This box lists all your available font families. Click on one family to set it in the current cell.</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Preview</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>example_label</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="alignment">
+ <set>AlignHCenter</set>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>You can see a preview of the font you are choosing for the current cell.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kcolorbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kspread/dialogs/kspread_dlg_angle.cc b/kspread/dialogs/kspread_dlg_angle.cc
new file mode 100644
index 00000000..8dc31e1c
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_angle.cc
@@ -0,0 +1,86 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Norbert Andres<nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qlayout.h>
+#include <qpushbutton.h>
+
+#include <kbuttonbox.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <knuminput.h>
+
+#include <kspread_cell.h>
+#include <kspread_doc.h>
+#include <kspread_sheet.h>
+#include <kspread_view.h>
+
+#include "kspread_dlg_angle.h"
+
+using namespace KSpread;
+
+AngleDialog::AngleDialog(View* parent, const char* name, const QPoint &_marker)
+ : KDialogBase( parent, name,TRUE,i18n("Change Angle" ), Ok|Cancel|Default )
+{
+ m_pView=parent;
+ marker=_marker;
+
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+
+ QVBoxLayout *lay = new QVBoxLayout( page, 0, spacingHint() );
+ m_pAngle = new KIntNumInput( page );
+ m_pAngle->setRange( -90, 90, 1 );
+ m_pAngle->setLabel( i18n("Angle:") );
+ m_pAngle->setSuffix(" ");
+ lay->addWidget( m_pAngle );
+
+ QWidget* spacer = new QWidget( page );
+ spacer->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ) );
+ lay->addWidget( spacer );
+
+ m_pAngle->setFocus();
+
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+
+ Cell *cell = m_pView->activeSheet()->cellAt( marker.x(), marker.y() );
+ int angle=-(cell->format()->getAngle(marker.x(), marker.y()));
+ m_pAngle->setValue( angle );
+}
+
+void AngleDialog::slotOk()
+{
+ m_pView->doc()->emitBeginOperation( false );
+ m_pView->activeSheet()->setSelectionAngle(m_pView->selectionInfo(), -m_pAngle->value());
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ // m_pView->doc()->emitEndOperation();
+
+ accept();
+}
+
+void AngleDialog::slotDefault()
+{
+ m_pAngle->setValue( 0 );
+}
+
+
+#include "kspread_dlg_angle.moc"
diff --git a/kspread/dialogs/kspread_dlg_angle.h b/kspread/dialogs/kspread_dlg_angle.h
new file mode 100644
index 00000000..0f2fc447
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_angle.h
@@ -0,0 +1,52 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Norbert Andres<nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_angle__
+#define __kspread_dlg_angle__
+
+#include <kdialogbase.h>
+
+class KIntNumInput;
+
+namespace KSpread
+{
+class View;
+
+class AngleDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ AngleDialog( View* parent,const char* name,const QPoint &_marker);
+
+public slots:
+ void slotOk();
+ void slotDefault();
+protected:
+ View* m_pView;
+ QPoint marker;
+ KIntNumInput *m_pAngle;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_area.cc b/kspread/dialogs/kspread_dlg_area.cc
new file mode 100644
index 00000000..7932ad13
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_area.cc
@@ -0,0 +1,101 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1999-2001 Laurent Montel <montel@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+
+#include <kmessagebox.h>
+
+#include "kspread_doc.h"
+#include "kspread_locale.h"
+#include "kspread_sheet.h"
+#include "kspread_view.h"
+#include "selection.h"
+
+#include "kspread_dlg_area.h"
+
+using namespace KSpread;
+
+AreaDialog::AreaDialog( View * parent, const char * name, const QPoint & _marker )
+ : KDialogBase( parent, name, TRUE, i18n("Area Name"), Ok | Cancel )
+{
+ m_pView = parent;
+ m_marker = _marker;
+
+ QWidget * page = new QWidget( this );
+ setMainWidget(page);
+ QVBoxLayout * lay1 = new QVBoxLayout( page, 0, spacingHint() );
+
+ QLabel * label = new QLabel( i18n("Enter the area name:"), page );
+ lay1->addWidget( label );
+
+ m_areaName = new QLineEdit(page);
+ m_areaName->setMinimumWidth( m_areaName->sizeHint().width() * 3 );
+
+ lay1->addWidget( m_areaName );
+ m_areaName->setFocus();
+ connect ( m_areaName, SIGNAL(textChanged ( const QString & )), this, SLOT(slotAreaNamechanged( const QString &)));
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+ enableButtonOK(!m_areaName->text().isEmpty());
+
+}
+
+void AreaDialog::slotAreaNamechanged( const QString & text)
+{
+ enableButtonOK(!text.isEmpty());
+}
+
+void AreaDialog::slotOk()
+{
+ QString tmp(m_areaName->text());
+ if( !tmp.isEmpty() )
+ {
+ tmp = tmp.lower();
+
+ QRect rect( m_pView->selectionInfo()->selection() );
+ bool newName = true;
+ QValueList<Reference>::Iterator it;
+ QValueList<Reference> area = m_pView->doc()->listArea();
+ for ( it = area.begin(); it != area.end(); ++it )
+ {
+ if(tmp == (*it).ref_name)
+ newName = false;
+ }
+ if (newName)
+ {
+ m_pView->doc()->emitBeginOperation( false );
+ m_pView->doc()->addAreaName(rect, tmp, m_pView->activeSheet()->sheetName());
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+ }
+ else
+ KMessageBox::error( this, i18n("This name is already used."));
+ }
+ else
+ {
+ KMessageBox::error( this, i18n("Area text is empty.") );
+ }
+}
+
+#include "kspread_dlg_area.moc"
diff --git a/kspread/dialogs/kspread_dlg_area.h b/kspread/dialogs/kspread_dlg_area.h
new file mode 100644
index 00000000..302715c8
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_area.h
@@ -0,0 +1,55 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1999-2001 Laurent Montel <montel@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_area__
+#define __kspread_dlg_area__
+
+#include <kdialogbase.h>
+
+class QPushButton;
+class QLineEdit;
+class QLabel;
+
+namespace KSpread
+{
+class View;
+
+class AreaDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ AreaDialog( View * parent, const char * name, const QPoint & _marker );
+
+public slots:
+ void slotOk();
+ void slotAreaNamechanged( const QString & text);
+
+protected:
+ View * m_pView;
+ QLineEdit * m_areaName;
+ QPoint m_marker;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_comment.cc b/kspread/dialogs/kspread_dlg_comment.cc
new file mode 100644
index 00000000..79ce9c49
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_comment.cc
@@ -0,0 +1,83 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qmultilineedit.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+
+#include <klocale.h>
+#include <kbuttonbox.h>
+
+#include "kspread_canvas.h"
+#include "kspread_doc.h"
+#include "selection.h"
+#include "kspread_sheet.h"
+#include "kspread_view.h"
+
+#include "kspread_dlg_comment.h"
+
+using namespace KSpread;
+
+CommentDialog::CommentDialog( View* parent, const char* name,const QPoint &_marker)
+ : KDialogBase( parent, name,TRUE,i18n("Cell Comment"),Ok|Cancel )
+{
+ m_pView = parent;
+ marker= _marker;
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+ QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
+
+ multiLine = new QMultiLineEdit( page );
+ lay1->addWidget(multiLine);
+
+ multiLine->setFocus();
+
+
+ Cell *cell = m_pView->activeSheet()->cellAt( m_pView->canvasWidget()->markerColumn(), m_pView->canvasWidget()->markerRow() );
+ if(!cell->format()->comment(marker.x(),marker.y()).isEmpty())
+ multiLine->setText(cell->format()->comment(marker.x(),marker.y()));
+
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+ connect(multiLine, SIGNAL(textChanged ()),this, SLOT(slotTextChanged()));
+
+ slotTextChanged();
+
+ resize( 400, height() );
+}
+
+void CommentDialog::slotTextChanged()
+{
+ enableButtonOK( !multiLine->text().isEmpty());
+}
+
+void CommentDialog::slotOk()
+{
+ m_pView->doc()->emitBeginOperation( false );
+ m_pView->activeSheet()->setSelectionComment( m_pView->selectionInfo(),
+ multiLine->text().stripWhiteSpace() );
+ m_pView->slotUpdateView( m_pView->activeSheet(), *m_pView->selectionInfo() );
+ // m_pView->doc()->emitEndOperation();
+ accept();
+}
+
+#include "kspread_dlg_comment.moc"
diff --git a/kspread/dialogs/kspread_dlg_comment.h b/kspread/dialogs/kspread_dlg_comment.h
new file mode 100644
index 00000000..21636d35
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_comment.h
@@ -0,0 +1,55 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_comment__
+#define __kspread_dlg_comment__
+
+#include <kdialogbase.h>
+
+class QPushButton;
+class QMultiLineEdit;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class CommentDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ CommentDialog( View* parent, const char* name,const QPoint &_marker );
+
+public slots:
+ void slotOk();
+ void slotTextChanged();
+protected:
+
+ View* m_pView;
+ QMultiLineEdit *multiLine;
+ QPoint marker;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_conditional.cc b/kspread/dialogs/kspread_dlg_conditional.cc
new file mode 100644
index 00000000..e9289d3f
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_conditional.cc
@@ -0,0 +1,679 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1999-2001 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+
+#include "kspread_dlg_conditional.h"
+#include "kspread_condition.h"
+
+#include "kspread_canvas.h"
+#include "kspread_cell.h"
+#include "kspread_doc.h"
+#include "selection.h"
+#include "kspread_sheet.h"
+#include "kspread_style.h"
+#include "kspread_style_manager.h"
+#include "kspread_view.h"
+
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include <KoGlobal.h>
+
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+
+using namespace KSpread;
+
+ConditionalWidget::ConditionalWidget( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ QGridLayout * Form1Layout = new QGridLayout( this, 1, 1, 11, 6, "Form1Layout");
+
+ QGroupBox * groupBox1_3 = new QGroupBox( this, "groupBox1_3" );
+ groupBox1_3->setColumnLayout(0, Qt::Vertical );
+ groupBox1_3->layout()->setSpacing( KDialog::spacingHint() );
+ groupBox1_3->layout()->setMargin( KDialog::marginHint() );
+ QGridLayout * groupBox1_3Layout = new QGridLayout( groupBox1_3->layout() );
+ groupBox1_3Layout->setAlignment( Qt::AlignTop );
+
+ QLabel * textLabel1_3 = new QLabel( groupBox1_3, "textLabel1_3" );
+ groupBox1_3Layout->addWidget( textLabel1_3, 0, 0 );
+
+ m_condition_3 = new QComboBox( false, groupBox1_3, "m_condition_3" );
+ groupBox1_3Layout->addWidget( m_condition_3, 0, 1 );
+
+ m_firstValue_3 = new KLineEdit( groupBox1_3, "m_firstValue_3" );
+ m_firstValue_3->setEnabled( false );
+ groupBox1_3Layout->addWidget( m_firstValue_3, 0, 2 );
+
+ m_secondValue_3 = new KLineEdit( groupBox1_3, "m_secondValue_3" );
+ m_secondValue_3->setEnabled( false );
+ groupBox1_3Layout->addWidget( m_secondValue_3, 0, 3 );
+
+ m_style_3 = new QComboBox( false, groupBox1_3, "m_style_3" );
+ m_style_3->setEnabled( false );
+ groupBox1_3Layout->addWidget( m_style_3, 1, 1 );
+
+ QLabel * textLabel2_3 = new QLabel( groupBox1_3, "textLabel2_3" );
+ groupBox1_3Layout->addWidget( textLabel2_3, 1, 0 );
+
+ QSpacerItem * spacer = new QSpacerItem( 41, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ groupBox1_3Layout->addItem( spacer, 1, 2 );
+ QSpacerItem * spacer_2 = new QSpacerItem( 61, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ groupBox1_3Layout->addItem( spacer_2, 1, 3 );
+
+ Form1Layout->addWidget( groupBox1_3, 2, 0 );
+
+ QGroupBox * groupBox1_2 = new QGroupBox( this, "groupBox1_2" );
+ groupBox1_2->setColumnLayout(0, Qt::Vertical );
+ groupBox1_2->layout()->setSpacing( KDialog::spacingHint() );
+ groupBox1_2->layout()->setMargin( KDialog::marginHint() );
+
+ QGridLayout * groupBox1_2Layout = new QGridLayout( groupBox1_2->layout() );
+ groupBox1_2Layout->setAlignment( Qt::AlignTop );
+
+ QLabel * textLabel1_2 = new QLabel( groupBox1_2, "textLabel1_2" );
+ groupBox1_2Layout->addWidget( textLabel1_2, 0, 0 );
+
+ QLabel * textLabel2_2 = new QLabel( groupBox1_2, "textLabel2_2" );
+ groupBox1_2Layout->addWidget( textLabel2_2, 1, 0 );
+
+ m_condition_2 = new QComboBox( false, groupBox1_2, "m_condition_2" );
+ groupBox1_2Layout->addWidget( m_condition_2, 0, 1 );
+
+ m_style_2 = new QComboBox( false, groupBox1_2, "m_style_2" );
+ m_style_2->setEnabled( false );
+ groupBox1_2Layout->addWidget( m_style_2, 1, 1 );
+
+ m_firstValue_2 = new KLineEdit( groupBox1_2, "m_firstValue_2" );
+ m_firstValue_2->setEnabled( false );
+ groupBox1_2Layout->addWidget( m_firstValue_2, 0, 2 );
+
+ m_secondValue_2 = new KLineEdit( groupBox1_2, "m_secondValue_2" );
+ m_secondValue_2->setEnabled( false );
+
+ groupBox1_2Layout->addWidget( m_secondValue_2, 0, 3 );
+
+ QSpacerItem * spacer_3 = new QSpacerItem( 41, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ groupBox1_2Layout->addItem( spacer_3, 1, 2 );
+ QSpacerItem * spacer_4 = new QSpacerItem( 61, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ groupBox1_2Layout->addItem( spacer_4, 1, 3 );
+ Form1Layout->addWidget( groupBox1_2, 1, 0 );
+
+ QGroupBox * groupBox1_1 = new QGroupBox( this, "groupBox1_1" );
+ groupBox1_1->setColumnLayout(0, Qt::Vertical );
+ groupBox1_1->layout()->setSpacing( KDialog::spacingHint() );
+ groupBox1_1->layout()->setMargin( KDialog::marginHint() );
+
+ QGridLayout * groupBox1_1Layout = new QGridLayout( groupBox1_1->layout() );
+ groupBox1_1Layout->setAlignment( Qt::AlignTop );
+
+ QLabel * textLabel1_1 = new QLabel( groupBox1_1, "textLabel1_2_2" );
+ groupBox1_1Layout->addWidget( textLabel1_1, 0, 0 );
+
+ QLabel * textLabel2_1 = new QLabel( groupBox1_1, "textLabel2_2_2" );
+ groupBox1_1Layout->addWidget( textLabel2_1, 1, 0 );
+
+ m_condition_1 = new QComboBox( false, groupBox1_1, "m_condition_1" );
+ groupBox1_1Layout->addWidget( m_condition_1, 0, 1 );
+
+ m_style_1 = new QComboBox( false, groupBox1_1, "m_style_1" );
+ m_style_1->setEnabled( false );
+ groupBox1_1Layout->addWidget( m_style_1, 1, 1 );
+
+ m_firstValue_1 = new KLineEdit( groupBox1_1, "m_firstValue_1" );
+ m_firstValue_1->setEnabled( false );
+ groupBox1_1Layout->addWidget( m_firstValue_1, 0, 2 );
+
+ m_secondValue_1 = new KLineEdit( groupBox1_1, "m_secondValue_1" );
+ m_secondValue_1->setEnabled( false );
+ groupBox1_1Layout->addWidget( m_secondValue_1, 0, 3 );
+
+ QSpacerItem * spacer_5 = new QSpacerItem( 41, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ groupBox1_1Layout->addItem( spacer_5, 1, 2 );
+ QSpacerItem * spacer_6 = new QSpacerItem( 61, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ groupBox1_1Layout->addItem( spacer_6, 1, 3 );
+
+ Form1Layout->addWidget( groupBox1_1, 0, 0 );
+ resize( QSize(702, 380).expandedTo( minimumSizeHint() ) );
+ clearWState( WState_Polished );
+
+ QStringList list;
+ list += i18n( "<none>" );
+ list += i18n( "equal to" );
+ list += i18n( "greater than" );
+ list += i18n( "less than" );
+ list += i18n( "equal to or greater than" );
+ list += i18n( "equal to or less than" );
+ list += i18n( "between" );
+ list += i18n( "outside range" );
+ list += i18n( "different to" );
+
+ m_condition_1->clear();
+ m_condition_2->clear();
+ m_condition_3->clear();
+ m_condition_1->insertStringList( list );
+ m_condition_2->insertStringList( list );
+ m_condition_3->insertStringList( list );
+
+ groupBox1_1->setTitle( i18n( "First Condition" ) );
+ groupBox1_2->setTitle( i18n( "Second Condition" ) );
+ groupBox1_3->setTitle( i18n( "Third Condition" ) );
+ textLabel1_1->setText( i18n( "Cell is" ) );
+ textLabel1_2->setText( i18n( "Cell is" ) );
+ textLabel1_3->setText( i18n( "Cell is" ) );
+ textLabel2_1->setText( i18n( "Cell style" ) );
+ textLabel2_2->setText( i18n( "Cell style" ) );
+ textLabel2_3->setText( i18n( "Cell style" ) );
+
+ connect( m_condition_1, SIGNAL( highlighted( const QString & ) ), this, SLOT( slotTextChanged1( const QString & ) ) );
+ connect( m_condition_2, SIGNAL( highlighted( const QString & ) ), this, SLOT( slotTextChanged2( const QString & ) ) );
+ connect( m_condition_3, SIGNAL( highlighted( const QString & ) ), this, SLOT( slotTextChanged3( const QString & ) ) );
+}
+
+ConditionalWidget::~ConditionalWidget()
+{
+}
+
+void ConditionalWidget::slotTextChanged1( const QString & text )
+{
+ if ( text == i18n( "<none>" ) )
+ {
+ m_firstValue_1->setEnabled( false );
+ m_secondValue_1->setEnabled( false );
+ m_style_1->setEnabled( false );
+ }
+ else
+ {
+ m_condition_2->setEnabled( true );
+ m_style_1->setEnabled( true );
+ if ( ( text == i18n( "between" ) ) || ( text == i18n( "different from" ) ) )
+ {
+ m_firstValue_1->setEnabled( true );
+ m_secondValue_1->setEnabled( true );
+ }
+ else
+ {
+ m_firstValue_1->setEnabled( true );
+ m_secondValue_1->setEnabled( false );
+ }
+ }
+}
+
+void ConditionalWidget::slotTextChanged2( const QString & text )
+{
+ if ( text == i18n( "<none>" ) )
+ {
+ m_firstValue_2->setEnabled( false );
+ m_secondValue_2->setEnabled( false );
+ m_style_2->setEnabled( false );
+ }
+ else
+ {
+ m_condition_3->setEnabled( true );
+ m_style_2->setEnabled( true );
+ if ( ( text == i18n( "between" ) ) || ( text == i18n( "different from" ) ) )
+ {
+ m_firstValue_2->setEnabled( true );
+ m_secondValue_2->setEnabled( true );
+ }
+ else
+ {
+ m_firstValue_2->setEnabled( true );
+ m_secondValue_2->setEnabled( false );
+ }
+ }
+}
+
+void ConditionalWidget::slotTextChanged3( const QString & text )
+{
+ if ( text == i18n( "<none>" ) )
+ {
+ m_firstValue_3->setEnabled( false );
+ m_secondValue_3->setEnabled( false );
+ m_style_3->setEnabled( false );
+ }
+ else
+ {
+ m_style_3->setEnabled( true );
+ if ( ( text == i18n( "between" ) ) || ( text == i18n( "different from" ) ) )
+ {
+ m_firstValue_3->setEnabled( true );
+ m_secondValue_3->setEnabled( true );
+ }
+ else
+ {
+ m_firstValue_3->setEnabled( true );
+ m_secondValue_3->setEnabled( false );
+ }
+ }
+}
+
+/**
+ * ConditionalDialog
+ * Sets conditional cell formattings.
+ */
+ConditionalDialog::ConditionalDialog( View * parent, const char * name,
+ const QRect & marker )
+ : KDialogBase( parent, name, true, "", KDialogBase::Ok | KDialogBase::Cancel,
+ KDialogBase::Ok, false ),
+ m_view( parent ),
+ m_dlg( new ConditionalWidget( this ) ),
+ m_marker( marker )
+{
+ QStringList list( m_view->doc()->styleManager()->styleNames() );
+
+ m_dlg->m_style_1->insertStringList( list );
+ m_dlg->m_style_2->insertStringList( list );
+ m_dlg->m_style_3->insertStringList( list );
+
+ setCaption( i18n( "Conditional Cell Attributes" ) );
+ setButtonBoxOrientation( Vertical );
+ setMainWidget( m_dlg );
+
+ init();
+}
+
+void ConditionalDialog::init()
+{
+ QValueList<Conditional> conditionList;
+ QValueList<Conditional> otherList;
+ bool found;
+ int numCondition;
+
+ QValueList<Conditional>::iterator it1;
+ QValueList<Conditional>::iterator it2;
+
+ Cell * obj = m_view->activeSheet()->cellAt( m_marker.left(),
+ m_marker.top() );
+
+ conditionList = obj->conditionList();
+ /* this is the list, but only display the conditions common to all selected
+ cells*/
+
+ for ( int x = m_marker.left(); x <= m_marker.right(); x++ )
+ {
+ for ( int y = m_marker.top(); y <= m_marker.bottom(); y++ )
+ {
+ Cell * obj2 = m_view->activeSheet()->cellAt( x, y );
+ otherList = obj2->conditionList();
+
+ it1 = conditionList.begin();
+ while ( it1 != conditionList.end() )
+ {
+ kdDebug() << "Here" << endl;
+ found = false;
+ for ( it2 = otherList.begin(); !found && it2 != otherList.end(); ++it2 )
+ {
+ kdDebug() << "Found: " << found << endl;
+ found = ( (*it1).val1 == (*it2).val1 &&
+ (*it1).val2 == (*it2).val2 &&
+ (*it1).cond == (*it2).cond );
+
+ if ( (*it1).strVal1 && !(*it2).strVal1 )
+ found = false;
+ if ( !(*it1).strVal1 && (*it2).strVal1 )
+ found = false;
+ if ( (*it1).strVal1 && (*it2).strVal1
+ && ( *(*it1).strVal1 != *(*it2).strVal1 ) )
+ found = false;
+ if ( !found )
+ continue;
+
+ if ( (*it1).strVal2 && !(*it2).strVal2 )
+ found = false;
+ if ( !(*it1).strVal2 && (*it2).strVal2 )
+ found = false;
+ if ( (*it1).strVal2 && (*it2).strVal2
+ && ( *(*it1).strVal2 != *(*it2).strVal2 ) )
+ found = false;
+ if ( !found )
+ continue;
+
+ if ( (*it1).colorcond && !(*it2).colorcond )
+ found = false;
+ if ( !(*it1).colorcond && (*it2).colorcond )
+ found = false;
+ if ( (*it1).colorcond && (*it2).colorcond
+ && ( *(*it1).colorcond != *(*it2).colorcond ) )
+ found = false;
+ if ( !found )
+ continue;
+
+ if ( (*it1).fontcond && !(*it2).fontcond )
+ found = false;
+ if ( !(*it1).fontcond && (*it2).fontcond )
+ found = false;
+ if ( (*it1).fontcond && (*it2).fontcond
+ && ( *(*it1).fontcond != *(*it2).fontcond ) )
+ found = false;
+ if ( !found )
+ continue;
+
+ if ( (*it1).styleName && !(*it2).styleName )
+ found = false;
+ if ( !(*it1).styleName && (*it2).styleName )
+ found = false;
+ if ( (*it1).styleName && (*it2).styleName
+ && ( *(*it1).styleName != *(*it2).styleName ) )
+ found = false;
+ }
+
+ if ( !found ) /* if it's not here, don't display this condition */
+ {
+ it1 = conditionList.remove( it1 );
+ }
+ else
+ {
+ ++it1;
+ }
+ }
+ }
+ }
+
+ kdDebug() << "Conditions: " << conditionList.size() << endl;
+
+ m_dlg->m_condition_2->setEnabled( false );
+ m_dlg->m_condition_3->setEnabled( false );
+
+ m_dlg->m_style_1->setEnabled( false );
+ m_dlg->m_style_2->setEnabled( false );
+ m_dlg->m_style_3->setEnabled( false );
+
+ numCondition = 0;
+ for ( it1 = conditionList.begin(); numCondition < 3 && it1 != conditionList.end(); ++it1 )
+ {
+ init( *it1, numCondition );
+
+ ++numCondition;
+ }
+}
+
+void ConditionalDialog::init( Conditional const & tmp, int numCondition )
+{
+ kdDebug() << "Adding " << numCondition << endl;
+ QComboBox * cb = 0;
+ QComboBox * sb = 0;
+ KLineEdit * kl1 = 0;
+ KLineEdit * kl2 = 0;
+ QString value;
+
+ switch( numCondition )
+ {
+ case 0:
+ cb = m_dlg->m_condition_1;
+ sb = m_dlg->m_style_1;
+ kl1 = m_dlg->m_firstValue_1;
+ kl2 = m_dlg->m_secondValue_1;
+ break;
+ case 1:
+ cb = m_dlg->m_condition_2;
+ sb = m_dlg->m_style_2;
+ kl1 = m_dlg->m_firstValue_2;
+ kl2 = m_dlg->m_secondValue_2;
+ break;
+ case 2:
+ cb = m_dlg->m_condition_3;
+ sb = m_dlg->m_style_3;
+ kl1 = m_dlg->m_firstValue_3;
+ kl2 = m_dlg->m_secondValue_3;
+ break;
+ default:
+ return;
+ }
+
+ if ( tmp.styleName )
+ {
+ sb->setCurrentText( *tmp.styleName );
+ sb->setEnabled( true );
+ }
+
+ switch( tmp.cond )
+ {
+ case Conditional::None :
+ break;
+
+ case Conditional::Equal :
+ cb->setCurrentItem( 1 );
+ break;
+
+ case Conditional::Superior :
+ cb->setCurrentItem( 2 );
+ break;
+
+ case Conditional::Inferior :
+ cb->setCurrentItem( 3 );
+ break;
+
+ case Conditional::SuperiorEqual :
+ cb->setCurrentItem( 4 );
+ break;
+
+ case Conditional::InferiorEqual :
+ cb->setCurrentItem( 5 );
+ break;
+
+ case Conditional::Between :
+ cb->setCurrentItem(6);
+
+ if ( tmp.strVal2 )
+ kl2->setText( *tmp.strVal2 );
+ else
+ {
+ value = value.setNum( tmp.val2 );
+ kl2->setText( value );
+ }
+ break;
+
+ case Conditional::Different :
+ cb->setCurrentItem(7);
+ if ( tmp.strVal2 )
+ kl2->setText( *tmp.strVal2 );
+ else
+ {
+ value = value.setNum( tmp.val2 );
+ kl2->setText( value );
+ }
+ break;
+ case Conditional::DifferentTo :
+ cb->setCurrentItem(8);
+ break;
+ }
+
+ if ( tmp.cond != Conditional::None )
+ {
+ kl1->setEnabled( true );
+
+ if ( tmp.strVal1 )
+ kl1->setText( *tmp.strVal1 );
+ else
+ {
+ value = value.setNum( tmp.val1 );
+ kl1->setText( value );
+ }
+ }
+}
+
+Conditional::Type ConditionalDialog::typeOfCondition( QComboBox const * const cb ) const
+{
+ Conditional::Type result = Conditional::None;
+ switch( cb->currentItem() )
+ {
+ case 0 :
+ result = Conditional::None;
+ break;
+ case 1 :
+ result = Conditional::Equal;
+ break;
+ case 2 :
+ result = Conditional::Superior;
+ break;
+ case 3 :
+ result = Conditional::Inferior;
+ break;
+ case 4 :
+ result = Conditional::SuperiorEqual;
+ break;
+ case 5 :
+ result = Conditional::InferiorEqual;
+ break;
+ case 6 :
+ result = Conditional::Between;
+ break;
+ case 7 :
+ result = Conditional::Different;
+ break;
+ case 8 :
+ result = Conditional::DifferentTo;
+ break;
+ default:
+ kdDebug(36001) << "Error in list" << endl;
+ break;
+ }
+
+ return result;
+}
+
+bool ConditionalDialog::checkInputData( KLineEdit const * const edit1,
+ KLineEdit const * const edit2 )
+{
+ bool b1 = false;
+ bool b2 = false;
+
+ if ( !edit2->isEnabled() )
+ return true;
+
+ edit1->text().toDouble( &b1 );
+ edit2->text().toDouble( &b2 );
+
+ if ( b1 != b2 )
+ {
+ if ( b1 )
+ KMessageBox::sorry( 0, i18n( "If the first value is a number, the second value also has to be a number." ) );
+ else
+ KMessageBox::sorry( 0, i18n( "If the first value is a string, the second value also has to be a string." ) );
+ return false;
+ }
+
+ return true;
+}
+
+bool ConditionalDialog::checkInputData()
+{
+ if ( m_dlg->m_firstValue_1->isEnabled() && !checkInputData( m_dlg->m_firstValue_1, m_dlg->m_secondValue_1 ) )
+ return false;
+ if ( m_dlg->m_firstValue_2->isEnabled() && !checkInputData( m_dlg->m_firstValue_2, m_dlg->m_secondValue_2 ) )
+ return false;
+ if ( m_dlg->m_firstValue_3->isEnabled() && !checkInputData( m_dlg->m_firstValue_3, m_dlg->m_secondValue_3 ) )
+ return false;
+
+ return true;
+}
+
+bool ConditionalDialog::getCondition( Conditional & newCondition, const QComboBox * cb,
+ const KLineEdit * edit1, const KLineEdit * edit2,
+ const QComboBox * sb, Style * style )
+{
+ if ( !cb->isEnabled() )
+ return false;
+
+ newCondition.cond = typeOfCondition( cb );
+ if ( newCondition.cond == Conditional::None )
+ return false;
+
+ bool ok = false;
+ double d1 = edit1->text().toDouble( &ok );
+ double d2 = 0.0;
+ QString * s1 = 0;
+ QString * s2 = 0;
+ QString * sn = 0;
+
+ if ( ok )
+ {
+ if ( edit2->isEnabled() )
+ d2 = edit2->text().toDouble( &ok );
+ // values are already checked...
+ }
+ else
+ {
+ d1 = 0.0;
+ s1 = new QString( edit1->text() );
+
+ if ( edit2->isEnabled() )
+ s2 = new QString( edit2->text() );
+ }
+ sn = new QString( sb->currentText() );
+
+ newCondition.val1 = d1;
+ newCondition.val2 = d2;
+ newCondition.strVal1 = s1;
+ newCondition.strVal2 = s2;
+ newCondition.fontcond = 0;
+ newCondition.colorcond = 0;
+ newCondition.styleName = sn;
+ newCondition.style = style;
+
+ return true;
+}
+
+void ConditionalDialog::slotOk()
+{
+ kdDebug() << "slotOk" << endl;
+
+ if ( !checkInputData() )
+ return;
+
+ kdDebug() << "Input data is valid" << endl;
+
+ m_view->doc()->emitBeginOperation( false );
+ StyleManager * manager = m_view->doc()->styleManager();
+
+ QValueList<Conditional> newList;
+
+ Conditional newCondition;
+
+ if ( getCondition( newCondition, m_dlg->m_condition_1, m_dlg->m_firstValue_1,
+ m_dlg->m_secondValue_1, m_dlg->m_style_1, manager->style( m_dlg->m_style_1->currentText() ) ) )
+ newList.append( newCondition );
+
+ if ( getCondition( newCondition, m_dlg->m_condition_2, m_dlg->m_firstValue_2,
+ m_dlg->m_secondValue_2, m_dlg->m_style_2, manager->style( m_dlg->m_style_2->currentText() ) ) )
+ newList.append( newCondition );
+
+ if ( getCondition( newCondition, m_dlg->m_condition_3, m_dlg->m_firstValue_3,
+ m_dlg->m_secondValue_3, m_dlg->m_style_3, manager->style( m_dlg->m_style_3->currentText() ) ) )
+ newList.append( newCondition );
+
+ kdDebug() << "Setting conditional list" << endl;
+ m_view->activeSheet()->setConditional( m_view->selectionInfo(), newList );
+ m_view->slotUpdateView( m_view->activeSheet(), *m_view->selectionInfo() );
+
+ accept();
+}
+
+#include "kspread_dlg_conditional.moc"
+
+
diff --git a/kspread/dialogs/kspread_dlg_conditional.h b/kspread/dialogs/kspread_dlg_conditional.h
new file mode 100644
index 00000000..4b0e065c
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_conditional.h
@@ -0,0 +1,103 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1999-2004 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_conditional__
+#define __kspread_dlg_conditional__
+
+#include <kdialogbase.h>
+#include <qwidget.h>
+
+#include "kspread_condition.h"
+
+class QComboBox;
+class KLineEdit;
+
+namespace KSpread
+{
+class Style;
+class View;
+
+class ConditionalWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ ConditionalWidget( QWidget * parent = 0, const char * name = 0, WFlags fl = 0 );
+ ~ConditionalWidget();
+
+ QComboBox * m_condition_1;
+ QComboBox * m_style_1;
+ KLineEdit * m_firstValue_1;
+ KLineEdit * m_secondValue_1;
+
+ QComboBox * m_condition_2;
+ QComboBox * m_style_2;
+ KLineEdit * m_firstValue_2;
+ KLineEdit * m_secondValue_2;
+
+ QComboBox * m_condition_3;
+ QComboBox * m_style_3;
+ KLineEdit * m_firstValue_3;
+ KLineEdit * m_secondValue_3;
+
+ public slots:
+ void slotTextChanged1( const QString & );
+ void slotTextChanged2( const QString & );
+ void slotTextChanged3( const QString & );
+};
+
+
+class ConditionalDialog : public KDialogBase
+{
+ Q_OBJECT
+ public:
+ ConditionalDialog( View * parent, const char * name,
+ const QRect & marker );
+
+ void init();
+
+ public slots:
+ void slotOk();
+
+ protected:
+ View * m_view;
+ ConditionalWidget * m_dlg;
+ QRect m_marker;
+ Conditional::Type m_result;
+
+ private:
+ void init( Conditional const & tmp, int numCondition );
+ Conditional::Type typeOfCondition( QComboBox const * const cb ) const;
+
+ bool checkInputData( KLineEdit const * const edit1,
+ KLineEdit const * const edit2 );
+ bool checkInputData();
+ bool getCondition( Conditional & newCondition, const QComboBox * cb,
+ const KLineEdit * edit1, const KLineEdit * edit2,
+ const QComboBox * sb, Style * style );
+
+};
+
+} // namespace KSpread
+
+#endif
+
diff --git a/kspread/dialogs/kspread_dlg_cons.cc b/kspread/dialogs/kspread_dlg_cons.cc
new file mode 100644
index 00000000..7f10e610
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_cons.cc
@@ -0,0 +1,687 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2000-2001 Werner Trobin <trobin@kde.org>
+ (C) 2000-2001 Laurent Montel <montel@kde.org>
+ (C) 1999-2002 David Faure <faure@kde.org>
+ (C) 1999 Stephan Kulow <coolo@kde.org>
+ (C) 1999 Reginald Stadlbauer <reggie@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <assert.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <kmessagebox.h>
+
+#include "kspread_dlg_cons.h"
+
+#include <kspread_canvas.h>
+#include <kspread_doc.h>
+#include <kspread_global.h>
+#include <kspread_locale.h>
+#include "selection.h"
+#include <kspread_sheet.h>
+#include <kspread_util.h>
+#include <kspread_view.h>
+
+#include <formula.h>
+#include <valueconverter.h>
+
+using namespace KSpread;
+
+ConsolidateDialog::ConsolidateDialog( View* parent, const char* name )
+ : KDialogBase( parent, name, false, i18n("Consolidate"), Ok|Cancel )
+{
+ m_pView = parent;
+
+ QWidget* page = new QWidget( this );
+ setMainWidget( page );
+
+ QGridLayout *grid1 = new QGridLayout( page, 12, 2, marginHint(), spacingHint() );
+
+ QLabel* tmpQLabel;
+ tmpQLabel = new QLabel( page, "Label_1" );
+ grid1->addWidget(tmpQLabel,0,0);
+ tmpQLabel->setText( i18n("&Function:") );
+
+ m_pFunction = new QComboBox( page );
+ grid1->addWidget(m_pFunction,1,0);
+ tmpQLabel->setBuddy(m_pFunction);
+
+ m_pFunction->insertItem( i18n("Sum"), Sum );
+ m_pFunction->insertItem( i18n("Average"), Average );
+ m_pFunction->insertItem( i18n("Count"), Count );
+ m_pFunction->insertItem( i18n("Max"), Max );
+ m_pFunction->insertItem( i18n("Min"), Min );
+ m_pFunction->insertItem( i18n("Product"), Product );
+ m_pFunction->insertItem( i18n("Standard Deviation"), StdDev );
+ m_pFunction->insertItem( i18n("Variance"), Var );
+
+ tmpQLabel = new QLabel( page, "Label_1" );
+ tmpQLabel->setText( i18n("Re&ference:") );
+ grid1->addWidget(tmpQLabel,2,0);
+
+ m_pRef = new QLineEdit( page );
+ grid1->addWidget(m_pRef,3,0);
+ tmpQLabel->setBuddy(m_pRef);
+
+ tmpQLabel = new QLabel( page, "Label_1" );
+ grid1->addWidget(tmpQLabel,4,0);
+ tmpQLabel->setText( i18n("&Entered references:") );
+
+ m_pRefs = new QListBox( page );
+ grid1->addMultiCellWidget( m_pRefs,5,8,0,0);
+ tmpQLabel->setBuddy(m_pRefs);
+
+ m_pRow = new QCheckBox( i18n("&Description in row"), page );
+ grid1->addWidget( m_pRow,9,0);
+ m_pCol = new QCheckBox( i18n("De&scription in column"), page );
+ grid1->addWidget(m_pCol,10,0);
+ m_pCopy = new QCheckBox( i18n("Co&py data"), page );
+ grid1->addWidget(m_pCopy,11,0);
+
+ m_pAdd = new QPushButton( i18n("&Add"), page );
+ grid1->addWidget(m_pAdd,2,1);
+ m_pRemove = new QPushButton( i18n("&Remove"), page );
+ grid1->addWidget(m_pRemove,3,1);
+
+
+ connect( m_pAdd, SIGNAL( clicked() ), this, SLOT( slotAdd() ) );
+ connect( m_pRemove, SIGNAL( clicked() ), this, SLOT( slotRemove() ) );
+ connect( m_pRef, SIGNAL( returnPressed() ), this, SLOT( slotReturnPressed() ) );
+
+ connect(m_pView->selectionInfo(), SIGNAL(changed(const Region&)),
+ this, SLOT(slotSelectionChanged()));
+}
+
+ConsolidateDialog::~ConsolidateDialog()
+{
+ kdDebug(36001)<<"Consolidate::~Consolidate()\n";
+}
+
+enum Description { D_ROW, D_COL, D_NONE, D_BOTH };
+
+struct st_cell
+{
+ QString xdesc;
+ QString ydesc;
+ Cell* cell;
+ QString sheet;
+ int x;
+ int y;
+};
+
+void ConsolidateDialog::slotOk()
+{
+ m_pView->doc()->emitBeginOperation( false );
+
+ Map *map = m_pView->doc()->map();
+
+ Sheet* sheet = m_pView->activeSheet();
+ int dx = m_pView->selectionInfo()->selection().left();
+ int dy = m_pView->selectionInfo()->selection().top();
+
+ QString function;
+
+ switch( m_pFunction->currentItem() )
+ {
+ case Sum: function = "SUM"; break;
+ case Average: function = "AVERAGE"; break;
+ case Count: function = "COUNT"; break;
+ case Max: function = "MAX"; break;
+ case Min: function = "MIN"; break;
+ case Product: function = "PRODUCT"; break;
+ case StdDev: function = "STDDEV"; break;
+ case Var: function = "VARIANCE"; break;
+ default: break; // bad bad !
+ }
+
+ QStringList r = refs();
+ QValueList<Range> ranges;
+ QStringList::Iterator s = r.begin();
+ for( ; s != r.end(); ++s )
+ {
+ Range r( *s, map );
+ // TODO: Check for valid
+ Q_ASSERT( r.isValid() );
+
+ if ( r.sheet() == 0 )
+ {
+ r.setSheet(sheet);
+ r.setSheetName(sheet->sheetName());
+ }
+ ranges.append( r );
+ }
+
+ Description desc;
+ if ( m_pRow->isChecked() && m_pCol->isChecked() )
+ desc = D_BOTH;
+ else if ( m_pRow->isChecked() )
+ desc = D_ROW;
+ else if ( m_pCol->isChecked() )
+ desc = D_COL;
+ else
+ desc = D_NONE;
+
+ // Check whether all ranges have same size
+ Q_ASSERT( ranges.count() > 0 );
+ QValueList<Range>::Iterator it = ranges.begin();
+ int w = (*it).range().right() - (*it).range().left() + 1;
+ int h = (*it).range().bottom() - (*it).range().top() + 1;
+ if ( w <= ( ( desc == D_BOTH || desc == D_COL ) ? 1 : 0 ) ||
+ h <= ( ( desc == D_BOTH || desc == D_ROW ) ? 1 : 0 ) )
+ {
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ KMessageBox::error( this, i18n( "The range\n%1\nis too small" ).arg( *( r.begin() ) ));
+ return;
+ }
+
+ if( (*it).range().bottom()==KS_rowMax || (*it).range().right()== KS_colMax )
+ {
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ KMessageBox::error( this, i18n( "The range\n%1\nis too large" ).arg( *( r.begin() ) ));
+ return;
+ }
+
+ ++it;
+ int i = 1;
+ for( ; it != ranges.end(); ++it, i++ )
+ {
+ QRect currentRange=(*it).range();
+
+ int w2 = currentRange.right() - currentRange.left() + 1;
+ int h2 = currentRange.bottom() - currentRange.top() + 1;
+
+ if(currentRange.bottom()==KS_rowMax || currentRange.right()== KS_colMax)
+ {
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ KMessageBox::error( this, i18n( "The range\n%1\nis too large" ).arg( r[i]));
+ return;
+ }
+ if ( ( desc == D_NONE && ( w != w2 || h != h2 ) ) ||
+ ( desc == D_ROW && h != h2 ) ||
+ ( desc == D_COL && w != w2 ) )
+ {
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ QString tmp = i18n( "The ranges\n%1\nand\n%2\nhave different size").arg( *( r.begin() ) ).arg( r[i] );
+ KMessageBox::error( this, tmp);
+ return;
+ }
+ }
+
+ // Create the consolidation sheet
+ if ( desc == D_NONE )
+ {
+ // Check whether the destination is part of the source ...
+ QRect dest;
+ dest.setCoords( dx, dy, dx + w - 1, dy + h - 1 );
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ Sheet *t = (*it).sheet();
+ Q_ASSERT( t );
+ QRect r;
+
+ QRect currentRange=(*it).range();
+
+ r.setCoords( currentRange.left(), currentRange.top(), currentRange.right(), currentRange.bottom() );
+ if ( t == sheet && r.intersects( dest ) )
+ {
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ QString tmp( i18n("The source tables intersect with the destination table") );
+ KMessageBox::error( this, tmp);
+ return;
+ }
+ }
+
+ for( int x = 0; x < w; x++ )
+ {
+ for( int y = 0; y < h; y++ )
+ {
+ bool novalue=true;
+ QString formula = "=" + function + "(";
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+ Cell *c = t->cellAt( x + (*it).range().left(), y + (*it).range().top() );
+ if(!c->isDefault())
+ novalue=false;
+ if ( it != ranges.begin() )
+ formula += ";";
+ formula += (*it).sheetName() + "!";
+ formula += c->name();
+ }
+ formula += ")";
+
+ if(!novalue)
+ sheet->setText( dy + y, dx + x,
+ m_pCopy->isChecked() ? evaluate( formula, sheet ) : formula );
+ }
+ }
+ }
+ else if ( desc == D_ROW )
+ {
+ // Get list of all descriptions in the rows
+ QStringList lst;
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+// kdDebug(36001) << "FROM " << (*it).range.left() << " to " << (*it).range.right() << endl;
+ for( int x = (*it).range().left(); x <= (*it).range().right() ; ++x )
+ {
+ Cell *c = t->cellAt( x, (*it).range().top() );
+ if ( c )
+ {
+ QString s = c->value().asString();
+ if ( !lst.contains( s ) )
+ lst.append( s );
+ }
+ }
+ }
+ lst.sort();
+
+ // Check whether the destination is part of the source ...
+ QRect dest;
+ dest.setCoords( dx, dy, dx + lst.count() - 1, dy + h - 1 );
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+ QRect r;
+ QRect currentRange=(*it).range();
+ r.setCoords( currentRange.left(), currentRange.top(), currentRange.right(), currentRange.bottom() );
+ if ( t == sheet && r.intersects( dest ) )
+ {
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ QString tmp( i18n("The source tables intersect with the destination table") );
+ KMessageBox::error( this, tmp);
+ return;
+ }
+ }
+
+ // Now create the consolidation sheet
+ int x = 0;
+ QStringList::Iterator s = lst.begin();
+ for( ; s != lst.end(); ++s, ++x )
+ {
+ sheet->setText( dy, dx + x, *s );
+
+ for( int y = 1; y < h; ++y )
+ {
+ int count = 0;
+ QString formula = "=" + function + "(";
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ for( int i = (*it).range().left(); i <= (*it).range().right(); ++i )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+ Cell *c = t->cellAt( i, (*it).range().top() );
+ if ( c )
+ {
+ if ( c->value().asString() == *s )
+ {
+// Cell *c2 = t->cellAt( i, y + (*it).range.top() );
+ count++;
+ if ( it != ranges.begin() )
+ formula += ";";
+ formula += (*it).sheetName() + "!";
+ formula += Cell::name( i, y + (*it).range().top() );
+ }
+ }
+ }
+ }
+ formula += ")";
+
+ sheet->setText( dy + y, dx + x,
+ m_pCopy->isChecked() ? evaluate( formula, sheet ) : formula );
+ }
+ }
+ }
+ else if ( desc == D_COL )
+ {
+ // Get list of all descriptions in the columns
+ QStringList lst;
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+ for( int y = (*it).range().top(); y <= (*it).range().bottom() ; ++y )
+ {
+ Cell *c = t->cellAt( (*it).range().left(), y );
+ if ( c )
+ {
+ QString s = c->value().asString();
+ if ( !s.isEmpty() && lst.find( s ) == lst.end() )
+ lst.append( s );
+ }
+ }
+ }
+ lst.sort();
+
+ // Check whether the destination is part of the source ...
+ QRect dest;
+ dest.setCoords( dx, dy, dx + w - 1, dy + lst.count() - 1 );
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+ QRect r;
+ QRect currentRange=(*it).range();
+ r.setCoords( currentRange.left(), currentRange.top(), currentRange.right(), currentRange.bottom() );
+ if ( t == sheet && r.intersects( dest ) )
+ {
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ QString tmp( i18n("The source tables intersect with the destination table") );
+ KMessageBox::error( this, tmp);
+ return;
+ }
+ }
+
+ // Now create the consolidation sheet
+ int y = 0;
+ QStringList::Iterator s = lst.begin();
+ for( ; s != lst.end(); ++s, ++y )
+ {
+ sheet->setText( dy + y, dx, *s );
+
+ for( int x = 1; x < w; ++x )
+ {
+ int count = 0;
+ QString formula = "=" + function + "(";
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ for( int i = (*it).range().top(); i <= (*it).range().bottom(); i++ )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+ Cell *c = t->cellAt( (*it).range().left(), i );
+ if ( c )
+ {
+ QString v = c->value().asString();
+ if ( !v.isEmpty() && *s == v )
+ {
+// Cell *c2 = t->cellAt( x + (*it).range.left(), i );
+ count++;
+ if ( it != ranges.begin() ) formula += ";";
+ formula += (*it).sheetName() + "!";
+ formula += Cell::name( i, y + (*it).range().top() );
+ }
+ }
+ }
+ }
+
+ formula += ")";
+
+ sheet->setText( dy + y, dx + x,
+ m_pCopy->isChecked() ? evaluate( formula, sheet ) : formula );
+ }
+ }
+ }
+ else if ( desc == D_BOTH )
+ {
+ // Get list of all descriptions in the columns
+ QStringList cols;
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+ for( int y = (*it).range().top() + 1; y <= (*it).range().bottom() ; ++y )
+ {
+ Cell *c = t->cellAt( (*it).range().left(), y );
+ if ( c )
+ {
+ QString s = c->value().asString();
+ if ( !s.isEmpty() && cols.find( s ) == cols.end() )
+ cols.append( s );
+ }
+ }
+ }
+ cols.sort();
+
+ // Get list of all descriptions in the rows
+ QStringList rows;
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+ for( int x = (*it).range().left() + 1; x <= (*it).range().right() ; ++x )
+ {
+ Cell *c = t->cellAt( x, (*it).range().top() );
+ if ( c )
+ {
+ QString s = c->value().asString();
+ if ( !s.isEmpty() && rows.find( s ) == rows.end() )
+ rows.append( s );
+ }
+ }
+ }
+ rows.sort();
+
+ // Check whether the destination is part of the source ...
+ QRect dest;
+ dest.setCoords( dx, dy, dx + cols.count(), dy + rows.count() );
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+ QRect r;
+ QRect currentRange=(*it).range();
+ r.setCoords( currentRange.left(), currentRange.top(), currentRange.right(), currentRange.bottom() );
+ if ( t == sheet && r.intersects( dest ) )
+ {
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ QString tmp( i18n("The source tables intersect with the destination table") );
+ KMessageBox::error( this, tmp);
+ return;
+ }
+ }
+
+ // Fill the list with all interesting cells
+ QValueList<st_cell> lst;
+ it = ranges.begin();
+ for( ; it != ranges.end(); ++it )
+ {
+ Sheet *t = (*it).sheet();
+ assert( t );
+ for( int x = (*it).range().left() + 1; x <= (*it).range().right() ; ++x )
+ {
+ Cell *c = t->cellAt( x, (*it).range().top() );
+ if ( c )
+ {
+ QString ydesc = c->value().asString();
+ for( int y = (*it).range().top() + 1; y <= (*it).range().bottom() ; ++y )
+ {
+ Cell *c2 = t->cellAt( (*it).range().left(), y );
+ if ( c2 )
+ {
+ QString xdesc = c2->value().asString();
+ Cell *c3 = t->cellAt( x, y );
+ if ( c3 && c3->value().isNumber() )
+ {
+ st_cell k;
+ k.xdesc = xdesc;
+ k.ydesc = ydesc;
+ k.cell = c3;
+ k.sheet = (*it).sheetName();
+ k.x = x;
+ k.y = y;
+ lst.append( k );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Draw the row description
+ int i = 1;
+ QStringList::Iterator s = rows.begin();
+ for( ; s != rows.end(); ++s, ++i )
+ sheet->setText( dy, dx + i, *s );
+
+ // Draw the column description
+ i = 1;
+ s = cols.begin();
+ for( ; s != cols.end(); ++s, ++i )
+ sheet->setText( dy + i, dx, *s );
+
+ // Draw the data
+ int x = 1;
+ QStringList::Iterator ydesc = rows.begin();
+ for( ; ydesc != rows.end(); ++ydesc, x++ )
+ {
+ int y = 1;
+ QStringList::Iterator xdesc = cols.begin();
+ for( ; xdesc != cols.end(); ++xdesc, y++ )
+ {
+ int count = 0;
+ QString formula = "=" + function + "(";
+ QValueList<st_cell>::Iterator lit = lst.begin();
+ for( ; lit != lst.end(); ++lit )
+ {
+ if ( (*lit).xdesc == *xdesc && (*lit).ydesc == *ydesc )
+ {
+ count++;
+ if ( it != ranges.begin() ) formula += ";";
+ formula += (*it).sheetName() + "!";
+ formula += Cell::name( i, y + (*it).range().top() );
+ }
+ }
+ formula += ")";
+
+ sheet->setText( dy + y, dx + x,
+ m_pCopy->isChecked() ? evaluate( formula, sheet ) : formula );
+ }
+ }
+ }
+ m_pView->updateEditWidget();
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+ delete this;
+}
+
+void ConsolidateDialog::slotCancel()
+{
+ reject();
+ delete this;
+}
+
+void ConsolidateDialog::slotAdd()
+{
+ slotReturnPressed();
+}
+
+void ConsolidateDialog::slotRemove()
+{
+ int i = m_pRefs->currentItem();
+ if ( i < 0 )
+ return;
+
+ m_pRefs->removeItem( i );
+
+ if ( m_pRefs->count() == 0 )
+ actionButton( Ok )->setEnabled( false );
+}
+
+QStringList ConsolidateDialog::refs()
+{
+ QStringList list;
+ int c = m_pRefs->count();
+
+ for( int i = 0; i < c; i++ )
+ list.append( m_pRefs->text( i ) );
+
+ return list;
+}
+
+void ConsolidateDialog::slotSelectionChanged()
+{
+ if (!m_pView->selectionInfo()->isValid())
+ {
+ m_pRef->setText( "" );
+ return;
+ }
+
+ QString area = m_pView->selectionInfo()->name();
+ m_pRef->setText( area );
+ m_pRef->setSelection( 0, area.length() );
+}
+
+void ConsolidateDialog::slotReturnPressed()
+{
+ QString txt = m_pRef->text();
+
+ Range r( txt, m_pView->doc()->map() );
+ if ( !r.isValid() )
+ {
+ KMessageBox::error( this, i18n("The range\n%1\n is malformed").arg( txt ));
+ return;
+ }
+
+ if ( !txt.isEmpty() )
+ {
+ m_pRefs->insertItem( txt );
+ actionButton( Ok )->setEnabled( true );
+ }
+}
+
+void ConsolidateDialog::closeEvent ( QCloseEvent * )
+{
+ delete this;
+}
+
+QString ConsolidateDialog::evaluate( const QString& formula, Sheet* sheet )
+{
+ QString result = "###";
+ Formula *f = new Formula (sheet);
+ f->setExpression (formula);
+ if (!f->isValid()) {
+ delete f;
+ return result;
+ }
+
+ Value res = f->eval ();
+ delete f;
+ result = sheet->doc()->converter()->asString (res).asString ();
+ return result;
+}
+
+#include "kspread_dlg_cons.moc"
diff --git a/kspread/dialogs/kspread_dlg_cons.h b/kspread/dialogs/kspread_dlg_cons.h
new file mode 100644
index 00000000..d45e0fb8
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_cons.h
@@ -0,0 +1,83 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2000-2001 Werner Trobin <trobin@kde.org>
+ (C) 2000-2001 Laurent Montel <montel@kde.org>
+ (C) 1999-2002 David Faure <faure@kde.org>
+ (C) 1999 Stephan Kulow <coolo@kde.org>
+ (C) 1999 Reginald Stadlbauer <reggie@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_cons__
+#define __kspread_dlg_cons__
+
+#include <qstringlist.h>
+#include <kdialogbase.h>
+
+class QLineEdit;
+class QPushButton;
+class QComboBox;
+class QCheckBox;
+class QListBox;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class ConsolidateDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ ConsolidateDialog( View* parent, const char* name );
+ ~ConsolidateDialog();
+ QStringList refs();
+
+public slots:
+ virtual void slotOk();
+ virtual void slotCancel();
+ void slotAdd();
+ void slotRemove();
+
+ void slotSelectionChanged();
+ void slotReturnPressed();
+
+protected:
+ virtual void closeEvent ( QCloseEvent * );
+
+ View* m_pView;
+ QLineEdit* m_pRef;
+ QListBox* m_pRefs;
+ QComboBox* m_pFunction;
+ QPushButton* m_pAdd;
+ QPushButton* m_pRemove;
+ QCheckBox* m_pRow;
+ QCheckBox* m_pCol;
+ QCheckBox* m_pCopy;
+
+ QString evaluate( const QString& formula, Sheet* sheet );
+
+ enum { Sum = 0, Average, Count, Max, Min, Product, StdDev, Var };
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_csv.cc b/kspread/dialogs/kspread_dlg_csv.cc
new file mode 100644
index 00000000..3c103b8e
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_csv.cc
@@ -0,0 +1,735 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002-2003 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Laurent Montel <montel@kde.org>
+ (C) 1999 David Faure <faure@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qbuttongroup.h>
+#include <qcheckbox.h>
+#include <qclipboard.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qmime.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qtable.h>
+#include <qlayout.h>
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <kfiledialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include <kspread_cell.h>
+#include <kspread_doc.h>
+#include <kspread_sheet.h>
+#include <kspread_undo.h>
+#include <kspread_view.h>
+
+#include "kspread_dlg_csv.h"
+
+using namespace KSpread;
+
+CSVDialog::CSVDialog( View * parent, const char * name, QRect const & rect, Mode mode)
+ : KDialogBase( parent, name, true, QString::null, Ok|Cancel ),
+ m_pView( parent ),
+ m_cancelled( false ),
+ m_adjustRows( 0 ),
+ m_startline( 0 ),
+ m_textquote( '"' ),
+ m_delimiter( "," ),
+ m_targetRect( rect ),
+ m_mode( mode )
+{
+ if ( !name )
+ setName( "CSV" );
+
+ setSizeGripEnabled( TRUE );
+
+ QWidget* page = new QWidget( this );
+ setMainWidget( page );
+ // MyDialogLayout = new QGridLayout( page, 4, 4, marginHint(), spacingHint(), "MyDialogLayout");
+ MyDialogLayout = new QGridLayout( page, 1, 1, 11, 6, "MyDialogLayout");
+
+ // Limit the range
+ int column = m_targetRect.left();
+ Cell* lastCell = m_pView->activeSheet()->getLastCellColumn( column );
+ if( lastCell )
+ if( m_targetRect.bottom() > lastCell->row() )
+ m_targetRect.setBottom( lastCell->row() );
+
+ m_sheet = new QTable( page, "m_table" );
+ //m_sheet->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)7, 0, 0, m_sheet->sizePolicy().hasHeightForWidth() ) );
+ m_sheet->setNumRows( 0 );
+ m_sheet->setNumCols( 0 );
+
+ MyDialogLayout->addMultiCellWidget( m_sheet, 3, 3, 0, 3 );
+
+ // Delimiter: comma, semicolon, tab, space, other
+ m_delimiterBox = new QButtonGroup( page, "m_delimiterBox" );
+ m_delimiterBox->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, m_delimiterBox->sizePolicy().hasHeightForWidth() ) );
+ m_delimiterBox->setTitle( i18n( "Delimiter" ) );
+ m_delimiterBox->setColumnLayout(0, Qt::Vertical );
+ m_delimiterBox->layout()->setSpacing( KDialog::spacingHint() );
+ m_delimiterBox->layout()->setMargin( KDialog::marginHint() );
+ m_delimiterBoxLayout = new QGridLayout( m_delimiterBox->layout() );
+ m_delimiterBoxLayout->setAlignment( Qt::AlignTop );
+ MyDialogLayout->addMultiCellWidget( m_delimiterBox, 0, 2, 0, 0 );
+
+ m_ignoreDuplicates = new QCheckBox( page, "m_ignoreDuplicates" );
+ m_ignoreDuplicates->setText( i18n( "Ignore duplicate delimiters" ) );
+
+ MyDialogLayout->addMultiCellWidget( m_ignoreDuplicates, 2, 2, 2, 3 );
+
+ m_radioComma = new QRadioButton( m_delimiterBox, "m_radioComma" );
+ m_radioComma->setText( i18n( "Comma" ) );
+ m_radioComma->setChecked( TRUE );
+ m_delimiterBoxLayout->addWidget( m_radioComma, 0, 0 );
+
+ m_radioSemicolon = new QRadioButton( m_delimiterBox, "m_radioSemicolon" );
+ m_radioSemicolon->setText( i18n( "Semicolon" ) );
+ m_delimiterBoxLayout->addWidget( m_radioSemicolon, 0, 1 );
+
+ m_radioTab = new QRadioButton( m_delimiterBox, "m_radioTab" );
+ m_radioTab->setText( i18n( "Tabulator" ) );
+ m_delimiterBoxLayout->addWidget( m_radioTab, 1, 0 );
+
+ m_radioSpace = new QRadioButton( m_delimiterBox, "m_radioSpace" );
+ m_radioSpace->setText( i18n( "Space" ) );
+ m_delimiterBoxLayout->addWidget( m_radioSpace, 1, 1 );
+
+ m_radioOther = new QRadioButton( m_delimiterBox, "m_radioOther" );
+ m_radioOther->setText( i18n( "Other" ) );
+ m_delimiterBoxLayout->addWidget( m_radioOther, 0, 2 );
+
+ m_delimiterEdit = new QLineEdit( m_delimiterBox, "m_delimiterEdit" );
+ m_delimiterEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, m_delimiterEdit->sizePolicy().hasHeightForWidth() ) );
+ m_delimiterEdit->setMaximumSize( QSize( 30, 32767 ) );
+ m_delimiterBoxLayout->addWidget( m_delimiterEdit, 1, 2 );
+
+
+ // Format: number, text, currency,
+ m_formatBox = new QButtonGroup( page, "m_formatBox" );
+ m_formatBox->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, m_formatBox->sizePolicy().hasHeightForWidth() ) );
+ m_formatBox->setTitle( i18n( "Format" ) );
+ m_formatBox->setColumnLayout(0, Qt::Vertical );
+ m_formatBox->layout()->setSpacing( KDialog::spacingHint() );
+ m_formatBox->layout()->setMargin( KDialog::marginHint() );
+ m_formatBoxLayout = new QGridLayout( m_formatBox->layout() );
+ m_formatBoxLayout->setAlignment( Qt::AlignTop );
+ MyDialogLayout->addMultiCellWidget( m_formatBox, 0, 2, 1, 1 );
+
+ m_radioNumber = new QRadioButton( m_formatBox, "m_radioNumber" );
+ m_radioNumber->setText( i18n( "Number" ) );
+ m_formatBoxLayout->addMultiCellWidget( m_radioNumber, 1, 1, 0, 1 );
+
+ m_radioText = new QRadioButton( m_formatBox, "m_radioText" );
+ m_radioText->setText( i18n( "Text" ) );
+ m_radioText->setChecked( TRUE );
+ m_formatBoxLayout->addWidget( m_radioText, 0, 0 );
+
+ m_radioCurrency = new QRadioButton( m_formatBox, "m_radioCurrency" );
+ m_radioCurrency->setText( i18n( "Currency" ) );
+ m_formatBoxLayout->addMultiCellWidget( m_radioCurrency, 0, 0, 1, 2 );
+
+ m_radioDate = new QRadioButton( m_formatBox, "m_radioDate" );
+ m_radioDate->setText( i18n( "Date" ) );
+ m_formatBoxLayout->addWidget( m_radioDate, 1, 2 );
+
+ m_comboLine = new QComboBox( FALSE, page, "m_comboLine" );
+ m_comboLine->insertItem( i18n( "1" ) );
+ m_comboLine->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, m_comboLine->sizePolicy().hasHeightForWidth() ) );
+
+ MyDialogLayout->addWidget( m_comboLine, 1, 3 );
+
+ m_comboQuote = new QComboBox( FALSE, page, "m_comboQuote" );
+ m_comboQuote->insertItem( i18n( "\"" ) );
+ m_comboQuote->insertItem( i18n( "'" ) );
+ m_comboQuote->insertItem( i18n( "None" ) );
+ m_comboQuote->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, m_comboQuote->sizePolicy().hasHeightForWidth() ) );
+
+ MyDialogLayout->addWidget( m_comboQuote, 1, 2 );
+ QSpacerItem* spacer_2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Preferred );
+ MyDialogLayout->addItem( spacer_2, 2, 3 );
+
+ TextLabel3 = new QLabel( page, "TextLabel3" );
+ TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) );
+ TextLabel3->setText( i18n( "Start at line:" ) );
+
+ MyDialogLayout->addWidget( TextLabel3, 0, 3 );
+
+ TextLabel2 = new QLabel( page, "TextLabel2" );
+ TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) );
+ TextLabel2->setText( i18n( "Textquote:" ) );
+
+ MyDialogLayout->addWidget( TextLabel2, 0, 2 );
+
+ if ( m_mode == Clipboard )
+ {
+ setCaption( i18n( "Inserting From Clipboard" ) );
+ QMimeSource * mime = QApplication::clipboard()->data();
+ if ( !mime )
+ {
+ KMessageBox::information( this, i18n("There is no data in the clipboard.") );
+ m_cancelled = true;
+ return;
+ }
+
+ if ( !mime->provides( "text/plain" ) )
+ {
+ KMessageBox::information( this, i18n("There is no usable data in the clipboard.") );
+ m_cancelled = true;
+ return;
+ }
+ m_fileArray = QByteArray(mime->encodedData( "text/plain" ) );
+ }
+ else if ( mode == File )
+ {
+ setCaption( i18n( "Inserting Text File" ) );
+ QString file = KFileDialog::getOpenFileName(":",
+ "text/plain",
+ this);
+ //cancel action !
+ if ( file.isEmpty() )
+ {
+ actionButton( Ok )->setEnabled( false );
+ m_cancelled = true;
+ return;
+ }
+ QFile in(file);
+ if (!in.open(IO_ReadOnly))
+ {
+ KMessageBox::sorry( this, i18n("Cannot open input file.") );
+ in.close();
+ actionButton( Ok )->setEnabled( false );
+ m_cancelled = true;
+ return;
+ }
+ m_fileArray = QByteArray(in.size());
+ in.readBlock(m_fileArray.data(), in.size());
+ in.close();
+ }
+ else
+ {
+ setCaption( i18n( "Text to Columns" ) );
+ m_data = "";
+ Cell * cell;
+ Sheet * sheet = m_pView->activeSheet();
+ int col = m_targetRect.left();
+ for (int i = m_targetRect.top(); i <= m_targetRect.bottom(); ++i)
+ {
+ cell = sheet->cellAt( col, i );
+ if ( !cell->isEmpty() && !cell->isDefault() )
+ {
+ m_data += cell->strOutText();
+ }
+ m_data += "\n";
+ }
+ }
+
+ fillSheet();
+ fillComboBox();
+
+ resize(sizeHint());
+
+ m_sheet->setSelectionMode(QTable::NoSelection);
+
+ connect(m_formatBox, SIGNAL(clicked(int)),
+ this, SLOT(formatClicked(int)));
+ connect(m_delimiterBox, SIGNAL(clicked(int)),
+ this, SLOT(delimiterClicked(int)));
+ connect(m_delimiterEdit, SIGNAL(returnPressed()),
+ this, SLOT(returnPressed()));
+ connect(m_delimiterEdit, SIGNAL(textChanged ( const QString & )),
+ this, SLOT(textChanged ( const QString & ) ));
+ connect(m_comboLine, SIGNAL(activated(const QString&)),
+ this, SLOT(lineSelected(const QString&)));
+ connect(m_comboQuote, SIGNAL(activated(const QString&)),
+ this, SLOT(textquoteSelected(const QString&)));
+ connect(m_sheet, SIGNAL(currentChanged(int, int)),
+ this, SLOT(currentCellChanged(int, int)));
+ connect(m_ignoreDuplicates, SIGNAL(stateChanged(int)),
+ this, SLOT(ignoreDuplicatesChanged(int)));
+}
+
+CSVDialog::~CSVDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+bool CSVDialog::cancelled()
+{
+ return m_cancelled;
+}
+
+void CSVDialog::fillSheet()
+{
+ int row, column;
+ bool lastCharDelimiter = false;
+ bool ignoreDups = m_ignoreDuplicates->isChecked();
+ enum { S_START, S_QUOTED_FIELD, S_MAYBE_END_OF_QUOTED_FIELD, S_END_OF_QUOTED_FIELD,
+ S_MAYBE_NORMAL_FIELD, S_NORMAL_FIELD } state = S_START;
+
+ QChar x;
+ QString field = "";
+
+ for (row = 0; row < m_sheet->numRows(); ++row)
+ for (column = 0; column < m_sheet->numCols(); ++column)
+ m_sheet->clearCell(row, column);
+
+ row = column = 1;
+ if (m_mode != Column)
+ {
+ m_mode = Column;
+ m_data = QString(m_fileArray);
+ m_fileArray.resize(0);
+ }
+
+ QTextStream inputStream(m_data, IO_ReadOnly);
+ inputStream.setEncoding(QTextStream::Locale);
+
+ while (!inputStream.atEnd())
+ {
+ inputStream >> x; // read one char
+
+ if (x == '\r') inputStream >> x; // eat '\r', to handle DOS/LOSEDOWS files correctly
+
+ switch (state)
+ {
+ case S_START :
+ if (x == m_textquote)
+ {
+ state = S_QUOTED_FIELD;
+ }
+ else if (x == m_delimiter)
+ {
+ if ((ignoreDups == false) || (lastCharDelimiter == false))
+ ++column;
+ lastCharDelimiter = true;
+ }
+ else if (x == '\n')
+ {
+ ++row;
+ column = 1;
+ }
+ else
+ {
+ field += x;
+ state = S_MAYBE_NORMAL_FIELD;
+ }
+ break;
+ case S_QUOTED_FIELD :
+ if (x == m_textquote)
+ {
+ state = S_MAYBE_END_OF_QUOTED_FIELD;
+ }
+ else if (x == '\n')
+ {
+ setText(row - m_startline, column, field);
+ field = "";
+ if (x == '\n')
+ {
+ ++row;
+ column = 1;
+ }
+ else
+ {
+ if ((ignoreDups == false) || (lastCharDelimiter == false))
+ ++column;
+ lastCharDelimiter = true;
+ }
+ state = S_START;
+ }
+ else
+ {
+ field += x;
+ }
+ break;
+ case S_MAYBE_END_OF_QUOTED_FIELD :
+ if (x == m_textquote)
+ {
+ field += x;
+ state = S_QUOTED_FIELD;
+ }
+ else if (x == m_delimiter || x == '\n')
+ {
+ setText(row - m_startline, column, field);
+ field = "";
+ if (x == '\n')
+ {
+ ++row;
+ column = 1;
+ }
+ else
+ {
+ if ((ignoreDups == false) || (lastCharDelimiter == false))
+ ++column;
+ lastCharDelimiter = true;
+ }
+ state = S_START;
+ }
+ else
+ {
+ state = S_END_OF_QUOTED_FIELD;
+ }
+ break;
+ case S_END_OF_QUOTED_FIELD :
+ if (x == m_delimiter || x == '\n')
+ {
+ setText(row - m_startline, column, field);
+ field = "";
+ if (x == '\n')
+ {
+ ++row;
+ column = 1;
+ }
+ else
+ {
+ if ((ignoreDups == false) || (lastCharDelimiter == false))
+ ++column;
+ lastCharDelimiter = true;
+ }
+ state = S_START;
+ }
+ else
+ {
+ state = S_END_OF_QUOTED_FIELD;
+ }
+ break;
+ case S_MAYBE_NORMAL_FIELD :
+ if (x == m_textquote)
+ {
+ field = "";
+ state = S_QUOTED_FIELD;
+ break;
+ }
+ case S_NORMAL_FIELD :
+ if (x == m_delimiter || x == '\n')
+ {
+ setText(row - m_startline, column, field);
+ field = "";
+ if (x == '\n')
+ {
+ ++row;
+ column = 1;
+ }
+ else
+ {
+ if ((ignoreDups == false) || (lastCharDelimiter == false))
+ ++column;
+ lastCharDelimiter = true;
+ }
+ state = S_START;
+ }
+ else
+ {
+ field += x;
+ }
+ }
+ if (x != m_delimiter)
+ lastCharDelimiter = false;
+ }
+
+ // file with only one line without '\n'
+ if (field.length() > 0)
+ {
+ setText(row - m_startline, column, field);
+ ++row;
+ field = "";
+ }
+
+ adjustRows( row - m_startline );
+
+ for (column = 0; column < m_sheet->numCols(); ++column)
+ {
+ QString header = m_sheet->horizontalHeader()->label(column);
+ if (header != i18n("Text") && header != i18n("Number") &&
+ header != i18n("Date") && header != i18n("Currency"))
+ m_sheet->horizontalHeader()->setLabel(column, i18n("Text"));
+
+ m_sheet->adjustColumn(column);
+ }
+}
+
+void CSVDialog::fillComboBox()
+{
+ m_comboLine->clear();
+ for (int row = 0; row < m_sheet->numRows(); ++row)
+ m_comboLine->insertItem(QString::number(row + 1), row);
+}
+
+void CSVDialog::setText(int row, int col, const QString& text)
+{
+ if (row < 1) // skipped by the user
+ return;
+
+ if (m_sheet->numRows() < row) {
+ m_sheet->setNumRows(row+5000); /* We add 5000 at a time to limit recalculations */
+ m_adjustRows=1;
+ }
+
+ if (m_sheet->numCols() < col)
+ m_sheet->setNumCols(col);
+
+ m_sheet->setText(row - 1, col - 1, text);
+}
+
+/*
+ * Called after the first fillSheet() when number of rows are unknown.
+ */
+void CSVDialog::adjustRows(int iRows)
+{
+ if (m_adjustRows)
+ {
+ m_sheet->setNumRows( iRows );
+ m_adjustRows=0;
+ }
+}
+
+void CSVDialog::returnPressed()
+{
+ if (m_delimiterBox->id(m_delimiterBox->selected()) != 4)
+ return;
+
+ m_delimiter = m_delimiterEdit->text();
+ fillSheet();
+}
+
+void CSVDialog::textChanged ( const QString & )
+{
+ m_radioOther->setChecked ( true );
+ delimiterClicked(4); // other
+}
+
+void CSVDialog::formatClicked(int id)
+{
+ QString header;
+
+ switch (id)
+ {
+ case 1: // text
+ header = i18n("Text");
+ break;
+ case 0: // number
+ header = i18n("Number");
+ break;
+ case 3: // date
+ header = i18n("Date");
+ break;
+ case 2: // currency
+ header = i18n("Currency");
+ break;
+ }
+
+ m_sheet->horizontalHeader()->setLabel(m_sheet->currentColumn(), header);
+}
+
+void CSVDialog::delimiterClicked(int id)
+{
+ switch (id)
+ {
+ case 0: // comma
+ m_delimiter = ",";
+ break;
+ case 4: // other
+ m_delimiter = m_delimiterEdit->text();
+ break;
+ case 2: // tab
+ m_delimiter = "\t";
+ break;
+ case 3: // space
+ m_delimiter = " ";
+ break;
+ case 1: // semicolon
+ m_delimiter = ";";
+ break;
+ }
+
+ fillSheet();
+}
+
+void CSVDialog::textquoteSelected(const QString& mark)
+{
+ if (mark == i18n("none"))
+ m_textquote = 0;
+ else
+ m_textquote = mark[0];
+
+ fillSheet();
+}
+
+void CSVDialog::lineSelected(const QString& line)
+{
+ m_startline = line.toInt() - 1;
+ fillSheet();
+}
+
+void CSVDialog::currentCellChanged(int, int col)
+{
+ int id;
+ QString header = m_sheet->horizontalHeader()->label(col);
+
+ if (header == i18n("Text"))
+ id = 1;
+ else if (header == i18n("Number"))
+ id = 0;
+ else if (header == i18n("Date"))
+ id = 3;
+ else
+ id = 2;
+
+ m_formatBox->setButton(id);
+}
+
+void CSVDialog::accept()
+{
+ Sheet * sheet = m_pView->activeSheet();
+ QString csv_delimiter = QString::null;
+ Cell * cell;
+
+ int numRows = m_sheet->numRows();
+ int numCols = m_sheet->numCols();
+
+ if (numRows == 0)
+ ++numRows;
+
+ if ( (numCols > m_targetRect.width()) && (m_targetRect.width() > 1) )
+ {
+ numCols = m_targetRect.width();
+ }
+ else
+ m_targetRect.setRight( m_targetRect.left() + numCols );
+
+ if ( (numRows > m_targetRect.height()) && (m_targetRect.height() > 1) )
+ numRows = m_targetRect.height();
+ else
+ m_targetRect.setBottom( m_targetRect.top() + numRows );
+
+ if ( numRows == 1 && numCols == 1)
+ {
+ Doc * doc = m_pView->doc();
+ cell = sheet->nonDefaultCell( m_targetRect.left(), m_targetRect.top() );
+ if ( !doc->undoLocked() )
+ {
+ UndoSetText * undo = new UndoSetText( doc, sheet , cell->text(), m_targetRect.left(),
+ m_targetRect.top(), cell->formatType() );
+ doc->addCommand( undo );
+ }
+ }
+ else
+ {
+ UndoChangeAreaTextCell * undo = new UndoChangeAreaTextCell( m_pView->doc(), sheet , m_targetRect );
+ m_pView->doc()->addCommand( undo );
+ }
+
+ m_pView->doc()->emitBeginOperation();
+
+ int i;
+ int left = m_targetRect.left();
+ int top = m_targetRect.top();
+
+ QMemArray<double> widths( numCols );
+ for ( i = 0; i < numCols; ++i )
+ {
+ ColumnFormat * c = sheet->nonDefaultColumnFormat( left + i );
+ widths[i] = c->dblWidth();
+ }
+
+ for (int row = 0; row < numRows; ++row)
+ {
+ for (int col = 0; col < numCols; ++col)
+ {
+ cell = sheet->nonDefaultCell( left + col, top + row );
+ cell->setCellText( getText( row, col ) );
+
+ QFontMetrics fm = sheet->painter().fontMetrics();
+ double w = fm.width( cell->strOutText() );
+ if ( w == 0.0 )
+ {
+ QFontMetrics fm( cell->format()->textFont( left + col, top + row ) );
+ w = fm.width('x') * (double) getText( row, col ).length();
+ }
+
+ if ( w > widths[col] )
+ widths[col] = w;
+
+ cell->format()->setFormatType(Generic_format);
+ /*
+ Disabling this code for now, everything will use Generic formatting,
+ hoping for the best (Tomas)
+ //### FIXME: long term solution is to allow to select Generic format ("autodetect") in the dialog and make it the default
+
+ switch (getHeader(col))
+ {
+ case TEXT:
+ break;
+ case NUMBER:
+ cell->format()->setFormatType(Number_format);
+ cell->setPrecision(2);
+ break;
+ case DATE:
+ cell->format()->setFormatType(ShortDate_format);
+ break;
+ case CURRENCY:
+ cell->format()->setFormatType(Money_format);
+ break;
+ }
+ */
+ }
+ }
+
+ for ( i = 0; i < numCols; ++i )
+ {
+ ColumnFormat * c = sheet->nonDefaultColumnFormat( left + i );
+ c->setDblWidth( widths[i] );
+ sheet->emit_updateColumn( c, left + i );
+ }
+
+ m_pView->slotUpdateView( sheet );
+ QDialog::accept();
+}
+
+int CSVDialog::getHeader(int col)
+{
+ QString header = m_sheet->horizontalHeader()->label(col);
+
+ if (header == i18n("Text"))
+ return TEXT;
+ else if (header == i18n("Number"))
+ return NUMBER;
+ else if (header == i18n("Currency"))
+ return CURRENCY;
+ else
+ return DATE;
+}
+
+QString CSVDialog::getText(int row, int col)
+{
+ return m_sheet->text(row, col);
+}
+
+void CSVDialog::ignoreDuplicatesChanged(int)
+{
+ fillSheet();
+}
+
+#include "kspread_dlg_csv.moc"
diff --git a/kspread/dialogs/kspread_dlg_csv.h b/kspread/dialogs/kspread_dlg_csv.h
new file mode 100644
index 00000000..ab676966
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_csv.h
@@ -0,0 +1,130 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002-2003 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Laurent Montel <montel@kde.org>
+ (C) 1999 David Faure <faure@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CSVDIALOG_H
+#define CSVDIALOG_H
+
+#include <kdialogbase.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QButtonGroup;
+class QComboBox;
+class QCheckBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+class QTable;
+
+
+namespace KSpread
+{
+class View;
+
+/**
+ * Provides dialog for managing CSV (comma separated value) data.
+ *
+ * Currently CSVDialog is used for converting text into columns,
+ * inserting text file and pasting text from clipboard, where conversion
+ * from CSV (comma separated value) data is is all required.
+ * The different purposed mentioned above is determined
+ * using mode, which can be Column, File, or Clipboard respectively.
+ *
+*/
+class CSVDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+
+ enum Mode { Clipboard, File, Column };
+ enum Header { TEXT, NUMBER, DATE, CURRENCY };
+
+ CSVDialog( View * parent, const char * name, QRect const & rect, Mode mode);
+
+ ~CSVDialog();
+
+ bool cancelled();
+
+ protected:
+ void accept();
+
+
+ private:
+ View* m_pView;
+
+ QGridLayout* MyDialogLayout;
+ QHBoxLayout* Layout1;
+ QGridLayout* m_delimiterBoxLayout;
+ QGridLayout* m_formatBoxLayout;
+ QTable* m_sheet;
+ QButtonGroup* m_delimiterBox;
+ QRadioButton* m_radioComma;
+ QRadioButton* m_radioSemicolon;
+ QRadioButton* m_radioTab;
+ QRadioButton* m_radioSpace;
+ QRadioButton* m_radioOther;
+ QLineEdit* m_delimiterEdit;
+ QButtonGroup* m_formatBox;
+ QRadioButton* m_radioNumber;
+ QRadioButton* m_radioText;
+ QRadioButton* m_radioCurrency;
+ QRadioButton* m_radioDate;
+ QComboBox* m_comboLine;
+ QComboBox* m_comboQuote;
+ QLabel* TextLabel3;
+ QLabel* TextLabel2;
+ QCheckBox * m_ignoreDuplicates;
+
+ void fillSheet();
+ void fillComboBox();
+ void setText(int row, int col, const QString& text);
+ void adjustRows(int iRows);
+ int getHeader(int col);
+ QString getText(int row, int col);
+
+ bool m_cancelled;
+ int m_adjustRows;
+ int m_startline;
+ QChar m_textquote;
+ QString m_delimiter;
+ QString m_data;
+ QByteArray m_fileArray;
+ QRect m_targetRect;
+ Mode m_mode;
+
+ private slots:
+ void returnPressed();
+ void formatClicked(int id);
+ void delimiterClicked(int id);
+ void lineSelected(const QString& line);
+ void textquoteSelected(const QString& mark);
+ void currentCellChanged(int, int col);
+ void textChanged ( const QString & );
+ void ignoreDuplicatesChanged(int);
+};
+
+} // namespace KSpread
+
+#endif // CVSDIALOG_H
diff --git a/kspread/dialogs/kspread_dlg_database.cc b/kspread/dialogs/kspread_dlg_database.cc
new file mode 100644
index 00000000..ca64eb0b
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_database.cc
@@ -0,0 +1,1179 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "kspread_cell.h"
+#include "kspread_dlg_database.h"
+#include "kspread_doc.h"
+#include "kspread_sheet.h"
+#include "kspread_util.h"
+#include "kspread_undo.h"
+#include "kspread_view.h"
+
+#include <kdebug.h>
+#include <klistview.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <knumvalidator.h>
+#include <kpushbutton.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qframe.h>
+#include <qheader.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qsqldatabase.h>
+#include <qsqlerror.h>
+#include <qsqlfield.h>
+#include <qsqlquery.h>
+#include <qsqlrecord.h>
+#include <qtextedit.h>
+#include <qtooltip.h>
+#include <qvariant.h>
+#include <qwhatsthis.h>
+#include <qwidget.h>
+
+using namespace KSpread;
+
+#ifndef QT_NO_SQL
+
+/********************************************************
+ * Database wizard *
+ ********************************************************/
+
+DatabaseDialog::DatabaseDialog( View * parent, QRect const & rect, const char * name, bool modal, WFlags fl )
+ : KWizard( (QWidget *) parent, name, modal, fl ),
+ m_currentPage( eDatabase ),
+ m_pView( parent ),
+ m_targetRect( rect ),
+ m_dbConnection( 0L )
+{
+ if ( !name )
+ setName( "DatabaseDialog" );
+
+ setCaption( i18n( "Insert Data From Database" ) );
+
+ // database page
+
+ m_database = new QWidget( this, "m_database" );
+ m_databaseLayout = new QGridLayout( m_database, 1, 1, -1, -1, "m_databaseLayout");
+
+ QFrame * Frame5 = new QFrame( m_database, "Frame5" );
+ Frame5->setFrameShape( QFrame::MShape );
+ Frame5->setFrameShadow( QFrame::MShadow );
+ QVBoxLayout * Frame5Layout = new QVBoxLayout( Frame5, 11, 6, "Frame5Layout");
+
+
+ QFrame * Frame16 = new QFrame( Frame5, "Frame16" );
+ Frame16->setFrameShape( QFrame::NoFrame );
+ Frame16->setFrameShadow( QFrame::Plain );
+ QGridLayout * Frame16Layout = new QGridLayout( Frame16, 1, 1, 11, 7, "Frame16Layout");
+
+ m_Type = new QLabel( Frame16, "m_Type" );
+ m_Type->setText( i18n( "Type:" ) );
+
+ Frame16Layout->addWidget( m_Type, 0, 0 );
+
+ QLabel * TextLabel4 = new QLabel( Frame16, "TextLabel4" );
+ TextLabel4->setText( i18n( "User name:\n"
+ "(if necessary)" ) );
+ Frame16Layout->addWidget( TextLabel4, 4, 0 );
+
+ QLabel * TextLabel2 = new QLabel( Frame16, "TextLabel2" );
+ TextLabel2->setText( i18n( "Host:" ) );
+ Frame16Layout->addWidget( TextLabel2, 2, 0 );
+
+ m_driver = new QComboBox( FALSE, Frame16, "m_driver" );
+ Frame16Layout->addWidget( m_driver, 0, 1 );
+
+ m_username = new QLineEdit( Frame16, "m_username" );
+ Frame16Layout->addWidget( m_username, 4, 1 );
+
+ m_host = new QLineEdit( Frame16, "m_host" );
+ m_host->setText("localhost");
+ Frame16Layout->addWidget( m_host, 2, 1 );
+
+ QLabel * TextLabel3 = new QLabel( Frame16, "TextLabel3" );
+ TextLabel3->setText( i18n( "Port:\n(if necessary)") );
+ Frame16Layout->addWidget( TextLabel3, 3, 0 );
+
+ m_password = new QLineEdit( Frame16, "m_password" );
+ m_password->setEchoMode( QLineEdit::Password );
+ Frame16Layout->addWidget( m_password, 5, 1 );
+
+ m_port = new QLineEdit( Frame16, "m_port" );
+ m_port->setValidator( new KIntValidator( m_port ) );
+ Frame16Layout->addWidget( m_port, 3, 1 );
+
+ QLabel * dbName = new QLabel( Frame16, "dbName" );
+ dbName->setText( i18n( "Database name: ") );
+ Frame16Layout->addWidget( dbName, 1, 0 );
+
+ m_databaseName = new QLineEdit( Frame16, "m_databaseName" );
+ Frame16Layout->addWidget( m_databaseName, 1, 1 );
+
+ QLabel * TextLabel5 = new QLabel( Frame16, "TextLabel5" );
+ TextLabel5->setText( i18n( "Password:\n"
+ "(if necessary)" ) );
+ Frame16Layout->addWidget( TextLabel5, 5, 0 );
+ Frame5Layout->addWidget( Frame16 );
+
+ m_databaseStatus = new QLabel( Frame5, "m_databaseStatus" );
+ m_databaseStatus->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, 0, 0, m_databaseStatus->sizePolicy().hasHeightForWidth() ) );
+ m_databaseStatus->setMaximumSize( QSize( 32767, 30 ) );
+ m_databaseStatus->setText( " " );
+ Frame5Layout->addWidget( m_databaseStatus );
+
+ m_databaseLayout->addWidget( Frame5, 0, 1 );
+
+ QFrame * Frame17 = new QFrame( m_database, "Frame17" );
+ Frame17->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, Frame17->sizePolicy().hasHeightForWidth() ) );
+ Frame17->setMinimumSize( QSize( 111, 0 ) );
+ Frame17->setFrameShape( QFrame::NoFrame );
+ Frame17->setFrameShadow( QFrame::Plain );
+
+ m_databaseLayout->addWidget( Frame17, 0, 0 );
+ addPage( m_database, i18n( "Database" ) );
+
+ // new page
+
+ m_sheet = new QWidget( this, "m_table" );
+ m_sheetLayout = new QGridLayout( m_sheet, 1, 1, 11, 6, "m_tableLayout");
+
+ QFrame * Frame5_2 = new QFrame( m_sheet, "Frame5_2" );
+ Frame5_2->setFrameShape( QFrame::MShape );
+ Frame5_2->setFrameShadow( QFrame::MShadow );
+ QGridLayout * Frame5_2Layout = new QGridLayout( Frame5_2, 1, 1, 11, 6, "Frame5_2Layout");
+
+ QHBoxLayout * Layout21 = new QHBoxLayout( 0, 0, 6, "Layout21");
+
+ // QLabel * TextLabel12_2 = new QLabel( Frame5_2, "TextLabel12_2" );
+ // TextLabel12_2->setText( i18n( "Database:" ) );
+ // Layout21->addWidget( TextLabel12_2 );
+
+ // m_databaseList = new QComboBox( FALSE, Frame5_2, "m_databaseList" );
+ // Layout21->addWidget( m_databaseList );
+
+ // m_connectButton = new KPushButton( Frame5_2, "m_connectButton" );
+ // m_connectButton->setText( i18n( "&Connect" ) );
+ // Layout21->addWidget( m_connectButton );
+
+ Frame5_2Layout->addLayout( Layout21, 0, 0 );
+
+ m_sheetStatus = new QLabel( Frame5_2, "m_tableStatus" );
+ m_sheetStatus->setText( " " );
+ Frame5_2Layout->addWidget( m_sheetStatus, 3, 0 );
+
+ m_SelectSheetLabel = new QLabel( Frame5_2, "m_SelectSheetLabel" );
+ m_SelectSheetLabel->setText( i18n( "Select tables:" ) );
+ Frame5_2Layout->addWidget( m_SelectSheetLabel, 1, 0 );
+
+ m_sheetView = new KListView( Frame5_2, "m_tableView" );
+ m_sheetView->addColumn( i18n( "Sheet" ) );
+ m_sheetView->setRootIsDecorated( FALSE );
+
+ Frame5_2Layout->addWidget( m_sheetView, 2, 0 );
+
+ m_sheetLayout->addWidget( Frame5_2, 0, 1 );
+
+ QFrame * Frame17_2 = new QFrame( m_sheet, "Frame17_2" );
+ Frame17_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, Frame17_2->sizePolicy().hasHeightForWidth() ) );
+ Frame17_2->setMinimumSize( QSize( 111, 0 ) );
+ Frame17_2->setFrameShape( QFrame::NoFrame );
+ Frame17_2->setFrameShadow( QFrame::Plain );
+
+ m_sheetLayout->addWidget( Frame17_2, 0, 0 );
+ addPage( m_sheet, i18n( "Sheets" ) );
+
+ m_columns = new QWidget( this, "m_columns" );
+ m_columnsLayout = new QGridLayout( m_columns, 1, 1, 11, 6, "m_columnsLayout");
+
+ QFrame * Frame5_2_2 = new QFrame( m_columns, "Frame5_2_2" );
+ Frame5_2_2->setFrameShape( QFrame::MShape );
+ Frame5_2_2->setFrameShadow( QFrame::MShadow );
+ QGridLayout * Frame5_2_2Layout = new QGridLayout( Frame5_2_2, 1, 1, 11, 6, "Frame5_2_2Layout");
+
+ QLabel * TextLabel11_2 = new QLabel( Frame5_2_2, "TextLabel11_2" );
+ TextLabel11_2->setText( i18n( "Select columns:" ) );
+
+ Frame5_2_2Layout->addWidget( TextLabel11_2, 0, 0 );
+
+ m_columnView = new KListView( Frame5_2_2, "m_columnView" );
+ m_columnView->addColumn( i18n( "Column" ) );
+ m_columnView->addColumn( i18n( "Sheet" ) );
+ m_columnView->addColumn( i18n( "Data Type" ) );
+ m_columnView->setRootIsDecorated( FALSE );
+
+ Frame5_2_2Layout->addWidget( m_columnView, 1, 0 );
+
+ m_columnsStatus = new QLabel( Frame5_2_2, "m_columnsStatus" );
+ m_columnsStatus->setText( " " );
+ Frame5_2_2Layout->addWidget( m_columnsStatus, 2, 0 );
+
+ m_columnsLayout->addWidget( Frame5_2_2, 0, 1 );
+
+ QFrame * Frame17_3 = new QFrame( m_columns, "Frame17_3" );
+ Frame17_3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, Frame17_3->sizePolicy().hasHeightForWidth() ) );
+ Frame17_3->setMinimumSize( QSize( 111, 0 ) );
+ Frame17_3->setFrameShape( QFrame::NoFrame );
+ Frame17_3->setFrameShadow( QFrame::Plain );
+
+ m_columnsLayout->addWidget( Frame17_3, 0, 0 );
+ addPage( m_columns, i18n( "Columns" ) );
+
+ // options page
+
+ m_options = new QWidget( this, "m_options" );
+ m_optionsLayout = new QGridLayout( m_options, 1, 1, 11, 6, "m_optionsLayout");
+
+ QFrame * optionsFrame = new QFrame( m_options, "optionsFrame" );
+ optionsFrame->setFrameShape( QFrame::MShape );
+ optionsFrame->setFrameShadow( QFrame::MShadow );
+ QGridLayout * optionsFrameLayout = new QGridLayout( optionsFrame, 1, 1, 11, 6, "optionsFrameLayout");
+
+ m_columns_1 = new QComboBox( false, optionsFrame, "m_columns_1" );
+ optionsFrameLayout->addWidget( m_columns_1, 2, 0 );
+
+ m_operatorValue_2 = new QLineEdit( optionsFrame, "m_operatorValue_2" );
+ optionsFrameLayout->addWidget( m_operatorValue_2, 3, 2 );
+
+ m_andBox = new QRadioButton( optionsFrame, "m_andBox" );
+ m_andBox->setText( i18n( "Match all of the following (AND)" ) );
+ m_andBox->setChecked( true );
+
+ optionsFrameLayout->addMultiCellWidget( m_andBox, 0, 0, 0, 2 );
+
+ m_orBox = new QRadioButton( optionsFrame, "m_orBox" );
+ m_orBox->setText( i18n( "Match any of the following (OR)" ) );
+ optionsFrameLayout->addMultiCellWidget( m_orBox, 1, 1, 0, 2 );
+
+ m_operatorValue_1 = new QLineEdit( optionsFrame, "m_operatorValue" );
+ optionsFrameLayout->addWidget( m_operatorValue_1, 2, 2 );
+
+ m_columns_2 = new QComboBox( FALSE, optionsFrame, "m_columns_2" );
+ optionsFrameLayout->addWidget( m_columns_2, 3, 0 );
+
+ m_operatorValue_3 = new QLineEdit( optionsFrame, "m_operatorValue_3" );
+ optionsFrameLayout->addWidget( m_operatorValue_3, 4, 2 );
+
+ m_operator_1 = new QComboBox( FALSE, optionsFrame, "m_operator_1" );
+ m_operator_1->insertItem( i18n( "equals" ) );
+ m_operator_1->insertItem( i18n( "not equal" ) );
+ m_operator_1->insertItem( i18n( "in" ) );
+ m_operator_1->insertItem( i18n( "not in" ) );
+ m_operator_1->insertItem( i18n( "like" ) );
+ m_operator_1->insertItem( i18n( "greater" ) );
+ m_operator_1->insertItem( i18n( "lesser" ) );
+ m_operator_1->insertItem( i18n( "greater or equal" ) );
+ m_operator_1->insertItem( i18n( "less or equal" ) );
+
+ optionsFrameLayout->addWidget( m_operator_1, 2, 1 );
+
+ m_operator_2 = new QComboBox( FALSE, optionsFrame, "m_operator_2" );
+ m_operator_2->insertItem( i18n( "equals" ) );
+ m_operator_2->insertItem( i18n( "not equal" ) );
+ m_operator_2->insertItem( i18n( "in" ) );
+ m_operator_2->insertItem( i18n( "not in" ) );
+ m_operator_2->insertItem( i18n( "like" ) );
+ m_operator_2->insertItem( i18n( "greater" ) );
+ m_operator_2->insertItem( i18n( "lesser" ) );
+
+ optionsFrameLayout->addWidget( m_operator_2, 3, 1 );
+
+ m_operator_3 = new QComboBox( FALSE, optionsFrame, "m_operator_3" );
+ m_operator_3->insertItem( i18n( "equals" ) );
+ m_operator_3->insertItem( i18n( "not equal" ) );
+ m_operator_3->insertItem( i18n( "in" ) );
+ m_operator_3->insertItem( i18n( "not in" ) );
+ m_operator_3->insertItem( i18n( "like" ) );
+ m_operator_3->insertItem( i18n( "greater" ) );
+ m_operator_3->insertItem( i18n( "lesser" ) );
+
+ optionsFrameLayout->addWidget( m_operator_3, 4, 1 );
+
+ m_columns_3 = new QComboBox( false, optionsFrame, "m_columns_3" );
+
+ optionsFrameLayout->addWidget( m_columns_3, 4, 0 );
+
+ m_distinct = new QCheckBox( optionsFrame, "m_distinct" );
+ m_distinct->setText( i18n( "Distinct" ) );
+
+ optionsFrameLayout->addWidget( m_distinct, 7, 2 );
+
+ QLabel * TextLabel19 = new QLabel( optionsFrame, "TextLabel19" );
+ TextLabel19->setText( i18n( "Sorted by" ) );
+ optionsFrameLayout->addWidget( TextLabel19, 5, 0 );
+
+ m_columnsSort_1 = new QComboBox( false, optionsFrame, "m_columnsSort_1" );
+ optionsFrameLayout->addWidget( m_columnsSort_1, 5, 1 );
+
+ m_sortMode_1 = new QComboBox( false, optionsFrame, "m_sortMode_1" );
+ m_sortMode_1->insertItem( i18n( "Ascending" ) );
+ m_sortMode_1->insertItem( i18n( "Descending" ) );
+ optionsFrameLayout->addWidget( m_sortMode_1, 5, 2 );
+
+ QLabel * TextLabel19_2 = new QLabel( optionsFrame, "TextLabel19_2" );
+ TextLabel19_2->setText( i18n( "Sorted by" ) );
+ optionsFrameLayout->addWidget( TextLabel19_2, 6, 0 );
+
+ m_columnsSort_2 = new QComboBox( false, optionsFrame, "m_columnsSort_2" );
+ optionsFrameLayout->addWidget( m_columnsSort_2, 6, 1 );
+
+ m_sortMode_2 = new QComboBox( false, optionsFrame, "m_sortMode_2" );
+ m_sortMode_2->insertItem( i18n( "Ascending" ) );
+ m_sortMode_2->insertItem( i18n( "Descending" ) );
+
+ optionsFrameLayout->addWidget( m_sortMode_2, 6, 2 );
+ QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ optionsFrameLayout->addItem( spacer, 7, 1 );
+ QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ optionsFrameLayout->addItem( spacer_2, 7, 0 );
+
+ m_optionsLayout->addWidget( optionsFrame, 0, 1 );
+
+ QFrame * Frame17_4 = new QFrame( m_options, "Frame17_4" );
+ Frame17_4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, Frame17_4->sizePolicy().hasHeightForWidth() ) );
+ Frame17_4->setMinimumSize( QSize( 111, 0 ) );
+ Frame17_4->setFrameShape( QFrame::NoFrame );
+ Frame17_4->setFrameShadow( QFrame::Plain );
+
+ m_optionsLayout->addWidget( Frame17_4, 0, 0 );
+ addPage( m_options, i18n( "Query Options" ) );
+
+ // result page
+
+ m_result = new QWidget( this, "m_result" );
+ m_resultLayout = new QGridLayout( m_result, 1, 1, 11, 6, "m_resultLayout");
+
+ QFrame * Frame5_2_2_3 = new QFrame( m_result, "Frame5_2_2_3" );
+ Frame5_2_2_3->setFrameShape( QFrame::MShape );
+ Frame5_2_2_3->setFrameShadow( QFrame::MShadow );
+ QGridLayout * Frame5_2_2_3Layout = new QGridLayout( Frame5_2_2_3, 1, 1, 11, 6, "Frame5_2_2_3Layout");
+
+ QLabel * TextLabel17 = new QLabel( Frame5_2_2_3, "TextLabel17" );
+ TextLabel17->setText( i18n( "SQL query:" ) );
+ Frame5_2_2_3Layout->addWidget( TextLabel17, 0, 0 );
+
+ m_sqlQuery = new QTextEdit( Frame5_2_2_3, "m_sqlQuery" );
+ Frame5_2_2_3Layout->addWidget( m_sqlQuery, 1, 0 );
+
+ QFrame * Frame12 = new QFrame( Frame5_2_2_3, "Frame12" );
+ Frame12->setFrameShape( QFrame::StyledPanel );
+ Frame12->setFrameShadow( QFrame::Raised );
+ QGridLayout * Frame12Layout = new QGridLayout( Frame12, 1, 1, 11, 6, "Frame12Layout");
+
+ m_startingRegion = new QRadioButton( Frame12, "m_startingRegion" );
+ m_startingRegion->setText( i18n( "Insert in region" ) );
+ Frame12Layout->addWidget( m_startingRegion, 0, 0 );
+
+ m_cell = new QLineEdit( Frame12, "m_cell" );
+ Frame12Layout->addWidget( m_cell, 1, 1 );
+
+ m_region = new QLineEdit( Frame12, "m_region" );
+ Frame12Layout->addWidget( m_region, 0, 1 );
+
+ m_startingCell = new QRadioButton( Frame12, "m_startingCell" );
+ m_startingCell->setText( i18n( "Starting in cell" ) );
+ m_startingCell->setChecked( TRUE );
+ Frame12Layout->addWidget( m_startingCell, 1, 0 );
+
+ Frame5_2_2_3Layout->addWidget( Frame12, 2, 0 );
+ m_resultLayout->addWidget( Frame5_2_2_3, 0, 1 );
+
+ QFrame * Frame17_5 = new QFrame( m_result, "Frame17_5" );
+ Frame17_5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, Frame17_5->sizePolicy().hasHeightForWidth() ) );
+ Frame17_5->setMinimumSize( QSize( 111, 0 ) );
+ Frame17_5->setFrameShape( QFrame::NoFrame );
+ Frame17_5->setFrameShadow( QFrame::Plain );
+
+ m_resultLayout->addWidget( Frame17_5, 0, 0 );
+ addPage( m_result, i18n( "Result" ) );
+
+ finishButton()->setEnabled(false);
+
+ // signals and slots connections
+ connect( m_orBox, SIGNAL( clicked() ), this, SLOT( orBox_clicked() ) );
+ connect( m_andBox, SIGNAL( clicked() ), this, SLOT( andBox_clicked() ) );
+ connect( m_startingCell, SIGNAL( clicked() ), this, SLOT( startingCell_clicked() ) );
+ connect( m_startingRegion, SIGNAL( clicked() ), this, SLOT( startingRegion_clicked() ) );
+ connect( m_driver, SIGNAL( activated(int) ), this, SLOT( databaseDriverChanged(int) ) );
+ connect( m_host, SIGNAL( textChanged(const QString &) ), this, SLOT( databaseHostChanged(const QString &) ) );
+ connect( m_databaseName, SIGNAL( textChanged(const QString &) ), this, SLOT( databaseNameChanged(const QString &) ) );
+ connect( m_sheetView, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint &, int ) ),
+ this, SLOT( popupSheetViewMenu(QListViewItem *, const QPoint &, int ) ) );
+ connect( m_sheetView, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( sheetViewClicked( QListViewItem * ) ) );
+
+ QStringList str = QSqlDatabase::drivers();
+ m_driver->insertItem("");
+ m_driver->insertStringList( str );
+
+
+ helpButton()->hide();
+ setNextEnabled(m_database, false);
+ setNextEnabled(m_sheet, false);
+ setNextEnabled(m_columns, false);
+ setNextEnabled(m_options, false);
+ setNextEnabled(m_result, false);
+}
+
+DatabaseDialog::~DatabaseDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+ if ( m_dbConnection )
+ m_dbConnection->close();
+}
+
+void DatabaseDialog::switchPage( int id )
+{
+ if ( id > eResult )
+ --m_currentPage;
+ if ( id < eDatabase )
+ ++m_currentPage;
+
+ switch ( id )
+ {
+ case eDatabase:
+ showPage(m_database);
+ break;
+
+ case eSheets:
+ showPage(m_sheet);
+ break;
+
+ case eColumns:
+ showPage(m_columns);
+ break;
+
+ case eOptions:
+ showPage(m_options);
+ break;
+
+ case eResult:
+ showPage(m_result);
+ break;
+
+ default:
+ break;
+ }
+}
+
+void DatabaseDialog::next()
+{
+ switch ( m_currentPage )
+ {
+ case eDatabase:
+ if (!databaseDoNext())
+ return;
+ break;
+
+ case eSheets:
+ if (!sheetsDoNext())
+ return;
+ break;
+
+ case eColumns:
+ if (!columnsDoNext())
+ return;
+ break;
+
+ case eOptions:
+ if (!optionsDoNext())
+ return;
+ break;
+
+ case eResult:
+ // there is nothing to do here
+ break;
+
+ default:
+ break;
+ }
+
+ ++m_currentPage;
+
+ switchPage( m_currentPage );
+}
+
+void DatabaseDialog::back()
+{
+ --m_currentPage;
+
+ switchPage( m_currentPage );
+}
+
+void DatabaseDialog::accept()
+{
+ Sheet * sheet = m_pView->activeSheet();
+ int top;
+ int left;
+ int width = -1;
+ int height = -1;
+ if ( m_startingRegion->isChecked() )
+ {
+ Range range( m_region->text() );
+ if ( range.isSheetKnown() )
+ {
+ KMessageBox::error( this, i18n("You cannot specify a table here.") );
+ m_region->setFocus();
+ m_region->selectAll();
+ return;
+ }
+
+ range.setSheet(sheet);
+
+ if ( !range.isValid() )
+ {
+ KMessageBox::error( this, i18n("You have to specify a valid region.") );
+ m_region->setFocus();
+ m_region->selectAll();
+ return;
+ }
+
+ top = range.range().top();
+ left = range.range().left();
+ width = range.range().width();
+ height = range.range().height();
+ }
+ else
+ {
+ Point point( m_cell->text() );
+ if ( point.isSheetKnown() )
+ {
+ KMessageBox::error( this, i18n("You cannot specify a table here.") );
+ m_cell->setFocus();
+ m_cell->selectAll();
+ return;
+ }
+ point.setSheet(sheet);
+ // if ( point.pos.x() < 1 || point.pos.y() < 1 )
+ if ( !point.isValid() )
+ {
+ KMessageBox::error( this, i18n("You have to specify a valid cell.") );
+ m_cell->setFocus();
+ m_cell->selectAll();
+ return;
+ }
+ top = point.pos().y();
+ left = point.pos().x();
+ }
+
+ int i;
+ QString queryStr;
+ QString tmp = m_sqlQuery->text();
+ for ( i = 0; i < (int) tmp.length(); ++i )
+ {
+ if ( tmp[i] != '\n' )
+ queryStr += tmp[i];
+ else
+ queryStr += " ";
+ }
+
+ Cell * cell;
+ QSqlQuery query( QString::null, m_dbConnection );
+
+ // Check the whole query for SQL that might modify database.
+ // If there is an update command, then it must be at the start of the string,
+ // or after an open bracket (e.g. nested update) or a space to be valid SQL.
+ // An update command must also be followed by a space, or it would be parsed
+ // as an identifier.
+ // For sanity, also check that there is a SELECT
+ QRegExp couldModifyDB( "(^|[( \\s])(UPDATE|DELETE|INSERT|CREATE) ", false /* cs */ );
+ QRegExp couldQueryDB( "(^|[( \\s])(SELECT) ", false /* cs */ );
+
+ if (couldModifyDB.search( queryStr ) != -1 || couldQueryDB.search ( queryStr ) == -1 )
+ {
+ KMessageBox::error( this, i18n("You are not allowed to change data in the database.") );
+ m_sqlQuery->setFocus();
+ return;
+ }
+
+ if ( !query.exec( queryStr ) )
+ {
+ KMessageBox::error( this, i18n( "Executing query failed." ) );
+ m_sqlQuery->setFocus();
+ return;
+ }
+
+ if ( query.size() == 0 )
+ {
+ KMessageBox::error( this, i18n( "You did not get any results with this query." ) );
+ m_sqlQuery->setFocus();
+ return;
+ }
+
+ int y = 0;
+ int count = m_columns_1->count();
+ if ( width != -1 )
+ {
+ if ( count > width )
+ count = width;
+ }
+
+ if ( height == -1 )
+ {
+ height = 0;
+ if ( query.first() )
+ {
+ if ( query.isValid() )
+ ++height;
+ }
+ while ( query.next() )
+ {
+ if ( query.isValid() )
+ ++height;
+ }
+ }
+
+ if ( !m_pView->doc()->undoLocked() )
+ {
+ QRect r(left, top, count, height);
+ UndoInsertData * undo = new UndoInsertData( m_pView->doc(), sheet, r );
+ m_pView->doc()->addCommand( undo );
+ }
+
+ m_pView->doc()->emitBeginOperation();
+
+ if ( query.first() )
+ {
+ if ( query.isValid() )
+ {
+ for ( i = 0; i < count; ++i )
+ {
+ cell = sheet->nonDefaultCell( left + i, top + y );
+ cell->setCellText( query.value( i ).toString() );
+ }
+ ++y;
+ }
+ }
+
+ if ( y != height )
+ {
+ while ( query.next() )
+ {
+ if ( !query.isValid() )
+ continue;
+
+ for ( i = 0; i < count; ++i )
+ {
+ cell = sheet->nonDefaultCell( left + i, top + y );
+ cell->setCellText( query.value( i ).toString() );
+ }
+ ++y;
+
+ if ( y == height )
+ break;
+ }
+ }
+
+ m_pView->slotUpdateView( sheet );
+ KWizard::accept();
+}
+
+bool DatabaseDialog::databaseDoNext()
+{
+ m_dbConnection = QSqlDatabase::addDatabase( m_driver->currentText() );
+
+ if ( m_dbConnection )
+ {
+ m_dbConnection->setDatabaseName( m_databaseName->text() );
+ m_dbConnection->setHostName( m_host->text() );
+
+ if ( !m_username->text().isEmpty() )
+ m_dbConnection->setUserName( m_username->text() );
+
+ if ( !m_password->text().isEmpty() )
+ m_dbConnection->setPassword( m_password->text() );
+
+ if ( !m_port->text().isEmpty() )
+ {
+ bool ok = false;
+ int port = m_port->text().toInt( &ok );
+ if (!ok)
+ {
+ KMessageBox::error( this, i18n("The port must be a number") );
+ return false;
+ }
+ m_dbConnection->setPort( port );
+ }
+
+ m_databaseStatus->setText( i18n("Connecting to database...") );
+ if ( m_dbConnection->open() )
+ {
+ m_databaseStatus->setText( i18n("Connected. Retrieving table information...") );
+ QStringList sheetList( m_dbConnection->tables() );
+
+ if ( sheetList.isEmpty() )
+ {
+ KMessageBox::error( this, i18n("This database contains no tables") );
+ return false;
+ }
+
+ unsigned int i;
+ m_sheetView->clear();
+
+ for ( i = 0; i < sheetList.size(); ++i )
+ {
+ QCheckListItem * item = new QCheckListItem( m_sheetView, sheetList[i],
+ QCheckListItem::CheckBox );
+ item->setOn(false);
+ m_sheetView->insertItem( item );
+ }
+
+ m_sheetView->setEnabled( true );
+ m_databaseStatus->setText( " " );
+ }
+ else
+ {
+ QSqlError error = m_dbConnection->lastError();
+ QString errorMsg;
+ QString err1 = error.driverText();
+ QString err2 = error.databaseText();
+ if ( !err1.isEmpty() )
+ {
+ errorMsg.append( error.driverText() );
+ errorMsg.append( "\n" );
+ }
+ if ( !err2.isEmpty() && err1 != err2)
+ {
+ errorMsg.append( error.databaseText() );
+ errorMsg.append( "\n" );
+ }
+ m_databaseStatus->setText( " " );
+
+ KMessageBox::error( this, errorMsg );
+ return false;
+ }
+ }
+ else
+ {
+ KMessageBox::error( this, i18n("Driver could not be loaded") );
+ m_databaseStatus->setText( " " );
+ return false;
+ }
+ setNextEnabled(m_sheet, true);
+
+ return true;
+}
+
+bool DatabaseDialog::sheetsDoNext()
+{
+ m_databaseStatus->setText( i18n("Retrieving meta data of tables...") );
+ QStringList sheets;
+
+ for (QListViewItem * item = (QCheckListItem *) m_sheetView->firstChild(); item; item = item->nextSibling())
+ {
+ if (((QCheckListItem * ) item)->isOn())
+ {
+ sheets.append(((QCheckListItem * ) item)->text());
+ }
+ }
+
+ if (sheets.empty())
+ {
+ KMessageBox::error( this, i18n("You have to select at least one table.") );
+ return false;
+ }
+
+ m_columnView->clear();
+ QSqlRecord info;
+ QCheckListItem * item;
+ for (int i = 0; i < (int) sheets.size(); ++i)
+ {
+ info = m_dbConnection->record( sheets[i] );
+ for (int j = 0; j < (int) info.count(); ++j)
+ {
+ QString name = info.fieldName(j);
+ item = new QCheckListItem( m_columnView, name,
+ QCheckListItem::CheckBox );
+ item->setOn(false);
+ m_columnView->insertItem( item );
+ item->setText( 1, sheets[i] );
+ QSqlField * field = info.field(name);
+ item->setText( 2, QVariant::typeToName(field->type()) );
+ }
+ }
+ m_columnView->setSorting(1, true);
+ m_columnView->sort();
+ m_columnView->setSorting( -1 );
+
+ setNextEnabled(m_columns, true);
+
+ return true;
+}
+
+bool DatabaseDialog::columnsDoNext()
+{
+ QStringList columns;
+ for (QListViewItem * item = m_columnView->firstChild(); item; item = item->nextSibling())
+ {
+ if (((QCheckListItem * ) item)->isOn())
+ {
+ columns.append( item->text(1) + "." + ((QCheckListItem * ) item)->text());
+ }
+ }
+
+ if (columns.empty())
+ {
+ KMessageBox::error( this, i18n("You have to select at least one column.") );
+ return false;
+ }
+
+ m_columns_1->clear();
+ m_columns_2->clear();
+ m_columns_3->clear();
+ m_columns_1->insertStringList(columns);
+ m_columns_2->insertStringList(columns);
+ m_columns_3->insertStringList(columns);
+ m_columnsSort_1->clear();
+ m_columnsSort_2->clear();
+ m_columnsSort_1->insertItem( i18n("None") );
+ m_columnsSort_2->insertItem( i18n("None") );
+ m_columnsSort_1->insertStringList(columns);
+ m_columnsSort_2->insertStringList(columns);
+
+ setNextEnabled(m_options, true);
+
+ return true;
+}
+
+
+QString DatabaseDialog::getWhereCondition(QString const & column,
+ QString const & value,
+ int op)
+{
+ QString wherePart;
+
+ switch( op )
+ {
+ case 0:
+ wherePart += column;
+ wherePart += " = ";
+ break;
+ case 1:
+ wherePart += "NOT ";
+ wherePart += column;
+ wherePart += " = ";
+ break;
+ case 2:
+ wherePart += column;
+ wherePart += " IN ";
+ break;
+ case 3:
+ wherePart += "NOT ";
+ wherePart += column;
+ wherePart += " IN ";
+ break;
+ case 4:
+ wherePart += column;
+ wherePart += " LIKE ";
+ break;
+ case 5:
+ wherePart += column;
+ wherePart += " > ";
+ break;
+ case 6:
+ wherePart += column;
+ wherePart += " < ";
+ break;
+ case 7:
+ wherePart += column;
+ wherePart += " >= ";
+ break;
+ case 8:
+ wherePart += column;
+ wherePart += " <= ";
+ break;
+ }
+
+ if ( op != 2 && op != 3 )
+ {
+ QString val;
+ bool ok = false;
+ value.toDouble(&ok);
+
+ if ( !ok )
+ {
+ if (value[0] != '\'')
+ val = "'";
+
+ val += value;
+
+ if (value[value.length() - 1] != '\'')
+ val += "'";
+ }
+ else
+ val = value;
+
+ wherePart += val;
+ }
+ else // "in" & "not in"
+ {
+ QString val;
+ if (value[0] != '(')
+ val = "(";
+ val += value;
+ if ( value[value.length() - 1] != ')' )
+ val += ")";
+ wherePart += val;
+ }
+
+ return wherePart;
+}
+
+QString DatabaseDialog::exchangeWildcards(QString const & value)
+{
+ QString str(value);
+ int p = str.find('*');
+ while ( p > -1 )
+ {
+ str = str.replace( p, 1, "%" );
+ p = str.find('*');
+ }
+
+ p = str.find('?');
+ while ( p > -1 )
+ {
+ str = str.replace( p, 1, "_" );
+ p = str.find('?');
+ }
+ return str;
+}
+
+bool DatabaseDialog::optionsDoNext()
+{
+ if ( m_operator_1->currentItem() == 4 )
+ {
+ if ( ( m_operatorValue_1->text().find('*') != -1 )
+ || ( m_operatorValue_1->text().find('?') != -1 ) )
+ {
+ // xgettext: no-c-format
+ int res = KMessageBox::warningYesNo( this, i18n("'*' or '?' are not valid wildcards in SQL. "
+ "The proper replacements are '%' or '_'. Do you want to replace them?") );
+
+ if ( res == KMessageBox::Yes )
+ m_operatorValue_1->setText(exchangeWildcards(m_operatorValue_1->text()));
+ }
+ }
+
+ if ( m_operator_2->currentItem() == 4 )
+ {
+ if ( ( m_operatorValue_2->text().find('*') != -1 )
+ || ( m_operatorValue_2->text().find('?') != -1 ) )
+ {
+ // xgettext: no-c-format
+ int res = KMessageBox::warningYesNo( this, i18n("'*' or '?' are not valid wildcards in SQL. "
+ "The proper replacements are '%' or '_'. Do you want to replace them?") );
+
+ if ( res == KMessageBox::Yes )
+ m_operatorValue_2->setText(exchangeWildcards(m_operatorValue_2->text()));
+ }
+ }
+
+ if ( m_operator_3->currentItem() == 4 )
+ {
+ if ( ( m_operatorValue_3->text().find('*') != -1 )
+ || ( m_operatorValue_3->text().find('?') != -1 ) )
+ {
+ // xgettext: no-c-format
+ int res = KMessageBox::warningYesNo( this, i18n("'*' or '?' are not valid wildcards in SQL. "
+ "The proper replacements are '%' or '_'. Do you want to replace them?") );
+
+ if ( res == KMessageBox::Yes )
+ m_operatorValue_3->setText(exchangeWildcards(m_operatorValue_3->text()));
+ }
+ }
+
+ QString query("SELECT ");
+
+ if (m_distinct->isChecked())
+ query += "DISTINCT ";
+
+ int i;
+ int l = m_columns_1->count() - 1;
+ for ( i = 0; i < l; ++i )
+ {
+ query += m_columns_1->text( i );
+ query += ", ";
+ }
+ query += m_columns_1->text( l );
+
+ query += "\nFROM ";
+
+ QListViewItem * item = (QCheckListItem *) m_sheetView->firstChild();
+ bool b = false;
+ while ( item )
+ {
+ if (((QCheckListItem * ) item)->isOn())
+ {
+ if ( b )
+ query += ", ";
+ b = true;
+ query += ((QCheckListItem * ) item)->text();
+ }
+ item = item->nextSibling();
+ }
+
+ if ( ( !m_operatorValue_1->text().isEmpty() )
+ || ( !m_operatorValue_2->text().isEmpty() )
+ || ( !m_operatorValue_3->text().isEmpty() ) )
+ query += "\nWHERE ";
+
+ bool added = false;
+ if ( !m_operatorValue_1->text().isEmpty() )
+ {
+ query += getWhereCondition(m_columns_1->currentText(),
+ m_operatorValue_1->text(),
+ m_operator_1->currentItem());
+ added = true;
+ }
+
+ if ( !m_operatorValue_2->text().isEmpty() )
+ {
+ if (added)
+ query += ( m_andBox->isChecked() ? " AND " : " OR " );
+
+ query += getWhereCondition(m_columns_2->currentText(),
+ m_operatorValue_2->text(),
+ m_operator_2->currentItem());
+ added = true;
+ }
+
+ if ( !m_operatorValue_3->text().isEmpty() )
+ {
+ if (added)
+ query += ( m_andBox->isChecked() ? " AND " : " OR " );
+
+ query += getWhereCondition(m_columns_3->currentText(),
+ m_operatorValue_3->text(),
+ m_operator_3->currentItem());
+ }
+
+ if ( (m_columnsSort_1->currentItem() != 0)
+ || (m_columnsSort_2->currentItem() != 0) )
+ {
+ query += "\nORDER BY ";
+ bool added = false;
+ if ( m_columnsSort_1->currentItem() != 0 )
+ {
+ added = true;
+ query += m_columnsSort_1->currentText();
+ if ( m_sortMode_1->currentItem() == 1 )
+ query += " DESC ";
+ }
+
+ if ( m_columnsSort_2->currentItem() != 0 )
+ {
+ if ( added )
+ query += ", ";
+
+ query += m_columnsSort_2->currentText();
+ if ( m_sortMode_2->currentItem() == 1 )
+ query += " DESC ";
+ }
+ }
+
+ m_sqlQuery->setText(query);
+ m_cell->setText(Cell::name( m_targetRect.left(), m_targetRect.top() ) );
+ m_region->setText(util_rangeName( m_targetRect ) );
+
+ setFinishEnabled( m_result, true );
+
+ return true;
+}
+
+void DatabaseDialog::orBox_clicked()
+{
+ m_andBox->setChecked( false );
+ m_orBox->setChecked( true );
+}
+
+void DatabaseDialog::andBox_clicked()
+{
+ m_andBox->setChecked( true );
+ m_orBox->setChecked( false );
+}
+
+void DatabaseDialog::startingCell_clicked()
+{
+ m_startingCell->setChecked( true );
+ m_startingRegion->setChecked( false );
+}
+
+void DatabaseDialog::startingRegion_clicked()
+{
+ m_startingCell->setChecked( false );
+ m_startingRegion->setChecked( true );
+}
+
+void DatabaseDialog::connectButton_clicked()
+{
+ qWarning( "DatabaseDialog::connectButton_clicked(): Not implemented yet!" );
+}
+
+void DatabaseDialog::databaseNameChanged(const QString & s)
+{
+ if ( !m_driver->currentText().isEmpty() && !s.isEmpty()
+ && !m_host->text().isEmpty() )
+ setNextEnabled(m_database, true);
+ else
+ setNextEnabled(m_database, false);
+}
+
+void DatabaseDialog::databaseHostChanged(const QString & s)
+{
+ if ( !m_driver->currentText().isEmpty() && !s.isEmpty()
+ && !m_databaseName->text().isEmpty() )
+ setNextEnabled(m_database, true);
+ else
+ setNextEnabled(m_database, false);
+}
+
+void DatabaseDialog::databaseDriverChanged(int index)
+{
+ if ( index > 0 && !m_host->text().isEmpty()
+ && !m_databaseName->text().isEmpty() )
+ setNextEnabled(m_database, true);
+ else
+ setNextEnabled(m_database, false);
+}
+
+void DatabaseDialog::popupSheetViewMenu( QListViewItem *, const QPoint &, int )
+{
+ // TODO: popup menu with "Select All", "Inverse selection", "remove selection"
+}
+
+void DatabaseDialog::sheetViewClicked( QListViewItem * )
+{
+// if ( item )
+// {
+// QCheckListItem * i = (QCheckListItem *) item;
+// i->setOn( !i->isOn() );
+// }
+// kdDebug() << "clicked" << endl;
+}
+
+
+#include "kspread_dlg_database.moc"
+
+#endif // QT_NO_SQL
diff --git a/kspread/dialogs/kspread_dlg_database.h b/kspread/dialogs/kspread_dlg_database.h
new file mode 100644
index 00000000..ae958d40
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_database.h
@@ -0,0 +1,143 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_database__
+#define __kspread_dlg_database__
+
+#include <qdialog.h>
+#include <qrect.h>
+
+#include <kwizard.h>
+
+class QCheckBox;
+class QComboBox;
+class QFrame;
+class QGridLayout;
+class QLabel;
+class QLineEdit;
+class QListViewItem;
+class QHBoxLayout;
+class QRadioButton;
+class QSqlDatabase;
+class QTextEdit;
+class QVBoxLayout;
+class QWidget;
+
+class KListView;
+class KPushButton;
+namespace KSpread
+{
+class View;
+
+class DatabaseDialog : public KWizard
+{
+ Q_OBJECT
+
+ public:
+ enum PageId { eDatabase = 0, eSheets = 1, eColumns = 2, eOptions = 3, eResult = 4 };
+
+ DatabaseDialog( View * parent, QRect const & rect, const char * name = 0, bool modal = FALSE, WFlags fl = 0 );
+ virtual ~DatabaseDialog();
+
+ private slots:
+ void orBox_clicked();
+ void andBox_clicked();
+ void startingCell_clicked();
+ void startingRegion_clicked();
+ void connectButton_clicked();
+ void databaseNameChanged( const QString & s );
+ void databaseHostChanged( const QString & s );
+ void databaseDriverChanged( int );
+ void popupSheetViewMenu( QListViewItem *, const QPoint &, int );
+ void sheetViewClicked( QListViewItem * );
+ void accept();
+
+ protected:
+ void next();
+ void back();
+
+ QGridLayout * m_databaseLayout;
+ QGridLayout * m_sheetLayout;
+ QGridLayout * m_columnsLayout;
+ QGridLayout * m_optionsLayout;
+ QGridLayout * m_resultLayout;
+
+ private:
+ int m_currentPage;
+ View * m_pView;
+ QRect m_targetRect;
+ QSqlDatabase * m_dbConnection;
+
+ QWidget * m_database;
+ QLabel * m_databaseStatus;
+ QLineEdit * m_username;
+ QLineEdit * m_port;
+ QLineEdit * m_databaseName;
+ QComboBox * m_driver;
+ QLineEdit * m_password;
+ QLineEdit * m_host;
+ QLabel * m_Type;
+ QWidget * m_sheet;
+ QComboBox * m_databaseList;
+ KPushButton * m_connectButton;
+ QLabel * m_sheetStatus;
+ QLabel * m_SelectSheetLabel;
+ KListView * m_sheetView;
+ QWidget * m_columns;
+ KListView * m_columnView;
+ QLabel * m_columnsStatus;
+ QWidget * m_options;
+ QComboBox * m_columns_1;
+ QComboBox * m_columns_2;
+ QComboBox * m_columns_3;
+ QComboBox * m_operator_1;
+ QComboBox * m_operator_2;
+ QComboBox * m_operator_3;
+ QLineEdit * m_operatorValue_1;
+ QLineEdit * m_operatorValue_2;
+ QLineEdit * m_operatorValue_3;
+ QRadioButton * m_andBox;
+ QRadioButton * m_orBox;
+ QComboBox * m_columnsSort_1;
+ QComboBox * m_columnsSort_2;
+ QComboBox * m_sortMode_1;
+ QComboBox * m_sortMode_2;
+ QCheckBox * m_distinct;
+ QWidget * m_result;
+ QTextEdit * m_sqlQuery;
+ QRadioButton * m_startingRegion;
+ QLineEdit * m_cell;
+ QLineEdit * m_region;
+ QRadioButton * m_startingCell;
+
+ void switchPage( int id );
+ bool databaseDoNext();
+ bool sheetsDoNext();
+ bool columnsDoNext();
+ bool optionsDoNext();
+
+ QString exchangeWildcards(QString const & value);
+ QString getWhereCondition( QString const &, QString const &, int );
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_find.cc b/kspread/dialogs/kspread_dlg_find.cc
new file mode 100644
index 00000000..397b31d8
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_find.cc
@@ -0,0 +1,167 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999-2005 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+
+#include "kspread_dlg_find.h"
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <klocale.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qcombobox.h>
+
+using namespace KSpread;
+
+FindOption::FindOption( QWidget *parent)
+{
+ QVBoxLayout *layout = new QVBoxLayout(parent);
+ m_moreOptions = new QPushButton( i18n( "More Options" ), parent );
+ layout->addWidget( m_moreOptions );
+
+ connect( m_moreOptions, SIGNAL( clicked () ), this, SLOT( slotMoreOptions() ) );
+
+ m_findExtension = new QWidget( parent );
+ layout->addWidget( m_findExtension );
+ QVBoxLayout *layout1 = new QVBoxLayout( m_findExtension );
+ m_searchInAllSheet = new QCheckBox( i18n( "Search entire sheet" ),m_findExtension );
+ layout1->addWidget( m_searchInAllSheet );
+
+ QHBoxLayout *comboLayout = new QHBoxLayout( m_findExtension );
+ QLabel *label = new QLabel( i18n( "Search in:" ), m_findExtension );
+ comboLayout->addWidget( label );
+
+ m_searchIn = new QComboBox( m_findExtension );
+ comboLayout->addWidget( m_searchIn );
+ layout1->addLayout( comboLayout );
+
+ QStringList lst;
+ lst << i18n( "Cell Values" );
+ lst << i18n( "Comments" );
+ m_searchIn->insertStringList( lst );
+
+ comboLayout = new QHBoxLayout( m_findExtension );
+ label = new QLabel( i18n( "Search direction:" ), m_findExtension );
+ comboLayout->addWidget( label );
+
+ m_searchDirection = new QComboBox( m_findExtension );
+ comboLayout->addWidget( m_searchDirection );
+ layout1->addLayout( comboLayout );
+
+ lst.clear();
+ lst << i18n( "Across then Down" );
+ lst << i18n( "Down then Across" );
+ m_searchDirection->insertStringList( lst );
+
+ m_findExtension->hide();
+ emit adjustSize();
+}
+
+FindOption::searchTypeValue FindOption::searchType() const
+{
+ int pos = m_searchIn->currentItem();
+ if ( pos == 0 )
+ return Value;
+ else if ( pos == 1 )
+ return Note;
+ else
+ return Value;
+}
+
+FindOption::searchDirectionValue FindOption::searchDirection() const
+{
+ int pos = m_searchDirection->currentItem();
+ if ( pos == 0 )
+ return Row;
+ else if ( pos == 1 )
+ return Column;
+ else
+ return Row;
+}
+
+
+void FindOption::slotMoreOptions()
+{
+ if ( m_findExtension->isHidden() )
+ {
+ m_findExtension->show();
+ m_moreOptions->setText( i18n( "Fewer Options" ));
+ }
+ else
+ {
+ m_findExtension->hide();
+ m_moreOptions->setText( i18n( "More Options" ));
+ }
+ emit adjustSize();
+}
+
+bool FindOption::searchInAllSheet() const
+{
+ return m_searchInAllSheet->isChecked();
+}
+
+FindDlg::FindDlg(QWidget *parent, const char *name, long options, const QStringList &findStrings, bool hasSelection )
+ : KFindDialog(parent,name,options,findStrings,hasSelection )
+{
+ m_findOptions = new FindOption( findExtension() );
+ connect( m_findOptions, SIGNAL( adjustSize() ), SLOT( slotAjustSize() ) );
+ setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
+}
+
+FindDlg::~FindDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void FindDlg::slotAjustSize()
+{
+ adjustSize();
+}
+
+bool FindDlg::searchInAllSheet() const
+{
+ return m_findOptions->searchInAllSheet();
+}
+
+
+SearchDlg::SearchDlg(QWidget *parent, const char *name, long options, const QStringList &findStrings, const QStringList &replaceStrings, bool hasSelection )
+ : KReplaceDialog(parent,name,options,findStrings,replaceStrings,hasSelection )
+{
+ m_findOptions = new FindOption( findExtension() );
+ connect( m_findOptions, SIGNAL( adjustSize() ), SLOT( slotAjustSize() ) );
+ setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
+}
+
+SearchDlg::~SearchDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void SearchDlg::slotAjustSize()
+{
+ adjustSize();
+ setFixedSize(size());
+}
+
+bool SearchDlg::searchInAllSheet() const
+{
+ return m_findOptions->searchInAllSheet();
+}
+
+
+#include "kspread_dlg_find.moc"
diff --git a/kspread/dialogs/kspread_dlg_find.h b/kspread/dialogs/kspread_dlg_find.h
new file mode 100644
index 00000000..ecf5bf57
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_find.h
@@ -0,0 +1,97 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999-2005 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_find__
+#define __kspread_dlg_find__
+
+
+#include <kfinddialog.h>
+#include <qstringlist.h>
+#include <kreplacedialog.h>
+
+class QCheckBox;
+class QPushButton;
+class QComboBox;
+
+namespace KSpread
+{
+
+class FindOption : public QObject
+{
+ Q_OBJECT
+ public:
+ FindOption( QWidget *parent);
+ bool searchInAllSheet() const;
+
+ enum searchTypeValue { Value, Note};
+ enum searchDirectionValue { Row, Column};
+
+ searchTypeValue searchType() const;
+ searchDirectionValue searchDirection() const;
+
+private slots:
+ void slotMoreOptions();
+
+signals:
+ void adjustSize();
+
+private:
+ QPushButton *m_moreOptions;
+ QCheckBox *m_searchInAllSheet;
+ QWidget *m_findExtension;
+ QComboBox *m_searchIn;
+ QComboBox *m_searchDirection;
+};
+
+class FindDlg : public KFindDialog
+{
+ Q_OBJECT
+
+ public:
+ FindDlg( QWidget *parent = 0, const char *name = 0, long options = 0, const QStringList &findStrings = QStringList(), bool hasSelection = false );
+ ~FindDlg();
+ bool searchInAllSheet() const;
+ FindOption::searchTypeValue searchType() const { return m_findOptions->searchType(); }
+ FindOption::searchDirectionValue searchDirection() const { return m_findOptions->searchDirection(); }
+
+ private slots:
+ void slotAjustSize();
+ private:
+ FindOption *m_findOptions;
+};
+
+class SearchDlg : public KReplaceDialog
+{
+ Q_OBJECT
+
+ public:
+ SearchDlg( QWidget *parent = 0, const char *name = 0, long options = 0, const QStringList &findStrings = QStringList(), const QStringList &replaceStrings = QStringList(), bool hasSelection = false );
+ ~SearchDlg();
+ bool searchInAllSheet() const;
+ FindOption::searchTypeValue searchType() const { return m_findOptions->searchType(); }
+
+ private slots:
+ void slotAjustSize();
+ private:
+ FindOption *m_findOptions;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_format.cc b/kspread/dialogs/kspread_dlg_format.cc
new file mode 100644
index 00000000..98c6d02e
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_format.cc
@@ -0,0 +1,352 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2000-2002 Laurent Montel <montel@kde.org>
+ (C) 2000 Werner Trobin <trobin@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qcombobox.h>
+#include <qfile.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+
+#include <kbuttonbox.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+#include <ksimpleconfig.h>
+
+#include "kspread_dlg_format.h"
+#include "kspread_doc.h"
+#include "kspread_locale.h"
+#include "kspread_sheet.h"
+#include "kspread_style.h"
+#include "kspread_style_manager.h"
+#include "kspread_undo.h"
+#include "kspread_view.h"
+#include "selection.h"
+
+
+using namespace KSpread;
+
+FormatDialog::FormatDialog( View* view, const char* name )
+ : KDialogBase( view, name, TRUE,i18n("Sheet Style"),Ok|Cancel )
+{
+ for( int i = 0; i < 16; ++i )
+ m_cells[ i ] = 0;
+
+ m_view = view;
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+ QVBoxLayout *vbox = new QVBoxLayout( page, 0, spacingHint() );
+
+ QLabel *toplabel = new QLabel( i18n("Select the sheet style to apply:"), page );
+ m_combo = new QComboBox( page );
+ m_label = new QLabel( page );
+
+ vbox->addWidget( toplabel );
+ vbox->addWidget( m_combo );
+ vbox->addWidget( m_label );
+
+
+ QStringList lst = Factory::global()->dirs()->findAllResources( "sheet-styles", "*.ksts", TRUE );
+
+ QStringList::Iterator it = lst.begin();
+ for( ; it != lst.end(); ++it )
+ {
+ KSimpleConfig cfg( *it, TRUE );
+ cfg.setGroup( "Sheet-Style" );
+
+ Entry e;
+ e.config = *it;
+ e.xml = cfg.readEntry( "XML" );
+ e.image = cfg.readEntry( "Image" );
+ e.name = cfg.readEntry( "Name" );
+
+ m_entries.append( e );
+
+ m_combo->insertItem( e.name );
+ }
+
+ slotActivated( 0 );
+
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+ connect( m_combo, SIGNAL( activated( int ) ), this, SLOT( slotActivated( int ) ) );
+}
+
+FormatDialog::~FormatDialog()
+{
+ for( int i = 0; i < 16; ++i )
+ delete m_cells[ i ];
+}
+
+void FormatDialog::slotActivated( int index )
+{
+ enableButtonOK(true);
+
+ QString img = Factory::global()->dirs()->findResource( "sheet-styles", m_entries[ index ].image );
+ if ( img.isEmpty() )
+ {
+ QString str( i18n( "Could not find image %1." ) );
+ str = str.arg( m_entries[ index ].image );
+ KMessageBox::error( this, str );
+
+ enableButtonOK(false);
+
+ return;
+ }
+
+ QPixmap pix( img );
+ if ( pix.isNull() )
+ {
+ QString str( i18n( "Could not load image %1." ) );
+ str = str.arg( img );
+ KMessageBox::error( this,str );
+
+ enableButtonOK(false);
+
+ return;
+ }
+
+ m_label->setPixmap( pix );
+}
+
+void FormatDialog::slotOk()
+{
+
+ m_view->doc()->emitBeginOperation( false );
+
+ QString xml = Factory::global()->dirs()->findResource( "sheet-styles", m_entries[ m_combo->currentItem() ].xml );
+ if ( xml.isEmpty() )
+ {
+ QString str( i18n( "Could not find sheet-style XML file '%1'." ) );
+ str = str.arg( m_entries[ m_combo->currentItem() ].xml );
+ KMessageBox::error( this, str );
+ return;
+ }
+
+ QFile file( xml );
+ file.open( IO_ReadOnly );
+ QDomDocument doc;
+ doc.setContent( &file );
+ file.close();
+
+ if ( !parseXML( doc ) )
+ {
+ QString str( i18n( "Parsing error in sheet-style XML file %1." ) );
+ str = str.arg( m_entries[ m_combo->currentItem() ].xml );
+ KMessageBox::error( this, str );
+ return;
+ }
+
+ QRect r = m_view->selectionInfo()->selection();
+
+ if ( !m_view->doc()->undoLocked() )
+ {
+ QString title=i18n("Change Format");
+ UndoCellFormat *undo = new UndoCellFormat( m_view->doc(), m_view->activeSheet(), r, title);
+ m_view->doc()->addCommand( undo );
+ }
+ //
+ // Set colors, borders etc.
+ //
+
+ // Top left corner
+ Cell* cell = m_view->activeSheet()->nonDefaultCell( r.left(), r.top() );
+ cell->format()->copy( *m_cells[0] );
+
+ // Top column
+ int x, y;
+ for( x = r.left() + 1; x <= r.right(); ++x )
+ {
+ int pos = 1 + ( ( x - r.left() - 1 ) % 2 );
+ Cell* cell = m_view->activeSheet()->nonDefaultCell( x, r.top() );
+ if(!cell->isPartOfMerged())
+ {
+ cell->format()->copy( *m_cells[ pos ] );
+
+ Format* c;
+ if ( x == r.right() )
+ c = m_cells[2];
+ else
+ c = m_cells[1];
+
+ if ( c )
+ cell->setTopBorderPen( c->topBorderPen( 0, 0 ) );
+
+ if ( x == r.left() + 1 )
+ c = m_cells[1];
+ else
+ c = m_cells[2];
+
+ if ( c )
+ cell->setLeftBorderPen( c->leftBorderPen( 0, 0 ) );
+ }
+ }
+
+ cell = m_view->activeSheet()->nonDefaultCell( r.right(), r.top() );
+ if ( m_cells[3] )
+ cell->setRightBorderPen( m_cells[3]->leftBorderPen( 0, 0 ) );
+
+ // Left row
+ for( y = r.top() + 1; y <= r.bottom(); ++y )
+ {
+ int pos = 4 + ( ( y - r.top() - 1 ) % 2 ) * 4;
+ Cell* cell = m_view->activeSheet()->nonDefaultCell( r.left(), y );
+ if(!cell->isPartOfMerged())
+ {
+ cell->format()->copy( *m_cells[ pos ] );
+
+ Format* c;
+ if ( y == r.bottom() )
+ c = m_cells[8];
+ else
+ c = m_cells[4];
+
+ if ( c )
+ cell->setLeftBorderPen( c->leftBorderPen( 0, 0 ) );
+
+ if ( y == r.top() + 1 )
+ c = m_cells[4];
+ else
+ c = m_cells[8];
+
+ if ( c )
+ cell->setTopBorderPen( c->topBorderPen( 0, 0 ) );
+ }
+ }
+
+ // Body
+ for( x = r.left() + 1; x <= r.right(); ++x )
+ for( y = r.top() + 1; y <= r.bottom(); ++y )
+ {
+ int pos = 5 + ( ( y - r.top() - 1 ) % 2 ) * 4 + ( ( x - r.left() - 1 ) % 2 );
+ Cell* cell = m_view->activeSheet()->nonDefaultCell( x, y );
+ if(!cell->isPartOfMerged())
+ {
+ cell->format()->copy( *m_cells[ pos ] );
+
+ Format* c;
+ if ( x == r.left() + 1 )
+ c = m_cells[ 5 + ( ( y - r.top() - 1 ) % 2 ) * 4 ];
+ else
+ c = m_cells[ 6 + ( ( y - r.top() - 1 ) % 2 ) * 4 ];
+
+ if ( c )
+ cell->setLeftBorderPen( c->leftBorderPen( 0, 0 ) );
+
+ if ( y == r.top() + 1 )
+ c = m_cells[ 5 + ( ( x - r.left() - 1 ) % 2 ) ];
+ else
+ c = m_cells[ 9 + ( ( x - r.left() - 1 ) % 2 ) ];
+
+ if ( c )
+ cell->setTopBorderPen( c->topBorderPen( 0, 0 ) );
+ }
+ }
+
+ // Outer right border
+ for( y = r.top(); y <= r.bottom(); ++y )
+ {
+ Cell* cell = m_view->activeSheet()->nonDefaultCell( r.right(), y );
+ if(!cell->isPartOfMerged())
+ {
+ if ( y == r.top() )
+ {
+ if ( m_cells[3] )
+ cell->setRightBorderPen( m_cells[3]->leftBorderPen( 0, 0 ) );
+ }
+ else if ( y == r.right() )
+ {
+ if ( m_cells[11] )
+ cell->setRightBorderPen( m_cells[11]->leftBorderPen( 0, 0 ) );
+ }
+ else
+ {
+ if ( m_cells[7] )
+ cell->setRightBorderPen( m_cells[7]->leftBorderPen( 0, 0 ) );
+ }
+ }
+ }
+
+ // Outer bottom border
+ for( x = r.left(); x <= r.right(); ++x )
+ {
+ Cell* cell = m_view->activeSheet()->nonDefaultCell( x, r.bottom() );
+ if(!cell->isPartOfMerged())
+ {
+ if ( x == r.left() )
+ {
+ if ( m_cells[12] )
+ cell->setBottomBorderPen( m_cells[12]->topBorderPen( 0, 0 ) );
+ }
+ else if ( x == r.right() )
+ {
+ if ( m_cells[14] )
+ cell->setBottomBorderPen( m_cells[14]->topBorderPen( 0, 0 ) );
+ }
+ else
+ {
+ if ( m_cells[13] )
+ cell->setBottomBorderPen( m_cells[13]->topBorderPen( 0, 0 ) );
+ }
+ }
+ }
+
+ m_view->selectionInfo()->initialize(r);//, m_view->activeSheet() );
+ m_view->doc()->setModified( true );
+ m_view->slotUpdateView( m_view->activeSheet() );
+ accept();
+}
+
+bool FormatDialog::parseXML( const QDomDocument& doc )
+{
+ for( int i = 0; i < 16; ++i )
+ {
+ delete m_cells[ i ];
+ m_cells[ i ] = 0;
+ }
+
+ QDomElement e = doc.documentElement().firstChild().toElement();
+ for( ; !e.isNull(); e = e.nextSibling().toElement() )
+ {
+ if ( e.tagName() == "cell" )
+ {
+ Sheet* sheet = m_view->activeSheet();
+ Format* cell = new Format( sheet, sheet->doc()->styleManager()->defaultStyle() );
+
+ if ( !cell->load( e.namedItem("format").toElement(), Paste::Normal ) )
+ return false;
+
+ int row = e.attribute("row").toInt();
+ int column = e.attribute("column").toInt();
+ int i = (row-1)*4 + (column-1);
+ if ( i < 0 || i >= 16 )
+ return false;
+
+ m_cells[ i ] = cell;
+ }
+ }
+
+ return TRUE;
+}
+
+#include "kspread_dlg_format.moc"
diff --git a/kspread/dialogs/kspread_dlg_format.h b/kspread/dialogs/kspread_dlg_format.h
new file mode 100644
index 00000000..f7c0d23b
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_format.h
@@ -0,0 +1,81 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2000-2002 Laurent Montel <montel@kde.org>
+ (C) 2000 Werner Trobin <trobin@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KSPREAD_DLG_FORMAT
+#define KSPREAD_DLG_FORMAT
+
+#include <kdialogbase.h>
+#include <qstring.h>
+#include <qvaluelist.h>
+#include <qcolor.h>
+#include <qpen.h>
+#include <qfont.h>
+
+class QComboBox;
+class QLabel;
+class QDomDocument;
+
+namespace KSpread
+{
+class Format;
+class Sheet;
+class View;
+
+/**
+ * Dialog for the "AutoFormat..." action
+ */
+class FormatDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ FormatDialog( View* view, const char* name = 0 );
+ ~FormatDialog();
+
+private slots:
+ void slotActivated( int index );
+ void slotOk();
+
+private:
+ bool parseXML( const QDomDocument& doc );
+
+ QComboBox* m_combo;
+ QLabel* m_label;
+ View* m_view;
+
+ struct Entry
+ {
+ QString xml;
+ QString image;
+ QString config;
+ QString name;
+ };
+ QValueList<Entry> m_entries;
+
+ Format* m_cells[ 16 ];
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_formula.cc b/kspread/dialogs/kspread_dlg_formula.cc
new file mode 100644
index 00000000..54100b8c
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_formula.cc
@@ -0,0 +1,763 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Ariya Hidayat <ariya@kde.org>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 1999-2003 Laurent Montel <montel@kde.org>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2002 Daniel Herring <herring@eecs.ku.edu>
+ (C) 2000-2001 Werner Trobin <trobin@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qtextbrowser.h>
+#include <qtabwidget.h>
+
+#include "kspread_dlg_formula.h"
+#include "kspread_canvas.h"
+#include "kspread_util.h"
+#include "kspread_editors.h"
+#include "kspread_doc.h"
+#include "kspread_locale.h"
+#include "kspread_map.h"
+#include "selection.h"
+#include "kspread_sheet.h"
+#include "kspread_view.h"
+#include "functions.h"
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kbuttonbox.h>
+#include <knumvalidator.h>
+#include <qcombobox.h>
+#include <qevent.h>
+#include <qlistbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <klineedit.h>
+#include <qlayout.h>
+
+using namespace KSpread;
+
+FormulaDialog::FormulaDialog( View* parent, const char* name,const QString& formulaName)
+ : KDialogBase( parent, name,false,i18n("Function"), Ok|Cancel )
+{
+ setWFlags( Qt::WDestructiveClose );
+
+ m_pView = parent;
+ m_focus = 0;
+ m_desc = 0;
+
+ Cell* cell = m_pView->activeSheet()->cellAt( m_pView->canvasWidget()->markerColumn(),
+ m_pView->canvasWidget()->markerRow() );
+ m_oldText=cell->text();
+ // Make sure that there is a cell editor running.
+ if ( !m_pView->canvasWidget()->editor() )
+ {
+ m_pView->canvasWidget()->createEditor( Canvas::CellEditor );
+ if(cell->text().isEmpty())
+ m_pView->canvasWidget()->editor()->setText( "=" );
+ else
+ if(cell->text().at(0)!='=')
+ m_pView->canvasWidget()->editor()->setText( "="+cell->text() );
+ else
+ m_pView->canvasWidget()->editor()->setText( cell->text() );
+ }
+
+ Q_ASSERT( m_pView->canvasWidget()->editor() );
+
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+
+ QGridLayout *grid1 = new QGridLayout(page,11,2,KDialog::marginHint(), KDialog::spacingHint());
+
+ searchFunct = new KLineEdit(page);
+ QSizePolicy sp3( QSizePolicy::Preferred, QSizePolicy::Fixed );
+ searchFunct->setSizePolicy( sp3 );
+
+ grid1->addWidget( searchFunct, 0, 0 );
+
+ typeFunction = new QComboBox(page);
+ QStringList cats = FunctionRepository::self()->groups();
+ cats.prepend( i18n("All") );
+ typeFunction->insertStringList( cats );
+ grid1->addWidget( typeFunction, 1, 0 );
+
+ functions = new QListBox(page);
+ QSizePolicy sp1( QSizePolicy::Preferred, QSizePolicy::Expanding );
+ functions->setSizePolicy( sp1 );
+ grid1->addWidget( functions, 2, 0 );
+
+ selectFunction = new QPushButton( page );
+ QToolTip::add(selectFunction, i18n("Insert function") );
+ selectFunction->setPixmap( BarIcon( "down", KIcon::SizeSmall ) );
+ grid1->addWidget( selectFunction, 3, 0 );
+
+ result = new QLineEdit( page );
+ grid1->addMultiCellWidget( result, 4, 4, 0, 1 );
+
+ m_tabwidget = new QTabWidget( page );
+ QSizePolicy sp2( QSizePolicy::Expanding, QSizePolicy::Expanding );
+ m_tabwidget->setSizePolicy( sp2 );
+ grid1->addMultiCellWidget( m_tabwidget, 0, 2, 1, 1 );
+
+ m_browser = new QTextBrowser( m_tabwidget );
+ m_browser->setMinimumWidth( 300 );
+
+ m_tabwidget->addTab( m_browser, i18n("&Help") );
+ int index = m_tabwidget->currentPageIndex();
+
+ m_input = new QWidget( m_tabwidget );
+ QVBoxLayout *grid2 = new QVBoxLayout( m_input, KDialog::marginHint(), KDialog::spacingHint() );
+
+ // grid2->setResizeMode (QLayout::Minimum);
+
+ label1 = new QLabel(m_input);
+ grid2->addWidget( label1 );
+
+ firstElement=new QLineEdit(m_input);
+ grid2->addWidget( firstElement );
+
+ label2=new QLabel(m_input);
+ grid2->addWidget( label2 );
+
+ secondElement=new QLineEdit(m_input);
+ grid2->addWidget( secondElement );
+
+ label3=new QLabel(m_input);
+ grid2->addWidget( label3 );
+
+ thirdElement=new QLineEdit(m_input);
+ grid2->addWidget( thirdElement );
+
+ label4=new QLabel(m_input);
+ grid2->addWidget( label4 );
+
+ fourElement=new QLineEdit(m_input);
+ grid2->addWidget( fourElement );
+
+ label5=new QLabel(m_input);
+ grid2->addWidget( label5 );
+
+ fiveElement=new QLineEdit(m_input);
+ grid2->addWidget( fiveElement );
+
+ grid2->addStretch( 10 );
+
+ m_tabwidget->addTab( m_input, i18n("&Parameters") );
+ m_tabwidget->setTabEnabled( m_input, FALSE );
+
+ m_tabwidget->setCurrentPage( index );
+
+ refresh_result = true;
+
+ connect( this, SIGNAL( cancelClicked() ), this, SLOT( slotClose() ) );
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+ connect( typeFunction, SIGNAL( activated(const QString &) ),
+ this, SLOT( slotActivated(const QString &) ) );
+ connect( functions, SIGNAL( highlighted(const QString &) ),
+ this, SLOT( slotSelected(const QString &) ) );
+ connect( functions, SIGNAL( selected(const QString &) ),
+ this, SLOT( slotSelected(const QString &) ) );
+ connect( functions, SIGNAL( doubleClicked(QListBoxItem * ) ),
+ this ,SLOT( slotDoubleClicked(QListBoxItem *) ) );
+
+ slotActivated(i18n("All"));
+
+ connect( selectFunction, SIGNAL(clicked()),
+ this,SLOT(slotSelectButton()));
+
+ connect( firstElement,SIGNAL(textChanged ( const QString & )),
+ this,SLOT(slotChangeText(const QString &)));
+ connect( secondElement,SIGNAL(textChanged ( const QString & )),
+ this,SLOT(slotChangeText(const QString &)));
+ connect( thirdElement,SIGNAL(textChanged ( const QString & )),
+ this,SLOT(slotChangeText(const QString &)));
+ connect( fourElement,SIGNAL(textChanged ( const QString & )),
+ this,SLOT(slotChangeText(const QString &)));
+ connect( fiveElement,SIGNAL(textChanged ( const QString & )),
+ this,SLOT(slotChangeText(const QString &)));
+
+ connect( m_pView->choice(), SIGNAL(changed(const Region&)),
+ this, SLOT(slotSelectionChanged()));
+
+ connect( m_browser, SIGNAL( linkClicked( const QString& ) ),
+ this, SLOT( slotShowFunction( const QString& ) ) );
+
+ // Save the name of the active sheet.
+ m_sheetName = m_pView->activeSheet()->sheetName();
+ // Save the cells current text.
+ QString tmp_oldText = m_pView->canvasWidget()->editor()->text();
+ // Position of the cell.
+ m_column = m_pView->canvasWidget()->markerColumn();
+ m_row = m_pView->canvasWidget()->markerRow();
+
+ if( tmp_oldText.isEmpty() )
+ result->setText("=");
+ else
+ {
+ if( tmp_oldText.at(0)!='=')
+ result->setText( "=" + tmp_oldText );
+ else
+ result->setText( tmp_oldText );
+ }
+
+ // Allow the user to select cells on the spreadsheet.
+ m_pView->canvasWidget()->startChoose();
+
+ qApp->installEventFilter( this );
+
+ // Was a function name passed along with the constructor ? Then activate it.
+ if( !formulaName.isEmpty() )
+ {
+ functions->setCurrentItem( functions->index( functions->findItem( formulaName ) ) );
+ slotDoubleClicked( functions->findItem( formulaName ) );
+ }
+ else
+ {
+ // Set keyboard focus to allow selection of a formula.
+ searchFunct->setFocus();
+ }
+
+ // Add auto completion.
+ searchFunct->setCompletionMode( KGlobalSettings::CompletionAuto );
+ searchFunct->setCompletionObject( &listFunct, true );
+
+ if( functions->currentItem() == -1 )
+ selectFunction->setEnabled( false );
+
+ connect( searchFunct, SIGNAL( textChanged( const QString & ) ),
+ this, SLOT( slotSearchText(const QString &) ) );
+ connect( searchFunct, SIGNAL( returnPressed() ),
+ this, SLOT( slotPressReturn() ) );
+}
+
+FormulaDialog::~FormulaDialog()
+{
+ kdDebug(36001)<<"FormulaDialog::~FormulaDialog() \n";
+}
+
+void FormulaDialog::slotPressReturn()
+{
+ //laurent 2001-07-07 desactivate this code
+ //because kspread crash.
+ //TODO fix it
+ /*
+ if( !functions->currentText().isEmpty() )
+ slotDoubleClicked( functions->findItem( functions->currentText() ) );
+ */
+}
+
+void FormulaDialog::slotSearchText(const QString &_text)
+{
+ QString result = listFunct.makeCompletion( _text.upper() );
+ if( !result.isNull() )
+ functions->setCurrentItem( functions->index( functions->findItem( result ) ) );
+}
+
+bool FormulaDialog::eventFilter( QObject* obj, QEvent* ev )
+{
+ if ( obj == firstElement && ev->type() == QEvent::FocusIn )
+ m_focus = firstElement;
+ else if ( obj == secondElement && ev->type() == QEvent::FocusIn )
+ m_focus = secondElement;
+ else if ( obj == thirdElement && ev->type() == QEvent::FocusIn )
+ m_focus = thirdElement;
+ else if ( obj == fourElement && ev->type() == QEvent::FocusIn )
+ m_focus = fourElement;
+ else if ( obj == fiveElement && ev->type() == QEvent::FocusIn )
+ m_focus = fiveElement;
+ else
+ return FALSE;
+
+ if ( m_focus )
+ m_pView->canvasWidget()->startChoose();
+
+ return FALSE;
+}
+
+void FormulaDialog::slotOk()
+{
+ m_pView->doc()->emitBeginOperation( false );
+
+ m_pView->canvasWidget()->endChoose();
+ // Switch back to the old sheet
+ if( m_pView->activeSheet()->sheetName() != m_sheetName )
+ {
+ Sheet *sheet=m_pView->doc()->map()->findSheet(m_sheetName);
+ if( sheet)
+ m_pView->setActiveSheet(sheet);
+ }
+
+ // Revert the marker to its original position
+ m_pView->selectionInfo()->initialize( QPoint( m_column, m_row ) );
+
+ // If there is still an editor then set the text.
+ // Usually the editor is always in place.
+ if( m_pView->canvasWidget()->editor() != 0 )
+ {
+ Q_ASSERT( m_pView->canvasWidget()->editor() );
+ QString tmp = result->text();
+ if( tmp.at(0) != '=')
+ tmp = "=" + tmp;
+ int pos = m_pView->canvasWidget()->editor()->cursorPosition()+ tmp.length();
+ m_pView->canvasWidget()->editor()->setText( tmp );
+ m_pView->canvasWidget()->editor()->setFocus();
+ m_pView->canvasWidget()->editor()->setCursorPosition( pos );
+ }
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+ // delete this;
+}
+
+void FormulaDialog::slotClose()
+{
+ m_pView->doc()->emitBeginOperation( false );
+
+ m_pView->canvasWidget()->endChoose();
+
+ // Switch back to the old sheet
+ if(m_pView->activeSheet()->sheetName() != m_sheetName )
+ {
+ Sheet *sheet=m_pView->doc()->map()->findSheet(m_sheetName);
+ if( !sheet )
+ return;
+ m_pView->setActiveSheet(sheet);
+ }
+
+
+ // Revert the marker to its original position
+ m_pView->selectionInfo()->initialize( QPoint( m_column, m_row ) );
+
+ // If there is still an editor then reset the text.
+ // Usually the editor is always in place.
+ if( m_pView->canvasWidget()->editor() != 0 )
+ {
+ Q_ASSERT( m_pView->canvasWidget()->editor() );
+ m_pView->canvasWidget()->editor()->setText( m_oldText );
+ m_pView->canvasWidget()->editor()->setFocus();
+ }
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ reject();
+ //laurent 2002-01-03 comment this line otherwise kspread crash
+ //but dialog box is not deleted => not good
+ //delete this;
+}
+
+void FormulaDialog::slotSelectButton()
+{
+ if( functions->currentItem() != -1 )
+ {
+ slotDoubleClicked(functions->findItem(functions->text(functions->currentItem())));
+ }
+}
+
+void FormulaDialog::slotChangeText( const QString& )
+{
+ // Test the lock
+ if( !refresh_result )
+ return;
+
+ if ( m_focus == 0 )
+ return;
+
+ QString tmp = m_leftText+m_funcName+"(";
+ tmp += createFormula();
+ tmp = tmp+ ")" + m_rightText;
+
+ result->setText( tmp );
+}
+
+QString FormulaDialog::createFormula()
+{
+ QString tmp( "" );
+
+ if ( !m_desc )
+ return QString::null;
+
+ bool first = TRUE;
+
+ int count = m_desc->params();
+
+ if(!firstElement->text().isEmpty() && count >= 1 )
+ {
+ tmp=tmp+createParameter(firstElement->text(), 0 );
+ first = FALSE;
+ }
+
+ if(!secondElement->text().isEmpty() && count >= 2 )
+ {
+ first = FALSE;
+ if ( !first )
+ tmp=tmp+";"+createParameter(secondElement->text(), 1 );
+ else
+ tmp=tmp+createParameter(secondElement->text(), 1 );
+ }
+ if(!thirdElement->text().isEmpty() && count >= 3 )
+ {
+ first = FALSE;
+ if ( !first )
+ tmp=tmp+";"+createParameter(thirdElement->text(), 2 );
+ else
+ tmp=tmp+createParameter(thirdElement->text(), 2 );
+ }
+ if(!fourElement->text().isEmpty() && count >= 4 )
+ {
+ first = FALSE;
+ if ( !first )
+ tmp=tmp+";"+createParameter(fourElement->text(), 3 );
+ else
+ tmp=tmp+createParameter(fourElement->text(), 3 );
+ }
+ if(!fiveElement->text().isEmpty() && count >= 5 )
+ {
+ first = FALSE;
+ if ( !first )
+ tmp=tmp+";"+createParameter(fiveElement->text(), 4 );
+ else
+ tmp=tmp+createParameter(fiveElement->text(), 4 );
+ }
+
+ return(tmp);
+}
+
+QString FormulaDialog::createParameter( const QString& _text, int param )
+{
+ if ( _text.isEmpty() )
+ return QString( "" );
+
+ if ( !m_desc )
+ return QString( "" );
+
+ QString text;
+
+ ParameterType elementType = m_desc->param( param ).type();
+
+ switch( elementType )
+ {
+ case KSpread_Any:
+ {
+ bool isNumber;
+ double tmp = m_pView->doc()->locale()->readNumber( _text, &isNumber );
+ Q_UNUSED( tmp );
+
+ //In case of number or boolean return _text, else return value as KSpread_String
+ if ( isNumber || _text.upper() =="FALSE" || _text.upper() == "TRUE" )
+ return _text;
+ }
+ // fall through
+ case KSpread_String:
+ {
+ // Does the text start with quotes?
+ if ( _text[0] == '"' )
+ {
+ text = "\\"; // changed: was "\""
+
+ // Escape quotes
+ QString tmp = _text;
+ int pos;
+ int start = 1;
+ while( ( pos = tmp.find( '"', start ) ) != -1 )
+ {
+ if (tmp[pos - 1] != '\\')
+ tmp.replace( pos, 1, "\\\"" );
+ else
+ start = pos + 1;
+ }
+
+ text += tmp;
+ text += "\"";
+ }
+ else
+ {
+ Point p = Point( _text, m_pView->doc()->map() );
+ Range r = Range( _text, m_pView->doc()->map() );
+
+ if( !p.isValid() && !r.isValid() )
+ {
+ text = "\"";
+
+ // Escape quotes
+ QString tmp = _text;
+ int pos;
+ int start = 1;
+ while( ( pos = tmp.find( '"', start ) ) != -1 )
+ {
+ if (tmp[pos - 1] != '\\')
+ tmp.replace( pos, 1, "\\\"" );
+ else
+ start = pos + 1;
+ }
+
+ text += tmp;
+ text += "\"";
+ }
+ else
+ text = _text;
+ }
+ }
+ return text;
+ case KSpread_Float:
+ return _text;
+ case KSpread_Boolean:
+ return _text;
+ case KSpread_Int:
+ return _text;
+ }
+
+ // Never reached
+ return text;
+}
+
+static void showEntry( QLineEdit* edit, QLabel* label,
+ FunctionDescription* desc, int param )
+{
+ edit->show();
+ label->setText( desc->param( param ).helpText()+":" );
+ label->show();
+ ParameterType elementType = desc->param( param ).type();
+ KFloatValidator *validate=0L;
+ switch( elementType )
+ {
+ case KSpread_String:
+ case KSpread_Boolean:
+ case KSpread_Any:
+ edit->clearValidator ();
+ break;
+ case KSpread_Float:
+ validate=new KFloatValidator (edit);
+ validate->setAcceptLocalizedNumbers(true);
+ edit->setValidator(validate);
+ edit->setText( "0" );
+ break;
+ case KSpread_Int:
+ edit->setValidator(new QIntValidator (edit));
+ edit->setText( "0" );
+ break;
+ }
+
+}
+
+void FormulaDialog::slotDoubleClicked( QListBoxItem* item )
+{
+ if ( !item )
+ return;
+ refresh_result = false;
+ if ( !m_desc )
+ {
+ m_browser->setText( "" );
+ return;
+ }
+
+ m_focus = 0;
+ int old_length = result->text().length();
+
+ // Dont change order of these function calls due to a bug in Qt 2.2
+ m_browser->setText( m_desc->toQML() );
+ m_tabwidget->setTabEnabled( m_input, TRUE );
+ m_tabwidget->setCurrentPage( 1 );
+
+ //
+ // Show as many QLineEdits as needed.
+ //
+ if( m_desc->params() > 0 )
+ {
+ m_focus = firstElement;
+ firstElement->setFocus();
+
+ showEntry( firstElement, label1, m_desc, 0 );
+ }
+ else
+ {
+ label1->hide();
+ firstElement->hide();
+ }
+
+ if( m_desc->params() > 1 )
+ {
+ showEntry( secondElement, label2, m_desc, 1 );
+ }
+ else
+ {
+ label2->hide();
+ secondElement->hide();
+ }
+
+ if( m_desc->params() > 2 )
+ {
+ showEntry( thirdElement, label3, m_desc, 2 );
+ }
+ else
+ {
+ label3->hide();
+ thirdElement->hide();
+ }
+
+ if( m_desc->params() > 3 )
+ {
+ showEntry( fourElement, label4, m_desc, 3 );
+ }
+ else
+ {
+ label4->hide();
+ fourElement->hide();
+ }
+
+ if( m_desc->params() > 4 )
+ {
+ showEntry( fiveElement, label5, m_desc, 4 );
+ }
+ else
+ {
+ label5->hide();
+ fiveElement->hide();
+ }
+
+ if( m_desc->params() > 5 )
+ {
+ kdDebug(36001) << "Error in param->nb_param" << endl;
+ }
+ refresh_result= true;
+ //
+ // Put the new function call in the result.
+ //
+ if( result->cursorPosition() < old_length )
+ {
+ m_rightText=result->text().right(old_length-result->cursorPosition());
+ m_leftText=result->text().left(result->cursorPosition());
+ }
+ else
+ {
+ m_rightText="";
+ m_leftText=result->text();
+ }
+ int pos = result->cursorPosition();
+ result->setText( m_leftText+functions->text( functions->currentItem() ) + "()" + m_rightText);
+
+ if (result->text()[0] != '=')
+ result->setText("=" + result->text());
+
+ //
+ // Put focus somewhere is there are no QLineEdits visible
+ //
+ if( m_desc->params() == 0 )
+ {
+ label1->show();
+ label1->setText( i18n("This function has no parameters.") );
+
+ result->setFocus();
+ result->setCursorPosition(pos+functions->text(functions->currentItem()).length()+2);
+ }
+ slotChangeText( "" );
+}
+
+void FormulaDialog::slotSelected( const QString& function )
+{
+ FunctionDescription* desc =
+ FunctionRepository::self()->functionInfo (function);
+ if ( !desc )
+ {
+ m_browser->setText (i18n ("Description is not available."));
+ return;
+ }
+
+ if( functions->currentItem() !=- 1 )
+ selectFunction->setEnabled( TRUE );
+
+ // Lock
+ refresh_result = false;
+
+ m_funcName = function;
+ m_desc = desc;
+
+ // Set the help text
+ m_browser->setText( m_desc->toQML() );
+ m_browser->setContentsPos( 0, 0 );
+
+ m_focus=0;
+
+ m_tabwidget->setCurrentPage( 0 );
+ m_tabwidget->setTabEnabled( m_input, FALSE );
+
+ // Unlock
+ refresh_result=true;
+}
+
+// from hyperlink in the "Related Function"
+void FormulaDialog::slotShowFunction( const QString& function )
+{
+ FunctionDescription* desc =
+ FunctionRepository::self()->functionInfo( function );
+ if ( !desc ) return;
+
+ // select the category
+ QString category = desc->group();
+ typeFunction->setCurrentText( category );
+ slotActivated( category );
+
+ // select the function
+ QListBoxItem* item = functions->findItem( function,
+ Qt::ExactMatch | Qt::CaseSensitive );
+ if( item ) functions->setCurrentItem( item );
+
+ slotSelected( function );
+}
+
+void FormulaDialog::slotSelectionChanged()
+{
+ if ( !m_focus )
+ return;
+
+ if (m_pView->choice()->isValid())
+ {
+ QString area = m_pView->choice()->name();
+ m_focus->setText( area );
+ }
+}
+
+void FormulaDialog::slotActivated( const QString& category )
+{
+ QStringList lst;
+ if ( category == i18n("All") )
+ lst = FunctionRepository::self()->functionNames();
+ else
+ lst = FunctionRepository::self()->functionNames( category );
+
+ kdDebug(36001)<<"category: "<<category<<" ("<<lst.count()<<"functions)" << endl;
+
+ functions->clear();
+ functions->insertStringList( lst );
+
+ QStringList upperList;
+ for ( QStringList::Iterator it = lst.begin(); it != lst.end();++it )
+ upperList.append((*it).upper());
+
+ listFunct.setItems( upperList );
+
+ // Go to the first function in the list.
+ functions->setCurrentItem(0);
+ slotSelected( functions->text(0) );
+}
+
+void FormulaDialog::closeEvent ( QCloseEvent * e )
+{
+ e->accept();
+}
+
+#include "kspread_dlg_formula.moc"
diff --git a/kspread/dialogs/kspread_dlg_formula.h b/kspread/dialogs/kspread_dlg_formula.h
new file mode 100644
index 00000000..d4e224e7
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_formula.h
@@ -0,0 +1,179 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Ariya Hidayat <ariya@kde.org>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 1999-2003 Laurent Montel <montel@kde.org>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2002 Daniel Herring <herring@eecs.ku.edu>
+ (C) 2000-2001 Werner Trobin <trobin@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_formula__
+#define __kspread_dlg_formula__
+
+#include <qframe.h>
+
+#include <kcompletion.h>
+#include <kdialogbase.h>
+
+class QComboBox;
+class QLabel;
+class QLineEdit;
+class QListBox;
+class QPushButton;
+class QTabWidget;
+class QTextBrowser;
+class KLineEdit;
+
+namespace KSpread
+{
+class FunctionDescription;
+class Sheet;
+class View;
+
+class FormulaDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ FormulaDialog( View* parent, const char* name,const QString& formulaName=0);
+ ~FormulaDialog();
+private:
+ /**
+ * Turns the @p text into a parameter that koscript can understand. The type
+ * of this parameter is extracted by looking at parameter number @p param in @ref #m_desc.
+ */
+ QString createParameter( const QString& _text, int param );
+ /**
+ * Reads the text out of @ref #firstElement and friends and creates a parameter
+ * list for the function.
+ */
+ QString createFormula();
+
+private slots:
+ /**
+ * Called by the Ok button.
+ */
+ void slotOk();
+ /**
+ * Called by the Close button.
+ */
+ void slotClose();
+ /**
+ * Called if a function name was selected but not double clicked.
+ * This will just show the help page for the function.
+ */
+ void slotSelected( const QString& function );
+ /**
+ * Called if the user clicked on one of the "related function"
+ * This will switch the active function and show help page
+ * of the function as well.
+ */
+ void slotShowFunction( const QString& function );
+ /**
+ * Called if the user double clicked on some method name.
+ * That will switch into editing mode, allowing the user
+ * to enter the parameters for the function.
+ */
+ void slotDoubleClicked( QListBoxItem* item );
+ /**
+ * Called if a category of methods has been selected.
+ */
+ void slotActivated(const QString& category );
+ /**
+ * Called if the text of @ref #firstElement, @ref #secondElement etc. changes.
+ */
+ void slotChangeText(const QString& text );
+ /**
+ * Connected to @ref View to get notified if the selection in the
+ * sheet changes.
+ */
+ void slotSelectionChanged();
+ /**
+ * Called if the button @ref #selectFunction was clicked. That
+ * insertes a new function call to the result.
+ */
+ void slotSelectButton();
+ /**
+ * Called if the user changes some character in @ref #searchFunct.
+ */
+ void slotSearchText(const QString& text );
+ /**
+ * Called if the user pressed return in @ref #searchFunct.
+ */
+ void slotPressReturn();
+
+public:
+ /**
+ * Find out which widget got focus.
+ */
+ bool eventFilter( QObject* obj, QEvent* ev );
+protected:
+ virtual void closeEvent ( QCloseEvent * );
+private:
+ View* m_pView;
+
+ QTabWidget* m_tabwidget;
+ QTextBrowser* m_browser;
+ QWidget* m_input;
+
+ QPushButton *selectFunction;
+ QComboBox *typeFunction;
+ QListBox *functions;
+ QLineEdit *result;
+
+ KLineEdit *searchFunct;
+ KCompletion listFunct;
+
+ QLabel* label1;
+ QLabel* label2;
+ QLabel* label3;
+ QLabel* label4;
+ QLabel* label5;
+ QLineEdit *firstElement;
+ QLineEdit *secondElement;
+ QLineEdit *thirdElement;
+ QLineEdit *fourElement;
+ QLineEdit *fiveElement;
+ /**
+ * Tells which of the lineedits has the logical focus currently.
+ * It may happen that a lineedit does not have qt focus but
+ * logical focus but not the other way round.
+ */
+ QLineEdit* m_focus;
+
+ int m_column;
+ int m_row;
+ QString m_oldText;
+
+ QString m_funcName;
+ QString m_sheetName;
+
+ QString m_rightText;
+ QString m_leftText;
+ /**
+ * A lock for @ref #slotChangeText.
+ */
+ bool refresh_result;
+
+ KSpread::FunctionDescription* m_desc;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_goalseek.cc b/kspread/dialogs/kspread_dlg_goalseek.cc
new file mode 100644
index 00000000..a87ad3ef
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_goalseek.cc
@@ -0,0 +1,486 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 Laurent Montel <montel@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Werner Trobin <trobin@kde.org>
+ (C) 2002 Harri Porten <porten@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "kspread_dlg_goalseek.h"
+
+#include "kspread_canvas.h"
+#include "kspread_cell.h"
+#include "kspread_doc.h"
+#include "kspread_map.h"
+#include "selection.h"
+#include "kspread_sheet.h"
+#include "kspread_undo.h"
+#include "kspread_util.h"
+#include "kspread_view.h"
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kstdguiitem.h>
+#include <kpushbutton.h>
+
+#include <qframe.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qtooltip.h>
+#include <qvariant.h>
+#include <qwhatsthis.h>
+
+#include <math.h>
+
+using namespace KSpread;
+
+GoalSeekDialog::GoalSeekDialog( View * parent, QPoint const & marker,
+ const char * name, bool, WFlags fl )
+ : KDialog( parent, name, false, fl ),
+ m_pView( parent ),
+ m_maxIter( 1000 ),
+ m_restored( true ),
+ m_focus(0),
+ m_anchor( m_pView->selectionInfo()->anchor() ),
+ m_marker( m_pView->selectionInfo()->marker() ),
+ m_selection( m_pView->selectionInfo()->selection() )
+{
+ setWFlags( Qt::WDestructiveClose );
+
+ if ( !name )
+ setName( "GoalSeekDialog" );
+
+ resize( 458, 153 );
+ setCaption( i18n( "Goal Seek" ) );
+ setSizeGripEnabled( true );
+
+ GoalSeekDialogLayout = new QGridLayout( this, 1, 1, 11, 6, "GoalSeekDialogLayout");
+
+ m_startFrame = new QFrame( this, "m_startFrame" );
+ m_startFrame->setFrameShape( QFrame::StyledPanel );
+ m_startFrame->setFrameShadow( QFrame::Raised );
+ m_startFrameLayout = new QGridLayout( m_startFrame, 1, 1, 11, 6, "m_startFrameLayout");
+
+ QLabel * TextLabel4 = new QLabel( m_startFrame, "TextLabel4" );
+ TextLabel4->setText( i18n( "To value:" ) );
+ m_startFrameLayout->addWidget( TextLabel4, 1, 0 );
+
+ m_targetValueEdit = new QLineEdit( m_startFrame, "m_targetValueEdit" );
+ m_startFrameLayout->addWidget( m_targetValueEdit, 1, 1 );
+
+ m_targetEdit = new QLineEdit( m_startFrame, "m_targetEdit" );
+ m_startFrameLayout->addWidget( m_targetEdit, 0, 1 );
+ m_targetEdit->setText( Cell::name( marker.x(), marker.y() ) );
+
+ m_sourceEdit = new QLineEdit( m_startFrame, "m_sourceEdit" );
+ m_startFrameLayout->addWidget( m_sourceEdit, 2, 1 );
+
+ QLabel * TextLabel5 = new QLabel( m_startFrame, "TextLabel5" );
+ TextLabel5->setText( i18n( "By changing cell:" ) );
+
+ m_startFrameLayout->addWidget( TextLabel5, 2, 0 );
+
+ QLabel * TextLabel3 = new QLabel( m_startFrame, "TextLabel3" );
+ TextLabel3->setText( i18n( "Set cell:" ) );
+
+ m_startFrameLayout->addWidget( TextLabel3, 0, 0 );
+ GoalSeekDialogLayout->addWidget( m_startFrame, 0, 0 );
+
+ QVBoxLayout * Layout5 = new QVBoxLayout( 0, 0, 6, "Layout5");
+
+ m_buttonOk = new QPushButton( this, "m_buttonOk" );
+ m_buttonOk->setText( i18n( "&Start" ) );
+ m_buttonOk->setAccel( 276824143 );
+ m_buttonOk->setAutoDefault( TRUE );
+ m_buttonOk->setDefault( TRUE );
+ Layout5->addWidget( m_buttonOk );
+
+ m_buttonCancel = new KPushButton( KStdGuiItem::cancel(), this, "m_buttonCancel" );
+ m_buttonCancel->setAccel( 276824131 );
+ m_buttonCancel->setAutoDefault( TRUE );
+ Layout5->addWidget( m_buttonCancel );
+ QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ Layout5->addItem( spacer );
+
+ GoalSeekDialogLayout->addMultiCellLayout( Layout5, 0, 1, 1, 1 );
+
+ m_resultFrame = new QFrame( this, "m_resultFrame" );
+ m_resultFrame->setFrameShape( QFrame::StyledPanel );
+ m_resultFrame->setFrameShadow( QFrame::Raised );
+ m_resultFrame->setMinimumWidth( 350 );
+ m_resultFrameLayout = new QGridLayout( m_resultFrame, 1, 1, 11, 6, "m_resultFrameLayout");
+
+ m_currentValueLabel = new QLabel( m_resultFrame, "m_currentValueLabel" );
+ m_currentValueLabel->setText( i18n( "Current value:" ) );
+
+ m_resultFrameLayout->addWidget( m_currentValueLabel, 2, 0 );
+
+ m_newValueDesc = new QLabel( m_resultFrame, "m_newValueDesc" );
+ m_newValueDesc->setText( i18n( "New value:" ) );
+
+ m_resultFrameLayout->addWidget( m_newValueDesc, 1, 0 );
+
+ m_newValue = new QLabel( m_resultFrame, "m_newValue" );
+ m_newValue->setText( "m_targetValueEdit" );
+
+ m_resultFrameLayout->addWidget( m_newValue, 1, 1 );
+
+ m_currentValue = new QLabel( m_resultFrame, "m_currentValue" );
+ m_currentValue->setText( "m_currentValue" );
+
+ m_resultFrameLayout->addWidget( m_currentValue, 2, 1 );
+
+ m_resultText = new QLabel( m_resultFrame, "m_resultText" );
+ m_resultText->setText( "Goal seeking with cell <cell> found <a | no> solution:" );
+ m_resultText->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) );
+
+ m_resultFrameLayout->addMultiCellWidget( m_resultText, 0, 0, 0, 1 );
+
+ // GoalSeekDialogLayout->addWidget( m_resultFrame, 1, 0 );
+
+ m_resultFrame->hide();
+
+ m_sheetName = m_pView->activeSheet()->sheetName();
+
+ // Allow the user to select cells on the spreadsheet.
+ m_pView->canvasWidget()->startChoose();
+
+ qApp->installEventFilter( this );
+
+ // signals and slots connections
+ connect( m_buttonOk, SIGNAL( clicked() ), this, SLOT( buttonOkClicked() ) );
+ connect( m_buttonCancel, SIGNAL( clicked() ), this, SLOT( buttonCancelClicked() ) );
+
+ connect( m_pView->choice(), SIGNAL(changed(const Region&)),
+ this, SLOT(slotSelectionChanged()));
+
+ // tab order
+ setTabOrder( m_targetEdit, m_targetValueEdit );
+ setTabOrder( m_targetValueEdit, m_sourceEdit );
+ setTabOrder( m_sourceEdit, m_buttonOk );
+ setTabOrder( m_buttonOk, m_buttonCancel );
+}
+
+GoalSeekDialog::~GoalSeekDialog()
+{
+ kdDebug() << "~GoalSeekDialog" << endl;
+
+ if ( !m_restored )
+ {
+ m_pView->doc()->emitBeginOperation( false );
+ m_sourceCell->setValue(m_oldSource);
+ m_targetCell->setCalcDirtyFlag();
+ m_targetCell->calc();
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ }
+}
+
+bool GoalSeekDialog::eventFilter( QObject* obj, QEvent* ev )
+{
+ if ( obj == m_targetValueEdit && ev->type() == QEvent::FocusIn )
+ m_focus = m_targetValueEdit;
+ else if ( obj == m_targetEdit && ev->type() == QEvent::FocusIn )
+ m_focus = m_targetEdit;
+ else if ( obj == m_sourceEdit && ev->type() == QEvent::FocusIn )
+ m_focus = m_sourceEdit;
+ else
+ return FALSE;
+
+ if ( m_focus )
+ m_pView->canvasWidget()->startChoose();
+
+ return FALSE;
+}
+
+void GoalSeekDialog::closeEvent ( QCloseEvent * e )
+{
+ e->accept();
+}
+
+void GoalSeekDialog::slotSelectionChanged()
+{
+ if ( !m_focus )
+ return;
+
+ if (m_pView->choice()->isValid())
+ {
+ QString area = m_pView->choice()->name();
+ m_focus->setText( area );
+ }
+}
+
+void GoalSeekDialog::buttonOkClicked()
+{
+ Doc * pDoc = m_pView->doc();
+ pDoc->emitBeginOperation( false );
+ if (m_maxIter > 0)
+ {
+ Sheet * sheet = m_pView->activeSheet();
+
+ Point source( m_sourceEdit->text(), sheet->workbook(), sheet );
+ if (!source.isValid())
+ {
+ KMessageBox::error( this, i18n("Cell reference is invalid.") );
+ m_sourceEdit->selectAll();
+ m_sourceEdit->setFocus();
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ return;
+ }
+
+ Point target( m_targetEdit->text(), sheet->workbook(), sheet );
+ if (!target.isValid())
+ {
+ KMessageBox::error( this, i18n("Cell reference is invalid.") );
+ m_targetEdit->selectAll();
+ m_targetEdit->setFocus();
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ return;
+ }
+
+ bool ok = false;
+ double goal = m_pView->doc()->locale()->readNumber(m_targetValueEdit->text(), &ok );
+ if ( !ok )
+ {
+ KMessageBox::error( this, i18n("Target value is invalid.") );
+ m_targetValueEdit->selectAll();
+ m_targetValueEdit->setFocus();
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ return;
+ }
+
+ m_sourceCell = source.cell();
+ m_targetCell = target.cell();
+
+ if ( !m_sourceCell->value().isNumber() )
+ {
+ KMessageBox::error( this, i18n("Source cell must contain a numeric value.") );
+ m_sourceEdit->selectAll();
+ m_sourceEdit->setFocus();
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ return;
+ }
+
+ if ( !m_targetCell->isFormula() )
+ {
+ KMessageBox::error( this, i18n("Target cell must contain a formula.") );
+ m_targetEdit->selectAll();
+ m_targetEdit->setFocus();
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ return;
+ }
+
+ m_buttonOk->setText( i18n("&OK") );
+ m_buttonOk->setEnabled(false);
+ m_buttonCancel->setEnabled(false);
+ GoalSeekDialogLayout->addWidget( m_resultFrame, 0, 0 );
+ m_startFrame->hide();
+ m_resultFrame->show();
+ if ( m_startFrame->width() > 350 )
+ m_resultFrame->setMinimumWidth( m_startFrame->width() );
+
+ m_restored = false;
+
+ startCalc( m_sourceCell->value().asFloat(), goal );
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+
+ return;
+ }
+ else
+ {
+ if ( !pDoc->undoLocked() )
+ {
+ UndoSetText * undo
+ = new UndoSetText( pDoc, m_pView->activeSheet(), QString::number(m_oldSource),
+ m_sourceCell->column(), m_sourceCell->row(),
+ m_sourceCell->formatType() );
+
+ pDoc->addCommand( undo );
+ }
+
+ m_restored = true;
+ }
+ chooseCleanup();
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+void GoalSeekDialog::buttonCancelClicked()
+{
+ if ( !m_restored )
+ {
+ m_pView->doc()->emitBeginOperation( false );
+ m_sourceCell->setValue(m_oldSource);
+ m_targetCell->setCalcDirtyFlag();
+ m_targetCell->calc();
+ m_restored = true;
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ }
+
+ chooseCleanup();
+ reject();
+}
+
+void GoalSeekDialog::chooseCleanup()
+{
+ m_pView->canvasWidget()->endChoose();
+
+ Sheet * sheet = 0;
+
+ // Switch back to the old sheet
+ if ( m_pView->activeSheet()->sheetName() != m_sheetName )
+ {
+ sheet = m_pView->doc()->map()->findSheet( m_sheetName );
+ if ( sheet )
+ m_pView->setActiveSheet( sheet );
+ }
+ else
+ sheet = m_pView->activeSheet();
+
+ // Revert the marker to its original position
+ m_pView->selectionInfo()->initialize(QRect(m_marker, m_anchor));//, sheet );
+}
+
+
+void GoalSeekDialog::startCalc(double _start, double _goal)
+{
+ m_resultText->setText( i18n( "Starting..." ) );
+ m_newValueDesc->setText( i18n( "Iteration:" ) );
+
+ // lets be optimistic
+ bool ok = true;
+
+ // TODO: make this configurable
+ double eps = 0.0000001;
+
+ double startA = 0.0, startB;
+ double resultA, resultB;
+
+ // save old value
+ m_oldSource = m_sourceCell->value().asFloat();
+ resultA = _goal;
+
+ // initialize start value
+ startB = _start;
+ double x = startB + 0.5;
+
+ // while the result is not close enough to zero
+ // or while the max number of iterations is not reached...
+ while ( fabs( resultA ) > eps && ( m_maxIter >= 0 ) )
+ {
+ startA = startB;
+ startB = x;
+
+ m_sourceCell->setValue(startA);
+ // m_sourceCell->updateDepending();
+ m_sourceCell->setCalcDirtyFlag();
+ m_targetCell->calc( false );
+ resultA = m_targetCell->value().asFloat() - _goal;
+ // kdDebug() << "Target A: " << m_targetCell->value().asFloat() << ", " << m_targetCell->text() << " Calc: " << resultA << endl;
+
+ m_sourceCell->setValue(startB);
+ // m_sourceCell->updateDepending();
+ m_sourceCell->setCalcDirtyFlag();
+ m_targetCell->calc( false );
+ resultB = m_targetCell->value().asFloat() - _goal;
+ /*
+ kdDebug() << "Target B: " << m_targetCell->value().asFloat() << ", " << m_targetCell->text() << " Calc: " << resultB << endl;
+
+ kdDebug() << "Iteration: " << m_maxIter << ", StartA: " << startA
+ << ", ResultA: " << resultA << " (eps: " << eps << "), StartB: "
+ << startB << ", ResultB: " << resultB << endl;
+ */
+
+ // find zero with secant method (rough implementation was provided by Franz-Xaver Meier):
+ // if the function returns the same for two different
+ // values we have something like a horizontal line
+ // => can't get zero.
+ if ( resultB == resultA )
+ {
+ // kdDebug() << " resultA == resultB" << endl;
+ if ( fabs( resultA ) < eps )
+ {
+ ok = true;
+ break;
+ }
+
+ ok = false;
+ break;
+ }
+
+ // Point of intersection of secant with x-axis
+ x = ( startA * resultB - startB * resultA ) / ( resultB - resultA );
+
+ if ( fabs(x) > 100000000 )
+ {
+ // kdDebug() << "fabs(x) > 100000000: " << x << endl;
+ ok = false;
+ break;
+ }
+
+ // kdDebug() << "X: " << x << ", fabs (resultA): " << fabs(resultA) << ", Real start: " << startA << ", Real result: " << resultA << ", Iteration: " << m_maxIter << endl;
+
+ --m_maxIter;
+ if ( m_maxIter % 20 == 0 )
+ m_newValue->setText( QString::number(m_maxIter) );
+ }
+
+ m_newValueDesc->setText( i18n( "New value:" ) );
+ if ( ok )
+ {
+ m_sourceCell->setValue( startA );
+ m_sourceCell->setCalcDirtyFlag();
+ m_sourceCell->sheet()->setRegionPaintDirty(m_sourceCell->cellRect());
+ // m_targetCell->setCalcDirtyFlag();
+ m_targetCell->calc( false );
+
+ m_resultText->setText( i18n( "Goal seeking with cell %1 found a solution:" ).arg( m_sourceEdit->text() ) );
+ m_newValue->setText( m_pView->doc()->locale()->formatNumber( startA ) );
+ m_currentValue->setText( m_pView->doc()->locale()->formatNumber( m_oldSource ) );
+ m_restored = false;
+ }
+ else
+ {
+ // restore the old value
+ m_sourceCell->setValue( m_oldSource );
+ m_targetCell->setCalcDirtyFlag();
+ m_sourceCell->sheet()->setRegionPaintDirty(m_sourceCell->cellRect());
+ m_targetCell->calc( false );
+ m_resultText->setText( i18n( "Goal seeking with cell %1 has found NO solution." ).arg( m_sourceEdit->text() ) );
+ m_newValue->setText( "" );
+ m_currentValue->setText( m_pView->doc()->locale()->formatNumber( m_oldSource ) );
+ m_restored = true;
+ }
+
+ m_buttonOk->setEnabled( true );
+ m_buttonCancel->setEnabled( true );
+ m_maxIter = 0;
+}
+
+#include "kspread_dlg_goalseek.moc"
+
diff --git a/kspread/dialogs/kspread_dlg_goalseek.h b/kspread/dialogs/kspread_dlg_goalseek.h
new file mode 100644
index 00000000..966bcf17
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_goalseek.h
@@ -0,0 +1,116 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 Laurent Montel <montel@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Werner Trobin <trobin@kde.org>
+ (C) 2002 Harri Porten <porten@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_goalseek__
+#define __kspread_dlg_goalseek__
+
+#include <kdialog.h>
+#include <qpoint.h>
+#include <qrect.h>
+
+class QFrame;
+class QGridLayout;
+class QHBoxLayout;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QVBoxLayout;
+
+namespace KSpread
+{
+class Cell;
+class Point;
+class Sheet;
+class View;
+
+class GoalSeekDialog : public KDialog
+{
+ Q_OBJECT
+
+ public:
+ GoalSeekDialog( View * parent, QPoint const & marker, const char * name = 0,
+ bool modal = FALSE, WFlags fl = 0 );
+ ~GoalSeekDialog();
+
+ /**
+ * Find out which widget got focus.
+ */
+ bool eventFilter( QObject* obj, QEvent* ev );
+
+ public slots:
+ void buttonOkClicked();
+ void buttonCancelClicked();
+ void slotSelectionChanged();
+
+ protected:
+ virtual void closeEvent ( QCloseEvent * );
+
+ QGridLayout * GoalSeekDialogLayout;
+ QGridLayout * m_startFrameLayout;
+ QGridLayout * m_resultFrameLayout;
+
+ private:
+ View * m_pView;
+ Cell * m_sourceCell;
+ Cell * m_targetCell;
+ double m_result;
+ int m_maxIter;
+ bool m_restored;
+ double m_oldSource;
+
+ QString m_oldText;
+ QString m_sheetName;
+
+ QFrame * m_startFrame;
+ QLineEdit * m_targetValueEdit;
+ QLineEdit * m_targetEdit;
+ QLineEdit * m_sourceEdit;
+ QPushButton * m_buttonOk;
+ QPushButton * m_buttonCancel;
+ QFrame * m_resultFrame;
+ QLabel * m_newValueDesc;
+ QLabel * m_currentValueLabel;
+ QLabel * m_newValue;
+ QLabel * m_currentValue;
+ QLabel * m_resultText;
+
+ /**
+ * Tells which of the lineedits has the logical focus currently.
+ * It may happen that a lineedit does not have qt focus but
+ * logical focus but not the other way round.
+ */
+ QLineEdit * m_focus;
+
+ QPoint m_anchor;
+ QPoint m_marker;
+ QRect m_selection;
+
+ void startCalc(double _start, double _goal);
+ void chooseCleanup();
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_goto.cc b/kspread/dialogs/kspread_dlg_goto.cc
new file mode 100644
index 00000000..12117e36
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_goto.cc
@@ -0,0 +1,87 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999-2003 Laurent Montel <montel@kde.org>
+ (C) 2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2003 Ariya Hidayat <ariya@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 1999 Stephan Kulow <coolo@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <klineedit.h>
+
+#include "kspread_canvas.h"
+#include "kspread_doc.h"
+#include "kspread_locale.h"
+#include "kspread_util.h"
+#include "kspread_view.h"
+#include "selection.h"
+
+#include "kspread_dlg_goto.h"
+
+using namespace KSpread;
+
+GotoDialog::GotoDialog( View* parent, const char* name )
+ : KDialogBase( parent, name, TRUE, i18n("Goto Cell"), Ok|Cancel )
+{
+ m_pView = parent;
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+ QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
+
+ QLabel *label = new QLabel(i18n("Enter cell:"), page);
+ lay1->addWidget(label);
+
+ m_nameCell = new KLineEdit( page );
+ lay1->addWidget(m_nameCell);
+
+ m_nameCell->setFocus();
+ enableButtonOK( false );
+
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+ connect( m_nameCell, SIGNAL(textChanged ( const QString & )),
+ this, SLOT(textChanged ( const QString & )));
+}
+
+void GotoDialog::textChanged ( const QString &_text )
+{
+ enableButtonOK(!_text.isEmpty());
+}
+
+void GotoDialog::slotOk()
+{
+ m_pView->doc()->emitBeginOperation( false );
+
+ QString tmp_upper;
+ tmp_upper=m_nameCell->text().upper();
+ Region region(m_pView, tmp_upper);
+ if ( region.isValid() )
+ {
+ m_pView->selectionInfo()->initialize(region);
+ accept();
+ }
+ else
+ {
+ m_nameCell->clear();
+ }
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+}
+
+#include "kspread_dlg_goto.moc"
diff --git a/kspread/dialogs/kspread_dlg_goto.h b/kspread/dialogs/kspread_dlg_goto.h
new file mode 100644
index 00000000..7237f575
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_goto.h
@@ -0,0 +1,55 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999-2003 Laurent Montel <montel@kde.org>
+ (C) 2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2003 Ariya Hidayat <ariya@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 1999 Stephan Kulow <coolo@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_goto__
+#define __kspread_dlg_goto__
+
+#include <kdialogbase.h>
+
+class KLineEdit;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class GotoDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ GotoDialog( View* parent, const char* name);
+
+public slots:
+ void slotOk();
+ void textChanged ( const QString &_text );
+
+
+protected:
+ View* m_pView;
+ KLineEdit* m_nameCell;
+};
+
+} //
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_insert.cc b/kspread/dialogs/kspread_dlg_insert.cc
new file mode 100644
index 00000000..3685c1a6
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_insert.cc
@@ -0,0 +1,148 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2000-2001 Werner Trobin <trobin@kde.org>
+ (C) 2000 David Faure <faure@kde.org>
+ (C) 1999 Stephan Kulow <coolo@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+#include <qlayout.h>
+
+#include <kbuttonbox.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "kspread_doc.h"
+#include "kspread_sheet.h"
+#include "kspread_view.h"
+
+#include "kspread_dlg_insert.h"
+
+using namespace KSpread;
+
+InsertDialog::InsertDialog( View* parent, const char* name,const QRect &_rect,Mode _mode)
+ : KDialogBase( parent, name, TRUE,"",Ok|Cancel )
+{
+ m_pView = parent;
+ rect=_rect;
+ insRem=_mode;
+
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+ QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
+
+ QButtonGroup *grp = new QButtonGroup( 1, QGroupBox::Horizontal, i18n("Insert"),page);
+ grp->setRadioButtonExclusive( TRUE );
+ grp->layout();
+ lay1->addWidget(grp);
+ if( insRem==Insert)
+ {
+ rb1 = new QRadioButton( i18n("Move towards right"), grp );
+ rb2 = new QRadioButton( i18n("Move towards bottom"), grp );
+ rb3 = new QRadioButton( i18n("Insert rows"), grp );
+ rb4 = new QRadioButton( i18n("Insert columns"), grp );
+ setCaption( i18n("Insert Cells") );
+ }
+ else if(insRem==Remove)
+ {
+ grp->setTitle(i18n("Remove"));
+ rb1 = new QRadioButton( i18n("Move towards left"), grp );
+ rb2 = new QRadioButton( i18n("Move towards top"), grp );
+ rb3 = new QRadioButton( i18n("Remove rows"), grp );
+ rb4 = new QRadioButton( i18n("Remove columns"), grp );
+ setCaption( i18n("Remove Cells") );
+ }
+ else
+ kdDebug(36001) << "Error in kspread_dlg_InsertDialog" << endl;
+
+ rb1->setChecked(true);
+
+
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+}
+
+void InsertDialog::slotOk()
+{
+ m_pView->doc()->emitBeginOperation( false );
+ if( rb1->isChecked() )
+ {
+ if( insRem == Insert )
+ {
+ if ( !m_pView->activeSheet()->shiftRow( rect ) )
+ KMessageBox::error( this, i18n("The row is full. Cannot move cells to the right.") );
+ }
+ else if( insRem == Remove )
+ {
+ m_pView->activeSheet()->unshiftRow(rect);
+ }
+ }
+ else if( rb2->isChecked() )
+ {
+ if( insRem == Insert )
+ {
+ if ( !m_pView->activeSheet()->shiftColumn( rect ) )
+ KMessageBox::error( this, i18n("The column is full. Cannot move cells towards the bottom.") );
+ }
+ else if( insRem == Remove )
+ {
+ m_pView->activeSheet()->unshiftColumn( rect );
+ }
+ }
+ else if( rb3->isChecked() )
+ {
+ if( insRem == Insert )
+ {
+ if ( !m_pView->activeSheet()->insertRow( rect.top(),(rect.bottom()-rect.top() ) ) )
+ KMessageBox::error( this, i18n("The row is full. Cannot move cells to the right.") );
+ }
+ else if( insRem == Remove )
+ {
+ m_pView->activeSheet()->removeRow( rect.top(),(rect.bottom()-rect.top() ) );
+ }
+ }
+ else if( rb4->isChecked() )
+ {
+ if( insRem == Insert )
+ {
+ if ( !m_pView->activeSheet()->insertColumn( rect.left(),(rect.right()-rect.left() )) )
+ KMessageBox::error( this, i18n("The column is full. Cannot move cells towards the bottom.") );
+ }
+ else if( insRem == Remove )
+ {
+ m_pView->activeSheet()->removeColumn( rect.left(),(rect.right()-rect.left() ) );
+ }
+ }
+ else
+ {
+ kdDebug(36001) << "Error in kspread_dlg_InsertDialog" << endl;
+ }
+
+ m_pView->updateEditWidget();
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+#include "kspread_dlg_insert.moc"
diff --git a/kspread/dialogs/kspread_dlg_insert.h b/kspread/dialogs/kspread_dlg_insert.h
new file mode 100644
index 00000000..29fa4e22
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_insert.h
@@ -0,0 +1,65 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2000-2001 Werner Trobin <trobin@kde.org>
+ (C) 2000 David Faure <faure@kde.org>
+ (C) 1999 Stephan Kulow <coolo@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_insert__
+#define __kspread_dlg_insert__
+
+#include <kdialogbase.h>
+
+class QCheckBox;
+class QRadioButton;
+class QRect;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class InsertDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ enum Mode { Insert, Remove };
+
+ InsertDialog( View* parent, const char* name, const QRect &_rect, Mode _mode );
+
+public slots:
+ void slotOk();
+
+private:
+ View* m_pView;
+
+ QRadioButton *rb1;
+ QRadioButton *rb2;
+ QRadioButton *rb3;
+ QRadioButton *rb4;
+ QRect rect;
+ Mode insRem;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_layout.cc b/kspread/dialogs/kspread_dlg_layout.cc
new file mode 100644
index 00000000..e86e3271
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_layout.cc
@@ -0,0 +1,3928 @@
+/* This file is part of the KDE project
+ Copyright (C) 2006 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
+ (C) 2004 Tomas Mecir <mecirt@gmail.com>
+ (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2001-2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 1999-2002 Harri Porten <porten@kde.org>
+ (C) 2000-2001 David Faure <faure@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+ (C) 2000 Werner Trobin <trobin@kde.org>
+ (C) 1999 Reginald Stadlbauer <reggie@kde.org>
+ (C) 1998-1999 Stephan Kulow <coolo@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <stdlib.h>
+#include <math.h>
+
+#include <qbitmap.h>
+#include <qcheckbox.h>
+#include <qframe.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlistbox.h>
+#include <qfontdatabase.h>
+#include <qradiobutton.h>
+#include <qslider.h>
+#include <qwhatsthis.h>
+
+#include <kcolorbutton.h>
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <klineedit.h>
+#include <kmessagebox.h>
+#include <knumvalidator.h>
+
+#include <KoUnitWidgets.h>
+
+#include "kspread_canvas.h"
+#include "kspread_dlg_layout.h"
+#include "kspread_locale.h"
+#include "kspread_sheet.h"
+#include "kspread_style.h"
+#include "kspread_style_manager.h"
+#include "kspread_undo.h"
+#include "kspread_util.h"
+#include "manipulator.h"
+#include "selection.h"
+#include "valueformatter.h"
+
+using namespace KSpread;
+
+/***************************************************************************
+ *
+ * PatternSelect
+ *
+ ***************************************************************************/
+
+PatternSelect::PatternSelect( QWidget *parent, const char * )
+ : QFrame( parent )
+{
+ penStyle = NoPen;
+ penWidth = 1;
+ penColor = colorGroup().text();
+ selected = false;
+ undefined = false;
+}
+
+void PatternSelect::setPattern( const QColor &_color, int _width, PenStyle _style )
+{
+ penStyle = _style;
+ penColor = _color;
+ penWidth = _width;
+ repaint();
+}
+
+void PatternSelect::setUndefined()
+{
+ undefined = true;
+}
+
+void PatternSelect::paintEvent( QPaintEvent *_ev )
+{
+ QFrame::paintEvent( _ev );
+
+ QPainter painter( this );
+
+ if ( !undefined )
+ {
+ QPen pen( penColor, penWidth, penStyle);
+ painter.setPen( pen );
+ painter.drawLine( 6, height()/2, width() - 6,height()/2 );
+ }
+ else
+ {
+ painter.fillRect( 2, 2, width() - 4, height() - 4, BDiagPattern );
+ }
+}
+
+void PatternSelect::mousePressEvent( QMouseEvent * )
+{
+ slotSelect();
+
+ emit clicked( this );
+}
+
+void PatternSelect::slotUnselect()
+{
+ selected = false;
+
+ setLineWidth( 1 );
+ setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ repaint();
+}
+
+void PatternSelect::slotSelect()
+{
+ selected = true;
+
+ setLineWidth( 2 );
+ setFrameStyle( QFrame::Panel | QFrame::Plain );
+ repaint();
+}
+
+
+
+/***************************************************************************
+ *
+ * GeneralTab
+ *
+ ***************************************************************************/
+
+GeneralTab::GeneralTab( QWidget* parent, CellFormatDialog * dlg )
+ : QWidget( parent ),
+ m_dlg( dlg )
+{
+ QGridLayout * layout = new QGridLayout( this, 1, 1, KDialog::marginHint(), KDialog::spacingHint(), "layout");
+
+ QGroupBox * groupBox = new QGroupBox( this, "groupBox1" );
+ groupBox->setColumnLayout(0, Qt::Vertical );
+ groupBox->setTitle( i18n( "Style" ) );
+ groupBox->layout()->setSpacing( KDialog::spacingHint() );
+ groupBox->layout()->setMargin( KDialog::marginHint() );
+
+ QGridLayout * groupBoxLayout = new QGridLayout( groupBox->layout() );
+ groupBoxLayout->setAlignment( Qt::AlignTop );
+
+ QLabel * label1 = new QLabel( groupBox, "label1" );
+ label1->setText( i18n( "Name:" ) );
+ groupBoxLayout->addWidget( label1, 0, 0 );
+
+ m_nameEdit = new KLineEdit( groupBox, "m_nameEdit" );
+ m_nameEdit->setText( m_dlg->styleName );
+ groupBoxLayout->addWidget( m_nameEdit, 0, 1 );
+
+ QLabel * label2 = new QLabel( groupBox, "label2" );
+ label2->setText( i18n( "Inherit style:" ) );
+ groupBoxLayout->addWidget( label2, 1, 0 );
+
+ m_parentBox = new KComboBox( false, groupBox, "m_parentBox" );
+ m_parentBox->clear();
+ m_parentBox->insertItem( i18n( "<None>" ) );
+ QStringList tmp = m_dlg->getStyleManager()->styleNames();
+ tmp.remove( m_dlg->styleName );
+ m_parentBox->insertStringList( tmp );
+
+ if ( m_dlg->getStyle()->parent() )
+ m_parentBox->setCurrentText( m_dlg->getStyle()->parentName() );
+ else
+ {
+ m_parentBox->setCurrentText( i18n( "<None>" ) );
+
+ if ( m_dlg->getStyle()->definesAll() )
+ m_parentBox->setEnabled( false );
+ }
+
+ connect( m_parentBox, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotNewParent( const QString & ) ) );
+ connect( m_nameEdit, SIGNAL( lostFocus() ), this, SLOT( slotNameChanged() ) );
+
+ groupBoxLayout->addWidget( m_parentBox, 1, 1 );
+
+ QSpacerItem * spacer = new QSpacerItem( 20, 260, QSizePolicy::Minimum, QSizePolicy::Expanding );
+
+ layout->addWidget( groupBox, 0, 0 );
+ layout->addItem( spacer, 1, 0 );
+
+ if ( m_dlg->getStyle()->type() == Style::BUILTIN )
+ {
+ m_nameEdit->setEnabled( false );
+ m_parentBox->setEnabled( false );
+ }
+
+ resize( QSize( 534, 447 ).expandedTo(minimumSizeHint()) );
+}
+
+GeneralTab::~GeneralTab()
+{
+}
+
+void GeneralTab::slotNameChanged()
+{
+ checkName();
+}
+
+void GeneralTab::slotNewParent( const QString & parentName )
+{
+ kdDebug() << "New Parent" << endl;
+ if ( !checkParent( parentName ) )
+ return;
+
+ if ( parentName.isEmpty() || parentName == i18n( "<None>" ) )
+ m_dlg->getStyle()->setParent( 0 );
+ else
+ m_dlg->getStyle()->setParent( m_dlg->getStyleManager()->style( parentName ) );
+
+ // Set difference to new parent, set GUI to parent values, add changes made before
+ // m_dlg->initGUI();
+}
+
+bool GeneralTab::checkName()
+{
+ if ( m_nameEdit->isEnabled() )
+ {
+ if ( !m_dlg->getStyleManager()->validateStyleName( m_nameEdit->text(), m_dlg->getStyle() ) )
+ {
+ KMessageBox::sorry( this, i18n( "A style with this name already exists." ) );
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool GeneralTab::checkParent( const QString & parentName )
+{
+ if ( m_dlg->getStyle()->parentName() != parentName
+ && m_parentBox->isEnabled() && parentName != i18n( "<None>" ) && !parentName.isEmpty() )
+ {
+ if ( m_nameEdit->text() == parentName )
+ {
+ KMessageBox::sorry( this, i18n( "A style cannot inherit from itself." ) );
+ return false;
+ }
+ if ( !m_dlg->checkCircle( m_nameEdit->text(), parentName ) )
+ {
+ KMessageBox::sorry( this,
+ i18n( "The style cannot inherit from '%1' because of recursive references." )
+ .arg( m_parentBox->currentText() ) );
+ return false;
+ }
+
+ CustomStyle * p = m_dlg->getStyleManager()->style( parentName );
+
+ if ( !p )
+ {
+ KMessageBox::sorry( this, i18n( "The parent style does not exist." ) );
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool GeneralTab::apply( CustomStyle * style )
+{
+ if ( !checkParent( m_parentBox->currentText() ) )
+ return false;
+
+ if ( !checkName() )
+ return false;
+
+ if ( m_nameEdit->isEnabled() )
+ {
+ if ( style->type() != Style::BUILTIN )
+ {
+ QString name( style->name() );
+ style->setName( m_nameEdit->text() );
+ if ( m_parentBox->isEnabled() )
+ {
+ if ( m_parentBox->currentText() == i18n( "None" ) || m_parentBox->currentText().isEmpty() )
+ style->setParent( 0 );
+ else
+ style->setParent( m_dlg->getStyleManager()->style( m_parentBox->currentText() ) );
+ }
+ m_dlg->getStyleManager()->changeName( name, m_nameEdit->text() );
+ }
+ }
+
+ if ( style->type() == Style::TENTATIVE )
+ style->setType( Style::CUSTOM );
+
+ return true;
+}
+
+
+
+/***************************************************************************
+ *
+ * CellFormatDialog
+ *
+ ***************************************************************************/
+
+CellFormatDialog::CellFormatDialog( View * _view, Sheet * _sheet )
+ : QObject(),
+ m_doc( _sheet->doc() ),
+ m_sheet( _sheet ),
+ m_pView( _view ),
+ m_style( 0 )
+{
+ initMembers();
+
+ //We need both conditions quite often, so store the condition here too
+ isRowSelected = _view->selectionInfo()->isRowSelected();
+ isColumnSelected = _view->selectionInfo()->isColumnSelected();
+
+ QRect range = _view->selectionInfo()->selection();
+ left = range.left();
+ top = range.top();
+ right = range.right();
+ bottom = range.bottom();
+
+ if ( left == right )
+ oneCol = true;
+ else
+ oneCol = false;
+
+ if ( top == bottom )
+ oneRow = true;
+ else
+ oneRow = false;
+
+ Cell* obj = m_sheet->cellAt( left, top );
+ oneCell = (left == right && top == bottom &&
+ !obj->doesMergeCells());
+
+ isMerged = ((obj->doesMergeCells() &&
+ left + obj->extraXCells() >= right &&
+ top + obj->extraYCells() >= bottom));
+
+ // Initialize with the upper left object.
+ borders[BorderType_Left].style = obj->format()->leftBorderStyle( left, top );
+ borders[BorderType_Left].width = obj->format()->leftBorderWidth( left, top );
+ borders[BorderType_Left].color = obj->format()->leftBorderColor( left, top );
+ borders[BorderType_Top].style = obj->format()->topBorderStyle( left, top );
+ borders[BorderType_Top].width = obj->format()->topBorderWidth( left, top );
+ borders[BorderType_Top].color = obj->format()->topBorderColor( left, top );
+ borders[BorderType_FallingDiagonal].style =
+ obj->format()->fallDiagonalStyle( left, top );
+ borders[BorderType_FallingDiagonal].width =
+ obj->format()->fallDiagonalWidth( left, top );
+ borders[BorderType_FallingDiagonal].color =
+ obj->format()->fallDiagonalColor( left, top );
+ borders[BorderType_RisingDiagonal].style =
+ obj->format()->goUpDiagonalStyle( left, top );
+ borders[BorderType_RisingDiagonal].width =
+ obj->format()->goUpDiagonalWidth( left, top );
+ borders[BorderType_RisingDiagonal].color =
+ obj->format()->goUpDiagonalColor( left, top );
+
+ // Look at the upper right one for the right border.
+ obj = m_sheet->cellAt( right, top );
+ borders[BorderType_Right].style = obj->format()->rightBorderStyle( right, top );
+ borders[BorderType_Right].width = obj->format()->rightBorderWidth( right, top );
+ borders[BorderType_Right].color = obj->format()->rightBorderColor( right, top );
+
+ // Look at the bottom left cell for the bottom border.
+ obj = m_sheet->cellAt( left, bottom );
+ borders[BorderType_Bottom].style = obj->format()->bottomBorderStyle( left, bottom );
+ borders[BorderType_Bottom].width = obj->format()->bottomBorderWidth( left, bottom );
+ borders[BorderType_Bottom].color = obj->format()->bottomBorderColor( left, bottom );
+
+ // Just an assumption
+ obj = m_sheet->cellAt( right, top );
+ if ( obj->isPartOfMerged() )
+ {
+ obj = obj->obscuringCells().first();
+ int moveX = obj->column();
+ int moveY = top;
+ int moveX2 = right;
+ int moveY2 = obj->row();
+ borders[BorderType_Vertical].style = obj->format()->leftBorderStyle( moveX, moveY );
+ borders[BorderType_Vertical].width = obj->format()->leftBorderWidth( moveX, moveY );
+ borders[BorderType_Vertical].color = obj->format()->leftBorderColor( moveX, moveY );
+
+ obj = m_sheet->cellAt( moveX2, moveY2 );
+ borders[BorderType_Horizontal].style = obj->format()->topBorderStyle( moveX2, moveY2 );
+ borders[BorderType_Horizontal].width = obj->format()->topBorderWidth( moveX2, moveY2 );
+ borders[BorderType_Horizontal].color = obj->format()->topBorderColor( moveX2, moveY2 );
+ }
+ else
+ {
+ borders[BorderType_Vertical].style = obj->format()->leftBorderStyle( right, top );
+ borders[BorderType_Vertical].width = obj->format()->leftBorderWidth( right, top );
+ borders[BorderType_Vertical].color = obj->format()->leftBorderColor( right, top );
+ borders[BorderType_Horizontal].style = obj->format()->topBorderStyle(right, bottom);
+ borders[BorderType_Horizontal].width = obj->format()->topBorderWidth(right, bottom);
+ borders[BorderType_Horizontal].color = obj->format()->topBorderColor(right, bottom);
+ }
+
+ obj = m_sheet->cellAt( left, top );
+ prefix = obj->format()->prefix( left, top );
+ postfix = obj->format()->postfix( left, top );
+ precision = obj->format()->precision( left, top );
+ floatFormat = obj->format()->floatFormat( left, top );
+ floatColor = obj->format()->floatColor( left, top );
+ alignX = obj->format()->align( left, top );
+ alignY = obj->format()->alignY( left, top );
+ textColor = obj->format()->textColor( left, top );
+ bgColor = obj->bgColor( left, top );
+ textFontSize = obj->format()->textFontSize( left, top );
+ textFontFamily = obj->format()->textFontFamily( left, top );
+ textFontBold = obj->format()->textFontBold( left, top );
+ textFontItalic = obj->format()->textFontItalic( left, top );
+ strike=obj->format()->textFontStrike( left, top );
+ underline = obj->format()->textFontUnderline( left, top );
+ // Needed to initialize the font correctly ( bug in Qt )
+ textFont = obj->format()->textFont( left, top );
+ obj->format()->currencyInfo( cCurrency );
+
+ brushColor = obj->format()->backGroundBrushColor( left, top );
+ brushStyle = obj->format()->backGroundBrushStyle( left,top );
+
+ bMultiRow = obj->format()->multiRow( left, top );
+ bVerticalText = obj->format()->verticalText( left, top );
+ textRotation = obj->format()->getAngle(left, top);
+ formatType = obj->format()->getFormatType(left, top);
+
+ bDontPrintText = obj->format()->getDontprintText( left, top );
+ bHideFormula = obj->format()->isHideFormula( left, top );
+ bHideAll = obj->format()->isHideAll( left, top );
+ bIsProtected = !obj->format()->notProtected( left, top );
+
+ indent = obj->format()->getIndent(left, top);
+
+ value = obj->value();
+
+ RowFormat *rl;
+ ColumnFormat *cl;
+ widthSize = 0.0;
+ heightSize = 0.0;
+
+ if ( !isRowSelected )
+ {
+ for ( int x = left; x <= right; x++ )
+ {
+ cl = m_pView->activeSheet()->columnFormat( x );
+ widthSize = QMAX( cl->dblWidth(), widthSize );
+ }
+ }
+
+ if ( !isColumnSelected )
+ {
+ for ( int y = top; y <= bottom; y++ )
+ {
+ rl = m_pView->activeSheet()->rowFormat(y);
+ heightSize = QMAX( rl->dblHeight(), heightSize );
+ }
+ }
+
+ //select column(s)
+ if ( isColumnSelected )
+ {
+ int y = 1;
+ Cell* cell = NULL;
+ for (int x = left;x <= right; x++)
+ {
+ ColumnFormat *obj = m_sheet->nonDefaultColumnFormat(x);
+ initParameters( obj,x,y);
+
+ for (cell = m_sheet->getFirstCellColumn(x); cell != NULL;
+ cell = m_sheet->getNextCellDown(cell->column(), cell->row()))
+ {
+ initParameters( cell->format(), x, cell->row());
+ }
+ }
+
+ }
+ else if ( isRowSelected )
+ {
+ int x = 1;
+ Cell* c = NULL;
+ for ( int y = top;y<=bottom;y++)
+ {
+ RowFormat *obj = m_sheet->nonDefaultRowFormat(y);
+ initParameters( obj,x,y);
+
+ for (c = m_sheet->getFirstCellRow(y); c != NULL;
+ c = m_sheet->getNextCellRight(c->column(), c->row()) )
+ {
+ initParameters( c->format(), c->column(), c->row());
+ }
+ }
+ }
+ else
+ {
+ // Do the other objects have the same values ?
+ for ( int x = left; x <= right; x++ )
+ {
+ for ( int y = top; y <= bottom; y++ )
+ {
+ Cell *obj = m_sheet->cellAt( x, y );
+
+ if ( obj->isPartOfMerged() )
+ continue;
+
+ initParameters( obj->format(),x,y);
+ }
+ }
+ }
+ if ( !bTextRotation )
+ textRotation = 0;
+
+ if ( isColumnSelected )
+ {
+ int y=1;
+ ColumnFormat *obj=m_sheet->nonDefaultColumnFormat(left);
+ checkBorderLeft( obj,left, y);
+
+ Cell* c = NULL;
+ for (c = m_sheet->getFirstCellColumn(left); c != NULL;
+ c = m_sheet->getNextCellDown(c->column(), c->row()) )
+ {
+ checkBorderLeft(c->format(), c->column(), c->row());
+ }
+
+
+ obj=m_sheet->nonDefaultColumnFormat(right);
+ checkBorderRight(obj,right,y);
+ c = NULL;
+ for (c = m_sheet->getFirstCellColumn(right); c != NULL;
+ c = m_sheet->getNextCellDown(c->column(), c->row()) )
+ {
+ checkBorderRight(c->format(), c->column(), c->row());
+ }
+
+ for ( int x = left; x <= right; x++ )
+ {
+ Cell *obj = m_sheet->cellAt( x, top );
+ checkBorderTop(obj->format(),x, top);
+ obj = m_sheet->cellAt( x, bottom );
+ checkBorderBottom(obj->format(),x, bottom);
+ if ( x > left )
+ {
+ ColumnFormat *obj = m_sheet->nonDefaultColumnFormat(x);
+ checkBorderHorizontal(obj,x, y);
+ checkBorderVertical(obj,x, y);
+ }
+ }
+ }
+ else if ( isRowSelected )
+ {
+ int x=1;
+ for ( int y = top; y <= bottom; y++ )
+ {
+ Cell *obj = m_sheet->cellAt( right, y );
+ checkBorderRight(obj->format(),right,y);
+ obj = m_sheet->cellAt( left, y );
+ checkBorderLeft( obj->format(),left, y);
+ if ( y > top )
+ {
+ RowFormat* obj = m_sheet->nonDefaultRowFormat(y);
+ checkBorderHorizontal(obj,x, y);
+ checkBorderVertical(obj,x, y);
+ }
+ }
+
+ RowFormat *obj=m_sheet->nonDefaultRowFormat(top);
+ checkBorderTop(obj,x, top);
+ obj=m_sheet->nonDefaultRowFormat(bottom);
+ checkBorderBottom(obj,x, bottom);
+ }
+ else
+ {
+ for ( int y = top; y <= bottom; y++ )
+ {
+ Cell *obj = m_sheet->cellAt( left, y );
+ checkBorderLeft( obj->format(),left, y);
+ obj = m_sheet->cellAt( right, y );
+ checkBorderRight(obj->format(),right,y);
+ }
+
+ for ( int x = left; x <= right; x++ )
+ {
+ Cell *obj = m_sheet->cellAt( x, top );
+ checkBorderTop( obj->format(), x, top );
+ obj = m_sheet->cellAt( x, bottom );
+ checkBorderBottom( obj->format(), x, bottom );
+ }
+
+ // Look for the Outline
+ for ( int x = left; x <= right; x++ )
+ {
+ for ( int y = top+1; y <= bottom; y++ )
+ {
+ Cell *obj = m_sheet->cellAt( x, y );
+ checkBorderHorizontal(obj->format(),x, y);
+ }
+ }
+
+ for ( int x = left+1; x <= right; x++ )
+ {
+ for ( int y = top; y <= bottom; y++ )
+ {
+ Cell *obj = m_sheet->cellAt( x, y );
+ checkBorderVertical(obj->format(),x,y);
+ }
+ }
+ }
+
+ init();
+}
+
+CellFormatDialog::CellFormatDialog( View * _view, CustomStyle * _style,
+ StyleManager * _manager, Doc * doc )
+ : QObject(),
+ m_doc( doc ),
+ m_sheet( 0 ),
+ m_pView( _view ),
+ m_style( _style ),
+ m_styleManager( _manager )
+{
+ initMembers();
+ initGUI();
+ init();
+}
+
+void CellFormatDialog::initGUI()
+{
+ isRowSelected = false;
+ isColumnSelected = false;
+ styleName = m_style->name();
+
+ borders[BorderType_Left].style = m_style->leftBorderPen().style();
+ borders[BorderType_Left].width = m_style->leftBorderPen().width();
+ borders[BorderType_Left].color = m_style->leftBorderPen().color();
+
+ borders[BorderType_Top].style = m_style->topBorderPen().style();
+ borders[BorderType_Top].width = m_style->topBorderPen().width();
+ borders[BorderType_Top].color = m_style->topBorderPen().color();
+
+ borders[BorderType_Right].style = m_style->rightBorderPen().style();
+ borders[BorderType_Right].width = m_style->rightBorderPen().width();
+ borders[BorderType_Right].color = m_style->rightBorderPen().color();
+
+ borders[BorderType_Bottom].style = m_style->bottomBorderPen().style();
+ borders[BorderType_Bottom].width = m_style->bottomBorderPen().width();
+ borders[BorderType_Bottom].color = m_style->bottomBorderPen().color();
+
+ borders[BorderType_FallingDiagonal].style = m_style->fallDiagonalPen().style();
+ borders[BorderType_FallingDiagonal].width = m_style->fallDiagonalPen().width();
+ borders[BorderType_FallingDiagonal].color = m_style->fallDiagonalPen().color();
+
+ borders[BorderType_RisingDiagonal].style = m_style->goUpDiagonalPen().style();
+ borders[BorderType_RisingDiagonal].width = m_style->goUpDiagonalPen().width();
+ borders[BorderType_RisingDiagonal].color = m_style->goUpDiagonalPen().color();
+
+ borders[BorderType_Vertical].style = m_style->leftBorderPen().style();
+ borders[BorderType_Vertical].width = m_style->leftBorderPen().width();
+ borders[BorderType_Vertical].color = m_style->leftBorderPen().color();
+ borders[BorderType_Horizontal].style = m_style->topBorderPen().style();
+ borders[BorderType_Horizontal].width = m_style->topBorderPen().width();
+ borders[BorderType_Horizontal].color = m_style->topBorderPen().color();
+
+ prefix = m_style->prefix();
+ postfix = m_style->postfix();
+ precision = m_style->precision();
+ floatFormat = m_style->floatFormat();
+ floatColor = m_style->floatColor();
+ alignX = m_style->alignX();
+ alignY = m_style->alignY();
+ textColor = m_style->pen().color();
+ bgColor = m_style->bgColor();
+ textFontSize = m_style->fontSize();
+ textFontFamily = m_style->fontFamily();
+
+ uint flags = m_style->fontFlags();
+ textFontBold = ( flags & (uint) Style::FBold );
+ textFontItalic = ( flags & (uint) Style::FItalic );
+ strike = ( flags & (uint) Style::FStrike );
+ underline = ( flags & (uint) Style::FUnderline );
+
+ // Needed to initialize the font correctly ( bug in Qt )
+ textFont = m_style->font();
+ cCurrency = m_style->currency();
+ brushColor = m_style->backGroundBrush().color();
+ brushStyle = m_style->backGroundBrush().style();
+
+ bMultiRow = m_style->hasProperty( Style::PMultiRow );
+ bVerticalText = m_style->hasProperty( Style::PVerticalText );
+ textRotation = m_style->rotateAngle();
+ formatType = m_style->formatType();
+ indent = m_style->indent();
+
+ bDontPrintText = m_style->hasProperty( Style::PDontPrintText );
+ bHideFormula = m_style->hasProperty( Style::PHideFormula );
+ bHideAll = m_style->hasProperty( Style::PHideAll );
+ bIsProtected = !m_style->hasProperty( Style::PNotProtected );
+
+ widthSize = defaultWidthSize;
+ heightSize = defaultHeightSize;
+}
+
+CellFormatDialog::~CellFormatDialog()
+{
+ delete formatOnlyNegSignedPixmap;
+ delete formatRedOnlyNegSignedPixmap;
+ delete formatRedNeverSignedPixmap;
+ delete formatAlwaysSignedPixmap;
+ delete formatRedAlwaysSignedPixmap;
+}
+
+void CellFormatDialog::initMembers()
+{
+ formatOnlyNegSignedPixmap = 0L;
+ formatRedOnlyNegSignedPixmap = 0L;
+ formatRedNeverSignedPixmap = 0L;
+ formatAlwaysSignedPixmap = 0L;
+ formatRedAlwaysSignedPixmap = 0L;
+
+ // We assume, that all other objects have the same values
+ for ( int i = 0; i < BorderType_END; ++i )
+ {
+ borders[i].bStyle = true;
+ borders[i].bColor = true;
+ }
+ bFloatFormat = true;
+ bFloatColor = true;
+ bTextColor = true;
+ bBgColor = true;
+ bTextFontFamily = true;
+ bTextFontSize = true;
+ bTextFontBold = true;
+ bTextFontItalic = true;
+ bStrike = true;
+ bUnderline = true;
+ bTextRotation = true;
+ bFormatType = true;
+ bCurrency = true;
+ bDontPrintText = false;
+ bHideFormula = false;
+ bHideAll = false;
+ bIsProtected = true;
+
+ cCurrency.symbol = locale()->currencySymbol();
+ cCurrency.type = 0;
+
+ Sheet* sheet = m_pView->activeSheet();
+ defaultWidthSize = sheet ? sheet->columnFormat(0)->dblWidth() : 0;
+ defaultHeightSize = sheet ? sheet->rowFormat(0)->dblHeight() : 0;
+}
+
+bool CellFormatDialog::checkCircle( QString const & name, QString const & parent )
+{
+ return m_styleManager->checkCircle( name, parent );
+}
+
+void CellFormatDialog::checkBorderRight(Format *obj,int x,int y)
+{
+ if ( borders[BorderType_Right].style != obj->rightBorderStyle( x, y ) ||
+ borders[BorderType_Right].width != obj->rightBorderWidth( x, y ) )
+ borders[BorderType_Right].bStyle = false;
+ if ( borders[BorderType_Right].color != obj->rightBorderColor( x, y ) )
+ borders[BorderType_Right].bColor = false;
+}
+
+void CellFormatDialog::checkBorderLeft(Format *obj,int x,int y)
+{
+ if ( borders[BorderType_Left].style != obj->leftBorderStyle( x, y ) ||
+ borders[BorderType_Left].width != obj->leftBorderWidth( x, y ) )
+ borders[BorderType_Left].bStyle = false;
+ if ( borders[BorderType_Left].color != obj->leftBorderColor( x, y ) )
+ borders[BorderType_Left].bColor = false;
+}
+
+void CellFormatDialog::checkBorderTop(Format *obj,int x,int y)
+{
+ if ( borders[BorderType_Top].style != obj->topBorderStyle( x, y ) ||
+ borders[BorderType_Top].width != obj->topBorderWidth( x, y ) )
+ borders[BorderType_Top].bStyle = false;
+ if ( borders[BorderType_Top].color != obj->topBorderColor( x, y ) )
+ borders[BorderType_Top].bColor = false;
+}
+
+void CellFormatDialog::checkBorderBottom(Format *obj,int x,int y)
+{
+ if ( borders[BorderType_Bottom].style != obj->bottomBorderStyle( x, y ) ||
+ borders[BorderType_Bottom].width != obj->bottomBorderWidth( x, y ) )
+ borders[BorderType_Bottom].bStyle = false;
+ if ( borders[BorderType_Bottom].color != obj->bottomBorderColor( x, y ) )
+ borders[BorderType_Bottom].bColor = false;
+}
+
+void CellFormatDialog::checkBorderVertical(Format *obj,int x,int y)
+{
+ if (borders[BorderType_Vertical].style != obj->leftBorderStyle( x, y ) ||
+ borders[BorderType_Vertical].width != obj->leftBorderWidth( x, y ))
+ borders[BorderType_Vertical].bStyle = false;
+ if ( borders[BorderType_Vertical].color != obj->leftBorderColor( x, y ) )
+ borders[BorderType_Vertical].bColor = false;
+}
+
+void CellFormatDialog::checkBorderHorizontal(Format *obj,int x,int y)
+{
+ if ( borders[BorderType_Horizontal].style != obj->topBorderStyle( x, y ) ||
+ borders[BorderType_Horizontal].width != obj->topBorderWidth( x, y ) )
+ borders[BorderType_Horizontal].bStyle = false;
+ if ( borders[BorderType_Horizontal].color != obj->topBorderColor( x, y ) )
+ borders[BorderType_Horizontal].bColor = false;
+}
+
+
+void CellFormatDialog::initParameters(Format *obj,int x,int y)
+{
+ if (borders[BorderType_FallingDiagonal].style != obj->fallDiagonalStyle( x, y ))
+ borders[BorderType_FallingDiagonal].bStyle = false;
+ if (borders[BorderType_FallingDiagonal].width != obj->fallDiagonalWidth( x, y ))
+ borders[BorderType_FallingDiagonal].bStyle = false;
+ if (borders[BorderType_FallingDiagonal].color != obj->fallDiagonalColor( x, y ))
+ borders[BorderType_FallingDiagonal].bColor = false;
+
+ if (borders[BorderType_RisingDiagonal].style != obj->goUpDiagonalStyle( x, y ))
+ borders[BorderType_RisingDiagonal].bStyle = false;
+ if (borders[BorderType_RisingDiagonal].width != obj->goUpDiagonalWidth( x, y ))
+ borders[BorderType_RisingDiagonal].bStyle = false;
+ if (borders[BorderType_RisingDiagonal].color != obj->goUpDiagonalColor( x, y ))
+ borders[BorderType_RisingDiagonal].bColor = false;
+ if ( strike != obj->textFontStrike( x, y ) )
+ bStrike = false;
+ if ( underline != obj->textFontUnderline( x, y ) )
+ bUnderline = false;
+ if ( prefix != obj->prefix( x, y ) )
+ prefix = QString::null;
+ if ( postfix != obj->postfix( x, y ) )
+ postfix = QString::null;
+ if ( floatFormat != obj->floatFormat( x, y ) )
+ bFloatFormat = false;
+ if ( floatColor != obj->floatColor( x, y ) )
+ bFloatColor = false;
+ if ( textColor != obj->textColor( x, y ) )
+ bTextColor = false;
+ if ( textFontFamily != obj->textFontFamily( x, y ) )
+ bTextFontFamily = false;
+ if ( textFontSize != obj->textFontSize( x, y ) )
+ bTextFontSize = false;
+ if ( textFontBold != obj->textFontBold( x, y ) )
+ bTextFontBold = false;
+ if ( textFontItalic != obj->textFontItalic( x, y ) )
+ bTextFontItalic = false;
+ if ( bgColor != obj->bgColor( x, y ) )
+ bBgColor = false;
+ if ( textRotation != obj->getAngle(left, top) )
+ bTextRotation = false;
+ if ( formatType != obj->getFormatType(left, top) )
+ bFormatType = false;
+ if ( bMultiRow != obj->multiRow( left, top ) )
+ bMultiRow = false;
+ if ( bVerticalText!=obj->verticalText( left, top ) )
+ bVerticalText = false;
+ if ( bDontPrintText!=obj->getDontprintText( left, top ) )
+ bDontPrintText= false;
+
+ Format::Currency cur;
+ if (!obj->currencyInfo(cur))
+ bCurrency = false;
+ else
+ if (cur.symbol != cCurrency.symbol)
+ bCurrency = false;
+}
+
+void CellFormatDialog::init()
+{
+ QColorGroup colorGroup = QApplication::palette().active();
+
+ // Did we initialize the bitmaps ?
+ if ( formatOnlyNegSignedPixmap == 0L )
+ {
+ QColor black = colorGroup.text(); // not necessarily black :)
+ formatOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", black );
+ formatRedOnlyNegSignedPixmap = paintFormatPixmap( "123.456", black, "-123.456", Qt::red );
+ formatRedNeverSignedPixmap = paintFormatPixmap( "123.456", black, "123.456", Qt::red );
+ formatAlwaysSignedPixmap = paintFormatPixmap( "+123.456", black, "-123.456", black );
+ formatRedAlwaysSignedPixmap = paintFormatPixmap( "+123.456", black, "-123.456", Qt::red );
+ }
+
+ tab = new QTabDialog( (QWidget*)m_pView, 0L, true );
+ //tab->setGeometry( tab->x(), tab->y(), 420, 400 );
+
+ if ( m_style )
+ {
+ generalPage = new GeneralTab( tab, this );
+ tab->addTab( generalPage, i18n( "&General" ) );
+ }
+
+ floatPage = new CellFormatPageFloat( tab, this );
+ tab->addTab( floatPage, i18n("&Data Format") );
+
+ fontPage = new CellFormatPageFont( tab, this );
+ tab->addTab( fontPage, i18n("&Font") );
+
+ // miscPage = new CellFormatPageMisc( tab, this );
+ // tab->addTab( miscPage, i18n("&Misc") );
+
+ positionPage = new CellFormatPagePosition( tab, this);
+ tab->addTab( positionPage, i18n("&Position") );
+
+ borderPage = new CellFormatPageBorder( tab, this );
+ tab->addTab( borderPage, i18n("&Border") );
+
+ patternPage=new CellFormatPagePattern(tab,this);
+ tab->addTab( patternPage,i18n("Back&ground"));
+
+ protectPage = new CellFormatPageProtection( tab, this );
+ tab->addTab( protectPage, i18n("&Cell Protection") );
+
+ tab->setCancelButton( i18n( "&Cancel" ) );
+ tab->setOkButton( i18n( "&OK" ) );
+
+ tab->setCaption( i18n( "Cell Format" ) );
+
+ tab->adjustSize();
+
+ connect( tab, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ) );
+
+ tab->exec();
+}
+
+QPixmap * CellFormatDialog::paintFormatPixmap( const char * _string1, const QColor & _color1,
+ const char *_string2, const QColor & _color2 )
+{
+ QPixmap * pixmap = new QPixmap( 150, 14 );
+
+ QPainter painter;
+ painter.begin( pixmap );
+ painter.fillRect( 0, 0, 150, 14, QApplication::palette().active().base() );
+ painter.setPen( _color1 );
+ painter.drawText( 2, 11, _string1 );
+ painter.setPen( _color2 );
+ painter.drawText( 75, 11, _string2 );
+ painter.end();
+
+ QBitmap bm( pixmap->size() );
+ bm.fill( color0 );
+ painter.begin( &bm );
+ painter.setPen( color1 );
+ painter.drawText( 2, 11, _string1 );
+ painter.drawText( 75, 11, _string2 );
+ painter.end();
+ pixmap->setMask( bm );
+
+ return pixmap;
+}
+
+int CellFormatDialog::exec()
+{
+ return ( tab->exec() );
+}
+
+void CellFormatDialog::applyStyle()
+{
+ generalPage->apply( m_style );
+
+ borderPage->apply(0);
+ floatPage->apply( m_style );
+ // miscPage->apply( m_style );
+ fontPage->apply( m_style );
+ positionPage->apply( m_style );
+ patternPage->apply( m_style );
+ protectPage->apply( m_style );
+ m_pView->refreshView();
+}
+
+void CellFormatDialog::slotApply()
+{
+ if ( m_style )
+ {
+ applyStyle();
+ return;
+ }
+
+ // (Tomas) TODO: this will be slow !!!
+ // We need to create a manipulator that would act as KMacroCommand,
+ // but which would also ensure that updates are not painted until everything
+ // is updated properly ...
+ KMacroCommand* macroCommand = new KMacroCommand( i18n("Change Format") );
+
+ if ( isMerged != positionPage->getMergedCellState() )
+ {
+ if ( positionPage->getMergedCellState() )
+ {
+ Manipulator* manipulator = new MergeManipulator();
+ manipulator->setSheet(m_pView->activeSheet());
+ manipulator->setRegisterUndo(false);
+ manipulator->add(*m_pView->selectionInfo());
+ macroCommand->addCommand( manipulator );
+ }
+ else
+ {
+ //dissociate cells
+ Manipulator* manipulator = new MergeManipulator();
+ manipulator->setSheet(m_pView->activeSheet());
+ manipulator->setReverse(true);
+ manipulator->setRegisterUndo(false);
+ manipulator->add(*m_pView->selectionInfo());
+ macroCommand->addCommand( manipulator );
+ }
+ }
+
+ FormatManipulator* manipulator = new FormatManipulator();
+ manipulator->setSheet(m_pView->activeSheet());
+ manipulator->setRegisterUndo(false);
+ manipulator->add(*m_pView->selectionInfo());
+ borderPage->apply(manipulator);
+ floatPage->apply(manipulator);
+ fontPage->apply(manipulator);
+ positionPage->apply(manipulator);
+ patternPage->apply(manipulator);
+ protectPage->apply(manipulator);
+
+ if (!manipulator->isEmpty())
+ {
+ macroCommand->addCommand( manipulator );
+ }
+ else
+ {
+ delete manipulator;
+ }
+
+ if ( int( positionPage->getSizeHeight() ) != int( heightSize ) )
+ {
+ ResizeRowManipulator* manipulator = new ResizeRowManipulator();
+ manipulator->setSheet(m_pView->activeSheet());
+ manipulator->setSize(positionPage->getSizeHeight());
+ // TODO Stefan:
+ manipulator->setOldSize(heightSize);
+ manipulator->add(*m_pView->selectionInfo());
+ macroCommand->addCommand( manipulator );
+ }
+ if ( int( positionPage->getSizeWidth() ) != int( widthSize ) )
+ {
+ ResizeColumnManipulator* manipulator = new ResizeColumnManipulator();
+ manipulator->setSheet(m_pView->activeSheet());
+ manipulator->setSize(positionPage->getSizeWidth());
+ // TODO Stefan:
+ manipulator->setOldSize(widthSize);
+ manipulator->add(*m_pView->selectionInfo());
+ macroCommand->addCommand( manipulator );
+ }
+
+ macroCommand->execute();
+ m_doc->addCommand( macroCommand );
+
+ // Update the toolbar (bold/italic/font...)
+ m_pView->updateEditWidget();
+}
+
+
+
+/***************************************************************************
+ *
+ * CellFormatPageFloat
+ *
+ ***************************************************************************/
+
+CellFormatPageFloat::CellFormatPageFloat( QWidget* parent, CellFormatDialog *_dlg )
+ : QWidget ( parent ),
+ dlg( _dlg )
+{
+ QVBoxLayout* layout = new QVBoxLayout( this, 6,10 );
+
+ QButtonGroup *grp = new QButtonGroup( i18n("Format"),this);
+ QGridLayout *grid = new QGridLayout(grp,11,2,KDialog::marginHint(), KDialog::spacingHint());
+
+ int fHeight = grp->fontMetrics().height();
+ grid->addRowSpacing( 0, fHeight/2 ); // groupbox title
+
+ grp->setRadioButtonExclusive( true );
+ generic=new QRadioButton(i18n("Generic"),grp);
+ QWhatsThis::add(generic, i18n( "This is the default format and KSpread autodetects the actual data type depending on the current cell data. By default, KSpread right justifies numbers, dates and times within a cell and left justifies anything else." ) );
+ grid->addWidget(generic,1,0);
+
+ number=new QRadioButton(i18n("Number"),grp);
+ QWhatsThis::add(number, i18n( "The number notation uses the notation you globally choose in KControl -> Regional & Accessibility -> Numbers tab. Numbers are right justified by default." ) );
+ grid->addWidget(number,2,0);
+
+ percent=new QRadioButton(i18n("Percent"),grp);
+ QWhatsThis::add(percent, i18n( "When you have a number in the current cell and you switch from the dcell format from Generic to Percent, the current cell number will be multiplied by 100%.\nFor example if you enter 12 and set the cell format to Percent, the number will then be 1,200 %. Switching back to Generic cell format will bring it back to 12.\nYou can also use the Percent icon in the Format Toolbar." ) );
+ grid->addWidget(percent,3,0);
+
+ money=new QRadioButton(i18n("Money"),grp);
+ QWhatsThis::add(money, i18n( "The Money format converts your number into money notation using the settings globally fixed in KControl in Regional & Accessibility -> Money. The currency symbol will be displayed and the precision will be the one set in KControl.\nYou can also use the Currency icon in the Format Toolbar to set the cell formatting to look like your current currency." ) );
+ grid->addWidget(money,4,0);
+
+ scientific=new QRadioButton(i18n("Scientific"),grp);
+ QWhatsThis::add(scientific, i18n( "The scientific format changes your number using the scientific notation. For example, 0.0012 will be changed to 1.2E-03. Going back using Generic cell format will display 0.0012 again." ) );
+ grid->addWidget(scientific,5,0);
+
+ fraction=new QRadioButton(i18n("Fraction"),grp);
+ QWhatsThis::add(fraction, i18n( "The fraction format changes your number into a fraction. For example, 0.1 can be changed to 1/8, 2/16, 1/10, etc. You define the type of fraction by choosing it in the field on the right. If the exact fraction is not possible in the fraction mode you choose, the nearest closest match is chosen.\n For example: when we have 1.5 as number, we choose Fraction and Sixteenths 1/16 the text displayed into cell is \"1 8/16\" which is an exact fraction. If you have 1.4 as number in your cell and you choose Fraction and Sixteenths 1/16 then the cell will display \"1 6/16\" which is the nearest closest Sixteenth fraction." ) );
+ grid->addWidget(fraction,6,0);
+
+ date=new QRadioButton(i18n("Date format"),grp);
+ QWhatsThis::add(date, i18n( "To enter a date, you should enter it in one of the formats set in KControl in Regional & Accessibility ->Time & Dates. There are two formats set here: the date format and the short date format.\nJust like you can drag down numbers you can also drag down dates and the next cells will also get dates." ) );
+ grid->addWidget(date,7,0);
+
+ time=new QRadioButton(i18n("Time format"),grp);
+ QWhatsThis::add(time, i18n( "This formats your cell content as a time. To enter a time, you should enter it in the Time format set in KControl in Regional & Accessibility ->Time & Dates. In the Cell Format dialog box you can set how the time should be displayed by choosing one of the available time format options. The default format is the system format set in KControl. When the number in the cell does not make sense as a time, KSpread will display 00:00 in the global format you have in KControl." ) );
+ grid->addWidget(time,8,0);
+
+ textFormat=new QRadioButton(i18n("Text"),grp);
+ QWhatsThis::add(textFormat, i18n( "This formats your cell content as text. This can be useful if you want a number treated as text instead as a number, for example for a ZIP code. Setting a number as text format will left justify it. When numbers are formatted as text, they cannot be used in calculations or formulas. It also change the way the cell is justified." ) );
+ grid->addWidget(textFormat,9,0);
+
+ customFormat=new QRadioButton(i18n("Custom"),grp);
+ QWhatsThis::add(customFormat, i18n( "The custom format does not work yet. To be enabled in the next release." ) );
+ grid->addWidget(customFormat,10,0);
+ customFormat->setEnabled( false );
+
+ QGroupBox *box2 = new QGroupBox( grp, "Box");
+ box2->setTitle(i18n("Preview"));
+ QGridLayout *grid3 = new QGridLayout(box2,1,3,KDialog::marginHint(), KDialog::spacingHint());
+
+ exampleLabel=new QLabel(box2);
+ QWhatsThis::add(exampleLabel, i18n( "This will display a preview of your choice so you can know what it does before clicking the OK button to validate it." ) );
+ grid3->addWidget(exampleLabel,0,1);
+
+ grid->addMultiCellWidget(box2,9,10,1,1);
+
+ customFormatEdit = new QLineEdit( grp );
+ grid->addMultiCellWidget( customFormatEdit, 1, 1, 1, 1 );
+ customFormatEdit->setHidden( true );
+
+ listFormat=new QListBox(grp);
+ grid->addMultiCellWidget(listFormat,2,7,1,1);
+ QWhatsThis::add(listFormat, i18n( "Displays choices of format for the fraction, date or time formats." ) );
+ layout->addWidget(grp);
+
+ /* *** */
+
+ QGroupBox *box = new QGroupBox( this, "Box");
+
+ grid = new QGridLayout(box,3,4,KDialog::marginHint(), KDialog::spacingHint());
+
+ postfix = new QLineEdit( box, "LineEdit_1" );
+ QWhatsThis::add(postfix, i18n( "You can add here a Postfix such as a $HK symbol to the end of each cell content in the checked format." ) );
+ grid->addWidget(postfix,2,1);
+ precision = new KIntNumInput( dlg->precision, box, 10 );
+ precision->setSpecialValueText(i18n("variable"));
+ precision->setRange(-1,10,1,false);
+ QWhatsThis::add(precision, i18n( "You can control how many digits are displayed after the decimal point for numeric values. This can also be changed using the Increase precision or Decrease precision icons in the Format toolbar. " ) );
+ grid->addWidget(precision,1,1);
+
+ prefix = new QLineEdit( box, "LineEdit_3" );
+ QWhatsThis::add(prefix, i18n( "You can add here a Prefix such as a $ symbol at the start of each cell content in the checked format." ) );
+ grid->addWidget(prefix,0,1);
+
+ format = new QComboBox( box, "ListBox_1" );
+ QWhatsThis::add(format, i18n( "You can choose whether positive values are displayed with a leading + sign and whether negative values are shown in red." ) );
+ grid->addWidget(format,0,3);
+
+ QLabel* tmpQLabel;
+ tmpQLabel = new QLabel( box, "Label_1" );
+ grid->addWidget(tmpQLabel,2,0);
+ tmpQLabel->setText( i18n("Postfix:") );
+
+ postfix->setText( dlg->postfix );
+
+ tmpQLabel = new QLabel( box, "Label_2" );
+ grid->addWidget(tmpQLabel,0,0);
+
+ tmpQLabel->setText( i18n("Prefix:") );
+ tmpQLabel = new QLabel( box, "Label_3" );
+ grid->addWidget(tmpQLabel,1,0);
+ tmpQLabel->setText( i18n("Precision:") );
+
+ prefix->setText( dlg->prefix );
+
+ format->insertItem( *_dlg->formatOnlyNegSignedPixmap, 0 );
+ format->insertItem( *_dlg->formatRedOnlyNegSignedPixmap, 1 );
+ format->insertItem( *_dlg->formatRedNeverSignedPixmap, 2 );
+ format->insertItem( *_dlg->formatAlwaysSignedPixmap, 3 );
+ format->insertItem( *_dlg->formatRedAlwaysSignedPixmap, 4 );
+
+ tmpQLabel = new QLabel( box, "Label_4" );
+ grid->addWidget(tmpQLabel, 0, 2);
+ tmpQLabel->setText( i18n("Format:") );
+
+ currencyLabel = new QLabel( box, "LabelCurrency" );
+ grid->addWidget(currencyLabel, 1, 2);
+ currencyLabel->setText( i18n("Currency:") );
+
+ currency = new QComboBox( box, "ComboCurrency" );
+ grid->addWidget(currency, 1, 3);
+
+ currency->insertItem( i18n("Automatic") );
+
+ int index = 2; //ignore first two in the list
+ bool ok = true;
+ QString text;
+
+ while ( ok )
+ {
+ text = Currency::getChooseString( index, ok );
+ if ( ok )
+ {
+ currency->insertItem( text );
+ }
+ else
+ {
+ break;
+ }
+
+ ++index;
+ }
+
+ currency->setCurrentItem( 0 );
+ currency->hide();
+ currencyLabel->hide();
+
+ if ( !dlg->bFloatFormat || !dlg->bFloatColor )
+ format->setCurrentItem( 5 );
+ else if ( dlg->floatFormat == Format::OnlyNegSigned && dlg->floatColor == Format::AllBlack )
+ format->setCurrentItem( 0 );
+ else if ( dlg->floatFormat == Format::OnlyNegSigned && dlg->floatColor == Format::NegRed )
+ format->setCurrentItem( 1 );
+ else if ( dlg->floatFormat == Format::AlwaysUnsigned && dlg->floatColor == Format::NegRed )
+ format->setCurrentItem( 2 );
+ else if ( dlg->floatFormat == Format::AlwaysSigned && dlg->floatColor == Format::AllBlack )
+ format->setCurrentItem( 3 );
+ else if ( dlg->floatFormat == Format::AlwaysSigned && dlg->floatColor == Format::NegRed )
+ format->setCurrentItem( 4 );
+ layout->addWidget(box);
+
+ cellFormatType=dlg->formatType;
+ newFormatType = cellFormatType;
+
+ if (!cellFormatType)
+ generic->setChecked(true);
+ else
+ {
+ if (cellFormatType==Number_format)
+ number->setChecked(true);
+ else if (cellFormatType==Percentage_format)
+ percent->setChecked(true);
+ else if (cellFormatType==Money_format)
+ {
+ money->setChecked(true);
+ currencyLabel->show();
+ currency->show();
+ if (dlg->bCurrency)
+ {
+ QString tmp;
+ if (dlg->cCurrency.type != 1)
+ {
+ Currency curr(dlg->cCurrency.type);
+ bool ok = true;
+ tmp = Currency::getChooseString(dlg->cCurrency.type, ok);
+ if ( !ok )
+ tmp = dlg->cCurrency.symbol;
+ }
+ else
+ tmp = dlg->cCurrency.symbol;
+ currency->setCurrentText( tmp );
+ }
+ }
+ else if ( cellFormatType == Scientific_format )
+ scientific->setChecked(true);
+ else if ( formatIsDate (cellFormatType) )
+ date->setChecked(true);
+ else if ( formatIsTime (cellFormatType) )
+ time->setChecked(true);
+ else if ( formatIsFraction (cellFormatType) )
+ fraction->setChecked(true);
+ else if (cellFormatType == Text_format)
+ textFormat->setChecked(true);
+ else if (cellFormatType == Custom_format)
+ customFormat->setChecked(true);
+ }
+
+ connect(generic,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
+ connect(fraction,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
+ connect(money,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
+ connect(date,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
+ connect(scientific,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
+ connect(number,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
+ connect(percent,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
+ connect(time,SIGNAL(clicked ()),this,SLOT(slotChangeState()));
+ connect(textFormat,SIGNAL(clicked()),this,SLOT(slotChangeState()));
+ connect(customFormat,SIGNAL(clicked()),this,SLOT(slotChangeState()));
+
+ connect(listFormat,SIGNAL(selectionChanged ()),this,SLOT(makeformat()));
+ connect(precision,SIGNAL(valueChanged(int)),this,SLOT(slotChangeValue(int)));
+ connect(prefix,SIGNAL(textChanged ( const QString & ) ),this,SLOT(makeformat()));
+ connect(postfix,SIGNAL(textChanged ( const QString & ) ),this,SLOT(makeformat()));
+ connect(currency,SIGNAL(activated ( const QString & ) ),this, SLOT(currencyChanged(const QString &)));
+ connect(format,SIGNAL(activated ( int ) ),this,SLOT(formatChanged(int)));
+ connect(format, SIGNAL(activated(int)), this, SLOT(makeformat()));
+ slotChangeState();
+ m_bFormatColorChanged=false;
+ m_bFormatTypeChanged=false;
+ this->resize( 400, 400 );
+}
+
+void CellFormatPageFloat::formatChanged(int)
+{
+ m_bFormatColorChanged=true;
+}
+
+void CellFormatPageFloat::slotChangeValue(int)
+{
+ makeformat();
+}
+void CellFormatPageFloat::slotChangeState()
+{
+ QStringList list;
+ listFormat->clear();
+ currency->hide();
+ currencyLabel->hide();
+
+ // start with enabled, they get disabled when inappropriate further down
+ precision->setEnabled(true);
+ prefix->setEnabled(true);
+ postfix->setEnabled(true);
+ format->setEnabled(true);
+
+ if (generic->isChecked() || number->isChecked() || percent->isChecked() ||
+ scientific->isChecked() || textFormat->isChecked())
+ listFormat->setEnabled(false);
+ else if (money->isChecked())
+ {
+ listFormat->setEnabled(false);
+ precision->setValue(2);
+ currency->show();
+ currencyLabel->show();
+ }
+ else if (date->isChecked())
+ {
+ format->setEnabled(false);
+ precision->setEnabled(false);
+ prefix->setEnabled(false);
+ postfix->setEnabled(false);
+ listFormat->setEnabled(true);
+ init();
+ }
+ else if (fraction->isChecked())
+ {
+ precision->setEnabled(false);
+ listFormat->setEnabled(true);
+ list+=i18n("Halves 1/2");
+ list+=i18n("Quarters 1/4");
+ list+=i18n("Eighths 1/8");
+ list+=i18n("Sixteenths 1/16");
+ list+=i18n("Tenths 1/10");
+ list+=i18n("Hundredths 1/100");
+ list+=i18n("One digit 5/9");
+ list+=i18n("Two digits 15/22");
+ list+=i18n("Three digits 153/652");
+ listFormat->insertStringList(list);
+ if (cellFormatType == fraction_half)
+ listFormat->setCurrentItem(0);
+ else if (cellFormatType == fraction_quarter)
+ listFormat->setCurrentItem(1);
+ else if (cellFormatType == fraction_eighth )
+ listFormat->setCurrentItem(2);
+ else if (cellFormatType == fraction_sixteenth )
+ listFormat->setCurrentItem(3);
+ else if (cellFormatType == fraction_tenth )
+ listFormat->setCurrentItem(4);
+ else if (cellFormatType == fraction_hundredth )
+ listFormat->setCurrentItem(5);
+ else if (cellFormatType == fraction_one_digit )
+ listFormat->setCurrentItem(6);
+ else if (cellFormatType == fraction_two_digits )
+ listFormat->setCurrentItem(7);
+ else if (cellFormatType == fraction_three_digits )
+ listFormat->setCurrentItem(8);
+ else
+ listFormat->setCurrentItem(0);
+ }
+ else if (time->isChecked())
+ {
+ precision->setEnabled(false);
+ prefix->setEnabled(false);
+ postfix->setEnabled(false);
+ format->setEnabled(false);
+ listFormat->setEnabled(true);
+
+
+ list+=i18n("System: ")+dlg->locale()->formatTime(QTime::currentTime(),false);
+ list+=i18n("System: ")+dlg->locale()->formatTime(QTime::currentTime(),true);
+ QDateTime tmpTime (QDate (1, 1, 1900), QTime (10, 35, 25));
+
+
+ ValueFormatter *fmt = dlg->getDoc()->formatter();
+ list+= fmt->timeFormat(tmpTime, Time_format1);
+ list+= fmt->timeFormat(tmpTime, Time_format2);
+ list+= fmt->timeFormat(tmpTime, Time_format3);
+ list+= fmt->timeFormat(tmpTime, Time_format4);
+ list+= fmt->timeFormat(tmpTime, Time_format5);
+ list+= ( fmt->timeFormat(tmpTime, Time_format6) + i18n(" (=[mm]::ss)") );
+ list+= ( fmt->timeFormat(tmpTime, Time_format7) + i18n(" (=[hh]::mm::ss)") );
+ list+= ( fmt->timeFormat(tmpTime, Time_format8) + i18n(" (=[hh]::mm)") );
+ listFormat->insertStringList(list);
+
+ if ( cellFormatType == Time_format )
+ listFormat->setCurrentItem(0);
+ else if (cellFormatType == SecondeTime_format)
+ listFormat->setCurrentItem(1);
+ else if (cellFormatType == Time_format1)
+ listFormat->setCurrentItem(2);
+ else if (cellFormatType == Time_format2)
+ listFormat->setCurrentItem(3);
+ else if (cellFormatType == Time_format3)
+ listFormat->setCurrentItem(4);
+ else if (cellFormatType == Time_format4)
+ listFormat->setCurrentItem(5);
+ else if (cellFormatType == Time_format5)
+ listFormat->setCurrentItem(6);
+ else if (cellFormatType == Time_format6)
+ listFormat->setCurrentItem(7);
+ else if (cellFormatType == Time_format7)
+ listFormat->setCurrentItem(8);
+ else if (cellFormatType == Time_format8)
+ listFormat->setCurrentItem(9);
+ else
+ listFormat->setCurrentItem(0);
+ }
+
+ if (customFormat->isChecked())
+ {
+ customFormatEdit->setHidden( false );
+ precision->setEnabled(false);
+ prefix->setEnabled(false);
+ postfix->setEnabled(false);
+ format->setEnabled(false);
+ listFormat->setEnabled(true);
+ }
+ else
+ customFormatEdit->setHidden( true );
+
+ m_bFormatTypeChanged=true;
+
+ makeformat();
+}
+
+void CellFormatPageFloat::init()
+{
+ QStringList list;
+ QString tmp;
+ QString tmp2;
+ QDate tmpDate( 2000,2,18);
+ list+=i18n("System: ")+dlg->locale()->formatDate (QDate::currentDate(), true);
+ list+=i18n("System: ")+dlg->locale()->formatDate (QDate::currentDate(), false);
+
+ ValueFormatter *fmt = dlg->getDoc()->formatter();
+
+ /*18-Feb-00*/
+ list+=fmt->dateFormat( tmpDate, date_format1);
+ /*18-Feb-1999*/
+ list+=fmt->dateFormat( tmpDate, date_format2);
+ /*18-Feb*/
+ list+=fmt->dateFormat( tmpDate, date_format3);
+ /*18-2*/
+ list+=fmt->dateFormat( tmpDate, date_format4);
+ /*18/2/00*/
+ list+=fmt->dateFormat( tmpDate, date_format5);
+ /*18/5/1999*/
+ list+=fmt->dateFormat( tmpDate, date_format6);
+ /*Feb-99*/
+ list+=fmt->dateFormat( tmpDate, date_format7);
+ /*February-99*/
+ list+=fmt->dateFormat( tmpDate, date_format8);
+ /*February-1999*/
+ list+=fmt->dateFormat( tmpDate, date_format9);
+ /*F-99*/
+ list+=fmt->dateFormat( tmpDate, date_format10);
+ /*18/Feb*/
+ list+=fmt->dateFormat( tmpDate, date_format11);
+ /*18/2*/
+ list+=fmt->dateFormat( tmpDate, date_format12);
+ /*18/Feb/1999*/
+ list+=fmt->dateFormat( tmpDate, date_format13);
+ /*2000/Feb/18*/
+ list+=fmt->dateFormat( tmpDate, date_format14);
+ /*2000-Feb-18*/
+ list+=fmt->dateFormat( tmpDate, date_format15);
+ /*2000-2-18*/
+ list+=fmt->dateFormat( tmpDate, date_format16);
+ /*2 february 2000*/
+ list+=fmt->dateFormat( tmpDate, date_format17);
+ list+=fmt->dateFormat( tmpDate, date_format18);
+ list+=fmt->dateFormat( tmpDate, date_format19);
+ list+=fmt->dateFormat( tmpDate, date_format20);
+ list+=fmt->dateFormat( tmpDate, date_format21);
+ list+=fmt->dateFormat( tmpDate, date_format22);
+ list+=fmt->dateFormat( tmpDate, date_format23);
+ list+=fmt->dateFormat( tmpDate, date_format24);
+ list+=fmt->dateFormat( tmpDate, date_format25);
+ list+=fmt->dateFormat( tmpDate, date_format26);
+
+ listFormat->insertStringList(list);
+ if ( cellFormatType == ShortDate_format )
+ listFormat->setCurrentItem(0);
+ else if (cellFormatType == TextDate_format)
+ listFormat->setCurrentItem(1);
+ else if (cellFormatType == date_format1)
+ listFormat->setCurrentItem(2);
+ else if (cellFormatType == date_format2)
+ listFormat->setCurrentItem(3);
+ else if (cellFormatType == date_format3)
+ listFormat->setCurrentItem(4);
+ else if (cellFormatType == date_format4)
+ listFormat->setCurrentItem(5);
+ else if (cellFormatType == date_format5)
+ listFormat->setCurrentItem(6);
+ else if (cellFormatType == date_format6)
+ listFormat->setCurrentItem(7);
+ else if (cellFormatType == date_format7)
+ listFormat->setCurrentItem(8);
+ else if (cellFormatType == date_format8)
+ listFormat->setCurrentItem(9);
+ else if (cellFormatType == date_format9)
+ listFormat->setCurrentItem(10);
+ else if (cellFormatType == date_format10)
+ listFormat->setCurrentItem(11);
+ else if (cellFormatType == date_format11)
+ listFormat->setCurrentItem(12);
+ else if (cellFormatType == date_format12)
+ listFormat->setCurrentItem(13);
+ else if (cellFormatType == date_format13)
+ listFormat->setCurrentItem(14);
+ else if (cellFormatType == date_format14)
+ listFormat->setCurrentItem(15);
+ else if (cellFormatType == date_format15)
+ listFormat->setCurrentItem(16);
+ else if (cellFormatType == date_format16)
+ listFormat->setCurrentItem(17);
+ else if (cellFormatType == date_format17)
+ listFormat->setCurrentItem(18);
+ else if (cellFormatType == date_format18)
+ listFormat->setCurrentItem(19);
+ else if (cellFormatType == date_format19)
+ listFormat->setCurrentItem(20);
+ else if (cellFormatType == date_format20)
+ listFormat->setCurrentItem(21);
+ else if (cellFormatType == date_format21)
+ listFormat->setCurrentItem(22);
+ else if (cellFormatType == date_format22)
+ listFormat->setCurrentItem(23);
+ else if (cellFormatType == date_format23)
+ listFormat->setCurrentItem(24);
+ else if (cellFormatType == date_format24)
+ listFormat->setCurrentItem(25);
+ else if (cellFormatType == date_format25)
+ listFormat->setCurrentItem(26);
+ else if (cellFormatType == date_format26)
+ listFormat->setCurrentItem(27);
+ else
+ listFormat->setCurrentItem(0);
+
+}
+
+void CellFormatPageFloat::currencyChanged(const QString &)
+{
+ int index = currency->currentItem();
+ if (index > 0)
+ ++index;
+ dlg->cCurrency.symbol = Currency::getDisplaySymbol(index);
+ dlg->cCurrency.type = index;
+
+ makeformat();
+}
+
+void CellFormatPageFloat::updateFormatType ()
+{
+ if (generic->isChecked())
+ newFormatType = Generic_format;
+ else if (number->isChecked())
+ newFormatType = Number_format;
+ else if (percent->isChecked())
+ newFormatType = Percentage_format;
+ else if (date->isChecked())
+ {
+ newFormatType=ShortDate_format;
+ switch (listFormat->currentItem())
+ {
+ case 0: newFormatType=ShortDate_format; break;
+ case 1: newFormatType=TextDate_format; break;
+ case 2: newFormatType=date_format1; break; /*18-Feb-99*/
+ case 3: newFormatType=date_format2; break; /*18-Feb-1999*/
+ case 4: newFormatType=date_format3; break; /*18-Feb*/
+ case 5: newFormatType=date_format4; break; /*18-05*/
+ case 6: newFormatType=date_format5; break; /*18/05/00*/
+ case 7: newFormatType=date_format6; break; /*18/05/1999*/
+ case 8: newFormatType=date_format7; break;/*Feb-99*/
+ case 9: newFormatType=date_format8; break; /*February-99*/
+ case 10: newFormatType=date_format9; break; /*February-1999*/
+ case 11: newFormatType=date_format10; break; /*F-99*/
+ case 12: newFormatType=date_format11; break; /*18/Feb*/
+ case 13: newFormatType=date_format12; break; /*18/02*/
+ case 14: newFormatType=date_format13; break; /*18/Feb/1999*/
+ case 15: newFormatType=date_format14; break; /*2000/Feb/18*/
+ case 16: newFormatType=date_format15; break;/*2000-Feb-18*/
+ case 17: newFormatType=date_format16; break;/*2000-02-18*/
+ case 18: newFormatType=date_format17; break; /*2000-02-18*/
+ case 19: newFormatType=date_format18; break;
+ case 20: newFormatType=date_format19; break;
+ case 21: newFormatType=date_format20; break;
+ case 22: newFormatType=date_format21; break;
+ case 23: newFormatType=date_format22; break;
+ case 24: newFormatType=date_format23; break;
+ case 25: newFormatType=date_format24; break;
+ case 26: newFormatType=date_format25; break;
+ case 27: newFormatType=date_format26; break;
+ }
+ }
+ else if (money->isChecked())
+ newFormatType = Money_format;
+ else if (scientific->isChecked())
+ newFormatType = Scientific_format;
+ else if (fraction->isChecked())
+ {
+ newFormatType=fraction_half;
+ switch (listFormat->currentItem())
+ {
+ case 0: newFormatType=fraction_half; break;
+ case 1: newFormatType=fraction_quarter; break;
+ case 2: newFormatType=fraction_eighth; break;
+ case 3: newFormatType=fraction_sixteenth; break;
+ case 4: newFormatType=fraction_tenth; break;
+ case 5: newFormatType=fraction_hundredth; break;
+ case 6: newFormatType=fraction_one_digit; break;
+ case 7: newFormatType=fraction_two_digits; break;
+ case 8: newFormatType=fraction_three_digits; break;
+ }
+ }
+ else if (time->isChecked())
+ {
+ newFormatType=Time_format;
+ switch (listFormat->currentItem())
+ {
+ case 0: newFormatType=Time_format; break;
+ case 1: newFormatType=SecondeTime_format; break;
+ case 2: newFormatType=Time_format1; break;
+ case 3: newFormatType=Time_format2; break;
+ case 4: newFormatType=Time_format3; break;
+ case 5: newFormatType=Time_format4; break;
+ case 6: newFormatType=Time_format5; break;
+ case 7: newFormatType=Time_format6; break;
+ case 8: newFormatType=Time_format7; break;
+ case 9: newFormatType=Time_format8; break;
+ }
+ }
+ else if (textFormat->isChecked())
+ newFormatType = Text_format;
+ else if (customFormat->isChecked())
+ newFormatType = Custom_format;
+}
+
+void CellFormatPageFloat::makeformat()
+{
+ m_bFormatTypeChanged=true;
+ QString tmp;
+
+ updateFormatType();
+ QColor color;
+ Format::FloatFormat floatFormat = Format::OnlyNegSigned;
+ switch( format->currentItem() )
+ {
+ case 0:
+ floatFormat = Format::OnlyNegSigned;
+ color = black;
+ break;
+ case 1:
+ floatFormat = Format::OnlyNegSigned;
+ color = Qt::red;
+ break;
+ case 2:
+ floatFormat = Format::AlwaysUnsigned;
+ color = Qt::red;
+ break;
+ case 3:
+ floatFormat = Format::AlwaysSigned;
+ color = black;
+ break;
+ case 4:
+ floatFormat = Format::AlwaysSigned;
+ color = Qt::red;
+ break;
+ }
+ if (!dlg->value.isNumber() || dlg->value.asFloat() >= 0 || !format->isEnabled())
+ {
+ color = black;
+ }
+ ValueFormatter *fmt = dlg->getDoc()->formatter();
+ tmp = fmt->formatText(dlg->value, newFormatType, precision->value(),
+ floatFormat,
+ prefix->isEnabled() ? prefix->text() : QString::null,
+ postfix->isEnabled() ? postfix->text() : QString::null,
+ newFormatType == Money_format ? dlg->cCurrency.symbol : QString::null);
+ if (tmp.length() > 50)
+ tmp = tmp.left (50);
+ exampleLabel->setText(tmp.prepend("<font color=" + color.name() + ">").append("</font>"));
+}
+
+void CellFormatPageFloat::apply( CustomStyle * style )
+{
+ if ( postfix->text() != dlg->postfix )
+ {
+ if ( postfix->isEnabled())
+ style->changePostfix( postfix->text() );
+ else
+ style->changePostfix( "" );
+ }
+ if ( prefix->text() != dlg->prefix )
+ {
+ if (prefix->isEnabled())
+ style->changePrefix( prefix->text() );
+ else
+ style->changePrefix( "" );
+ }
+
+ if ( dlg->precision != precision->value() )
+ style->changePrecision( precision->value() );
+
+ if ( m_bFormatColorChanged )
+ {
+ switch( format->currentItem() )
+ {
+ case 0:
+ style->changeFloatFormat( Format::OnlyNegSigned );
+ style->changeFloatColor( Format::AllBlack );
+ break;
+ case 1:
+ style->changeFloatFormat( Format::OnlyNegSigned );
+ style->changeFloatColor( Format::NegRed );
+ break;
+ case 2:
+ style->changeFloatFormat( Format::AlwaysUnsigned );
+ style->changeFloatColor( Format::NegRed );
+ break;
+ case 3:
+ style->changeFloatFormat( Format::AlwaysSigned );
+ style->changeFloatColor( Format::AllBlack );
+ break;
+ case 4:
+ style->changeFloatFormat( Format::AlwaysSigned );
+ style->changeFloatColor( Format::NegRed );
+ break;
+ }
+ }
+ if ( m_bFormatTypeChanged )
+ {
+ style->changeFormatType (newFormatType);
+ if ( money->isChecked() )
+ {
+ Format::Currency cur;
+ int index = currency->currentItem();
+ if (index == 0)
+ {
+ if ( currency->currentText() == i18n( "Automatic" ) )
+ {
+ cur.symbol = dlg->locale()->currencySymbol();
+ cur.type = 0;
+ }
+ else
+ {
+ cur.type = 1;
+ cur.symbol = currency->currentText();
+ }
+ }
+ else
+ {
+ cur.type = ++index;
+ cur.symbol = Currency::getDisplaySymbol( index );
+ }
+
+ style->changeCurrency( cur );
+ }
+ }
+}
+
+void CellFormatPageFloat::apply(FormatManipulator* _obj)
+{
+ if ( postfix->text() != dlg->postfix )
+ if ( postfix->isEnabled())
+ {
+ // If we are in here it *never* can be disabled - FIXME (Werner)!
+ if ( postfix->isEnabled())
+ _obj->setPostfix( postfix->text() );
+ else
+ _obj->setPostfix( "" );
+ }
+ if ( prefix->text() != dlg->prefix )
+ if (prefix->isEnabled())
+ _obj->setPrefix( prefix->text() );
+ else
+ _obj->setPrefix( "" );
+
+ if ( dlg->precision != precision->value() )
+ _obj->setPrecision( precision->value() );
+
+ if (m_bFormatColorChanged)
+ {
+ switch( format->currentItem() )
+ {
+ case 0:
+ _obj->setFloatFormat( Format::OnlyNegSigned );
+ _obj->setFloatColor( Format::AllBlack );
+ break;
+ case 1:
+ _obj->setFloatFormat( Format::OnlyNegSigned );
+ _obj->setFloatColor( Format::NegRed );
+ break;
+ case 2:
+ _obj->setFloatFormat( Format::AlwaysUnsigned );
+ _obj->setFloatColor( Format::NegRed );
+ break;
+ case 3:
+ _obj->setFloatFormat( Format::AlwaysSigned );
+ _obj->setFloatColor( Format::AllBlack );
+ break;
+ case 4:
+ _obj->setFloatFormat( Format::AlwaysSigned );
+ _obj->setFloatColor( Format::NegRed );
+ break;
+ }
+ }
+ if (m_bFormatTypeChanged)
+ {
+ _obj->setFormatType (newFormatType);
+ if (money->isChecked())
+ {
+ Format::Currency cur;
+ int index = currency->currentItem();
+ if (index == 0)
+ {
+ if ( currency->currentText() == i18n( "Automatic" ) )
+ {
+ cur.symbol = dlg->locale()->currencySymbol();
+ cur.type = 0;
+ }
+ else
+ {
+ cur.type = 1;
+ cur.symbol = currency->currentText();
+ }
+ }
+ else
+ {
+ cur.type = ++index;
+ cur.symbol = Currency::getDisplaySymbol( index );
+ }
+
+ _obj->setCurrency( cur.type, cur.symbol );
+ }
+ }
+}
+
+
+
+/***************************************************************************
+ *
+ * CellFormatPageProtection
+ *
+ ***************************************************************************/
+
+CellFormatPageProtection::CellFormatPageProtection( QWidget* parent, CellFormatDialog * _dlg )
+ : ProtectionTab( parent ),
+ m_dlg( _dlg )
+{
+ m_bDontPrint->setChecked( m_dlg->bDontPrintText );
+ m_bHideAll->setChecked( m_dlg->bHideAll );
+ m_bHideFormula->setChecked( m_dlg->bHideFormula );
+ m_bIsProtected->setChecked( m_dlg->bIsProtected );
+}
+
+CellFormatPageProtection::~CellFormatPageProtection()
+{
+}
+
+void CellFormatPageProtection::apply( CustomStyle * style )
+{
+ if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked() )
+ {
+ if ( m_bDontPrint->isChecked() )
+ style->addProperty( Style::PDontPrintText );
+ else
+ style->removeProperty( Style::PDontPrintText );
+ }
+
+ if ( m_dlg->bIsProtected != m_bIsProtected->isChecked() )
+ {
+ if ( !m_bIsProtected->isChecked() )
+ style->addProperty( Style::PNotProtected );
+ else
+ style->removeProperty( Style::PNotProtected );
+ }
+
+ if ( m_dlg->bHideAll != m_bHideAll->isChecked() )
+ {
+ if ( m_bHideAll->isChecked() )
+ style->addProperty( Style::PHideAll );
+ else
+ style->removeProperty( Style::PHideAll );
+ }
+
+ if ( m_dlg->bHideFormula != m_bHideFormula->isChecked() )
+ {
+ if ( m_bHideFormula->isChecked() )
+ style->addProperty( Style::PHideFormula );
+ else
+ style->removeProperty( Style::PHideFormula );
+ }
+}
+
+void CellFormatPageProtection::apply(FormatManipulator* _obj)
+{
+ if ( m_dlg->bDontPrintText != m_bDontPrint->isChecked())
+ _obj->setDontPrintText( m_bDontPrint->isChecked() );
+
+ if ( m_dlg->bIsProtected != m_bIsProtected->isChecked())
+ _obj->setNotProtected( !m_bIsProtected->isChecked() );
+
+ if ( m_dlg->bHideAll != m_bHideAll->isChecked())
+ _obj->setHideAll( m_bHideAll->isChecked() );
+
+ if ( m_dlg->bHideFormula != m_bHideFormula->isChecked())
+ _obj->setHideFormula( m_bHideFormula->isChecked() );
+}
+
+
+
+/***************************************************************************
+ *
+ * CellFormatPageFont
+ *
+ ***************************************************************************/
+
+CellFormatPageFont::CellFormatPageFont( QWidget* parent, CellFormatDialog *_dlg ) : FontTab( parent )
+{
+ dlg = _dlg;
+
+ bTextColorUndefined = !dlg->bTextColor;
+
+ connect( textColorButton, SIGNAL( changed( const QColor & ) ),
+ this, SLOT( slotSetTextColor( const QColor & ) ) );
+
+
+ QStringList tmpListFont;
+ QFontDatabase *fontDataBase = new QFontDatabase();
+ tmpListFont = fontDataBase->families();
+ delete fontDataBase;
+
+ family_combo->insertStringList( tmpListFont);
+ selFont = dlg->textFont;
+
+ if ( dlg->bTextFontFamily )
+ {
+ selFont.setFamily( dlg->textFontFamily );
+ kdDebug(36001) << "Family = " << dlg->textFontFamily << endl;
+
+ if ( !family_combo->findItem(dlg->textFontFamily))
+ {
+ family_combo->insertItem("",0);
+ family_combo->setCurrentItem(0);
+ }
+ else
+ family_combo->setCurrentItem(family_combo->index(family_combo->findItem(dlg->textFontFamily)));
+ }
+ else
+ {
+ family_combo->insertItem("",0);
+ family_combo->setCurrentItem(0);
+ }
+
+ connect( family_combo, SIGNAL(highlighted(const QString &)),
+ SLOT(family_chosen_slot(const QString &)) );
+
+ QStringList lst;
+ lst.append("");
+ for ( unsigned int i = 1; i < 100; ++i )
+ lst.append( QString( "%1" ).arg( i ) );
+
+ size_combo->insertStringList( lst );
+
+
+ size_combo->setInsertionPolicy(QComboBox::NoInsertion);
+
+ connect( size_combo, SIGNAL(activated(const QString &)),
+ SLOT(size_chosen_slot(const QString &)) );
+ connect( size_combo ,SIGNAL( textChanged(const QString &)),
+ this,SLOT(size_chosen_slot(const QString &)));
+
+ connect( weight_combo, SIGNAL(activated(const QString &)),
+ SLOT(weight_chosen_slot(const QString &)) );
+
+ connect( style_combo, SIGNAL(activated(const QString &)),
+ SLOT(style_chosen_slot(const QString &)) );
+
+ strike->setChecked(dlg->strike);
+ connect( strike, SIGNAL( clicked()),
+ SLOT(strike_chosen_slot()) );
+
+ underline->setChecked(dlg->underline);
+ connect( underline, SIGNAL( clicked()),
+ SLOT(underline_chosen_slot()) );
+
+ example_label->setText(i18n("Dolor Ipse"));
+
+ connect(this,SIGNAL(fontSelected( const QFont& )),
+ this,SLOT(display_example( const QFont&)));
+
+ setCombos();
+ display_example( selFont );
+ fontChanged=false;
+ this->resize( 400, 400 );
+}
+
+void CellFormatPageFont::slotSetTextColor( const QColor &_color )
+{
+ textColor = _color;
+ bTextColorUndefined = false;
+}
+
+void CellFormatPageFont::apply( CustomStyle * style )
+{
+ if ( !bTextColorUndefined && textColor != dlg->textColor )
+ style->changeTextColor( textColor );
+
+ if ( ( size_combo->currentItem() != 0 )
+ && ( dlg->textFontSize != selFont.pointSize() ) )
+ style->changeFontSize( selFont.pointSize() );
+
+ if ( ( selFont.family() != dlg->textFontFamily )
+ && !family_combo->currentText().isEmpty() )
+ style->changeFontFamily( selFont.family() );
+
+ uint flags = 0;
+
+ if ( weight_combo->currentItem() != 0 && selFont.bold() )
+ flags |= Style::FBold;
+ else
+ flags &= ~(uint) Style::FBold;
+
+ if ( style_combo->currentItem() != 0 && selFont.italic() )
+ flags |= Style::FItalic;
+ else
+ flags &= ~(uint) Style::FItalic;
+
+ if ( strike->isChecked() )
+ flags |= Style::FStrike;
+ else
+ flags &= ~(uint) Style::FStrike;
+
+ if ( underline->isChecked() )
+ flags |= Style::FUnderline;
+ else
+ flags &= ~(uint) Style::FUnderline;
+
+ style->changeFontFlags( flags );
+}
+
+void CellFormatPageFont::apply(FormatManipulator* _obj)
+{
+ if ( !bTextColorUndefined && textColor != dlg->textColor )
+ _obj->setTextColor( textColor );
+ if (fontChanged)
+ {
+ if ( ( size_combo->currentItem() != 0 )
+ && ( dlg->textFontSize != selFont.pointSize() ) )
+ _obj->setFontSize( selFont.pointSize() );
+ if ( ( selFont.family() != dlg->textFontFamily ) && ( !family_combo->currentText().isEmpty() ) )
+ _obj->setFontFamily( selFont.family() );
+ if ( weight_combo->currentItem() != 0 )
+ _obj->setFontBold( selFont.bold() );
+ if ( style_combo->currentItem() != 0 )
+ _obj->setFontItalic( selFont.italic() );
+ _obj->setFontStrike( strike->isChecked() );
+ _obj->setFontUnderline(underline->isChecked() );
+ }
+}
+
+void CellFormatPageFont::underline_chosen_slot()
+{
+ selFont.setUnderline( underline->isChecked() );
+ emit fontSelected(selFont);
+}
+
+void CellFormatPageFont::strike_chosen_slot()
+{
+ selFont.setStrikeOut( strike->isChecked() );
+ emit fontSelected(selFont);
+}
+
+void CellFormatPageFont::family_chosen_slot(const QString & family)
+{
+ selFont.setFamily(family);
+ emit fontSelected(selFont);
+}
+
+void CellFormatPageFont::size_chosen_slot(const QString & size)
+{
+ QString size_string = size;
+
+ selFont.setPointSize(size_string.toInt());
+ emit fontSelected(selFont);
+}
+
+void CellFormatPageFont::weight_chosen_slot(const QString & weight)
+{
+ QString weight_string = weight;
+
+ if ( weight_string == i18n("Normal"))
+ selFont.setBold(false);
+ if ( weight_string == i18n("Bold"))
+ selFont.setBold(true);
+ emit fontSelected(selFont);
+}
+
+void CellFormatPageFont::style_chosen_slot(const QString & style)
+{
+ QString style_string = style;
+
+ if ( style_string == i18n("Roman"))
+ selFont.setItalic(false);
+ if ( style_string == i18n("Italic"))
+ selFont.setItalic(true);
+ emit fontSelected(selFont);
+}
+
+
+void CellFormatPageFont::display_example(const QFont& font)
+{
+ QString string;
+ fontChanged=true;
+ example_label->setFont(font);
+ example_label->repaint();
+}
+
+void CellFormatPageFont::setCombos()
+{
+ QString string;
+ QComboBox* combo;
+ int number_of_entries;
+ bool found;
+
+ if ( dlg->bTextColor )
+ textColor = dlg->textColor;
+ else
+ textColor = colorGroup().text();
+
+ if ( !textColor.isValid() )
+ textColor =colorGroup().text();
+
+ textColorButton->setColor( textColor );
+
+
+ combo = size_combo;
+ if ( dlg->bTextFontSize )
+ {
+ kdDebug(36001) << "SIZE=" << dlg->textFontSize << endl;
+ selFont.setPointSize( dlg->textFontSize );
+ number_of_entries = size_combo->count();
+ string.setNum( dlg->textFontSize );
+ found = false;
+
+ for (int i = 0; i < number_of_entries ; i++){
+ if ( string == (QString) combo->text(i)){
+ combo->setCurrentItem(i);
+ found = true;
+ // kdDebug(36001) << "Found Size " << string.data() << " setting to item " i << endl;
+ break;
+ }
+ }
+ }
+ else
+ combo->setCurrentItem( 0 );
+
+ if ( !dlg->bTextFontBold )
+ weight_combo->setCurrentItem(0);
+ else if ( dlg->textFontBold )
+ {
+ selFont.setBold( dlg->textFontBold );
+ weight_combo->setCurrentItem(2);
+ }
+ else
+ {
+ selFont.setBold( dlg->textFontBold );
+ weight_combo->setCurrentItem(1);
+ }
+
+ if ( !dlg->bTextFontItalic )
+ weight_combo->setCurrentItem(0);
+ else if ( dlg->textFontItalic )
+ {
+ selFont.setItalic( dlg->textFontItalic );
+ style_combo->setCurrentItem(2);
+ }
+ else
+ {
+ selFont.setItalic( dlg->textFontItalic );
+ style_combo->setCurrentItem(1);
+ }
+}
+
+
+
+/***************************************************************************
+ *
+ * CellFormatPagePosition
+ *
+ ***************************************************************************/
+
+CellFormatPagePosition::CellFormatPagePosition( QWidget* parent, CellFormatDialog *_dlg )
+ : PositionTab(parent ),
+ dlg( _dlg )
+{
+ if ( dlg->alignX == Format::Left )
+ left->setChecked( true );
+ else if ( dlg->alignX == Format::Center )
+ center->setChecked( true );
+ else if ( dlg->alignX == Format::Right )
+ right->setChecked( true );
+ else if ( dlg->alignX == Format::Undefined )
+ standard->setChecked( true );
+
+ connect(horizontalGroup, SIGNAL(clicked(int)), this, SLOT(slotStateChanged(int)));
+
+ if ( dlg->alignY ==Format::Top )
+ top->setChecked( true );
+ else if ( dlg->alignY ==Format::Middle )
+ middle->setChecked(true );
+ else if ( dlg->alignY ==Format::Bottom )
+ bottom->setChecked( true );
+
+ multi->setChecked(dlg->bMultiRow);
+
+ vertical->setChecked(dlg->bVerticalText);
+
+ angleRotation->setValue(-dlg->textRotation);//annma
+ spinBox3->setValue(-dlg->textRotation);
+ if ( dlg->textRotation != 0 )
+ {
+ multi->setEnabled(false );
+ vertical->setEnabled(false);
+ }
+
+ mergeCell->setChecked(dlg->isMerged);
+ mergeCell->setEnabled(!dlg->oneCell && ((!dlg->isRowSelected) && (!dlg->isColumnSelected)));
+
+ QGridLayout *grid2 = new QGridLayout(indentGroup, 1, 1, KDialog::marginHint(), KDialog::spacingHint());
+ grid2->addRowSpacing( 0, indentGroup->fontMetrics().height()/8 ); // groupbox title
+ m_indent = new KoUnitDoubleSpinBox( indentGroup, 0.0, 400.0, 10.0,dlg->indent,dlg->getDoc()->unit() );
+ grid2->addWidget(m_indent, 0, 0);
+
+ width = new KoUnitDoubleSpinBox( m_widthPanel );
+ QGridLayout *gridWidth = new QGridLayout(m_widthPanel, 1, 1, 0, 0);
+ gridWidth->addWidget(width, 0, 0);
+ width->setValue ( dlg->widthSize );
+ width->setUnit( dlg->getDoc()->unit() );
+ //to ensure, that we don't get rounding problems, we store the displayed value (for later check for changes)
+ dlg->widthSize = width->value();
+
+ if ( dlg->isRowSelected )
+ width->setEnabled(false);
+
+ defaultWidth->setText(i18n("Default width (%1 %2)").arg(KoUnit::toUserValue(dlg->defaultWidthSize, dlg->getDoc()->unit()), 0, 'f', 2).arg(dlg->getDoc()->unitName()));
+ if ( dlg->isRowSelected )
+ defaultWidth->setEnabled(false);
+
+ height=new KoUnitDoubleSpinBox( m_heightPanel );
+ QGridLayout *gridHeight = new QGridLayout(m_heightPanel, 1, 1, 0, 0);
+ gridHeight->addWidget(height, 0, 0);
+ height->setValue( dlg->heightSize );
+ height->setUnit( dlg->getDoc()->unit() );
+ //to ensure, that we don't get rounding problems, we store the displayed value (for later check for changes)
+ dlg->heightSize = height->value();
+
+ if ( dlg->isColumnSelected )
+ height->setEnabled(false);
+
+ defaultHeight->setText(i18n("Default height (%1 %2)").arg(KoUnit::toUserValue(dlg->defaultHeightSize, dlg->getDoc()->unit()), 0, 'f', 2).arg(dlg->getDoc()->unitName())); //annma
+ if ( dlg->isColumnSelected )
+ defaultHeight->setEnabled(false);
+
+ // in case we're editing a style, we disable the cell size settings
+ if (dlg->getStyle())
+ {
+ defaultHeight->setEnabled(false);
+ defaultWidth->setEnabled(false);
+ }
+
+ connect(defaultWidth , SIGNAL(clicked() ),this, SLOT(slotChangeWidthState()));
+ connect(defaultHeight , SIGNAL(clicked() ),this, SLOT(slotChangeHeightState()));
+ connect(vertical , SIGNAL(clicked() ),this, SLOT(slotChangeVerticalState()));
+ connect(multi , SIGNAL(clicked() ), this, SLOT(slotChangeMultiState()));
+ connect(angleRotation, SIGNAL(valueChanged(int)), this, SLOT(slotChangeAngle(int)));
+
+ slotStateChanged( 0 );
+ m_bOptionText = false;
+ this->resize( 400, 400 );
+}
+
+void CellFormatPagePosition::slotChangeMultiState()
+{
+ m_bOptionText = true;
+ if (vertical->isChecked())
+ {
+ vertical->setChecked(false);
+ }
+}
+
+void CellFormatPagePosition::slotChangeVerticalState()
+{
+ m_bOptionText=true;
+ if (multi->isChecked())
+ {
+ multi->setChecked(false);
+ }
+
+}
+
+void CellFormatPagePosition::slotStateChanged(int)
+{
+ if (right->isChecked() || center->isChecked())
+ m_indent->setEnabled(false);
+ else
+ m_indent->setEnabled(true);
+}
+
+bool CellFormatPagePosition::getMergedCellState() const
+{
+ return mergeCell->isChecked();
+}
+
+void CellFormatPagePosition::slotChangeWidthState()
+{
+ if ( defaultWidth->isChecked())
+ width->setEnabled(false);
+ else
+ width->setEnabled(true);
+}
+
+void CellFormatPagePosition::slotChangeHeightState()
+{
+ if ( defaultHeight->isChecked())
+ height->setEnabled(false);
+ else
+ height->setEnabled(true);
+}
+
+void CellFormatPagePosition::slotChangeAngle(int _angle)
+{
+ if ( _angle == 0 )
+ {
+ multi->setEnabled( true );
+ vertical->setEnabled( true );
+ }
+ else
+ {
+ multi->setEnabled( false );
+ vertical->setEnabled( false );
+ }
+}
+
+void CellFormatPagePosition::apply( CustomStyle * style )
+{
+ if ( top->isChecked() && dlg->alignY != Format::Top )
+ style->changeAlignY( Format::Top );
+ else if ( bottom->isChecked() && dlg->alignY != Format::Bottom )
+ style->changeAlignY( Format::Bottom );
+ else if ( middle->isChecked() && dlg->alignY != Format::Middle )
+ style->changeAlignY( Format::Middle );
+
+ if ( left->isChecked() && dlg->alignX != Format::Left )
+ style->changeAlignX( Format::Left );
+ else if ( right->isChecked() && dlg->alignX != Format::Right )
+ style->changeAlignX( Format::Right );
+ else if ( center->isChecked() && dlg->alignX != Format::Center )
+ style->changeAlignX( Format::Center );
+ else if ( standard->isChecked() && dlg->alignX != Format::Undefined )
+ style->changeAlignX( Format::Undefined );
+
+ if ( m_bOptionText )
+ {
+ if ( multi->isEnabled() )
+ {
+ if ( multi->isChecked() )
+ style->addProperty( Style::PMultiRow );
+ else
+ style->removeProperty( Style::PMultiRow );
+ }
+ }
+
+ if ( m_bOptionText )
+ {
+ if ( vertical->isEnabled() )
+ {
+ if ( vertical->isChecked() )
+ style->addProperty( Style::PVerticalText );
+ else
+ style->removeProperty( Style::PVerticalText );
+ }
+ }
+
+ if ( dlg->textRotation != angleRotation->value() )
+ style->changeRotateAngle( (-angleRotation->value()) );
+
+ if ( m_indent->isEnabled()
+ && dlg->indent != m_indent->value() )
+ style->changeIndent( m_indent->value() );
+
+ // setting the default column width and row height
+ if ( dlg->getStyle()->type() == Style::BUILTIN && dlg->getStyle()->name() == "Default" )
+ {
+ if ( (int) height->value() != (int) dlg->heightSize )
+ {
+ Format::setGlobalRowHeight( height->value() );
+ }
+ if ( (int) width->value() != (int) dlg->widthSize )
+ {
+ Format::setGlobalColWidth( width->value() );
+ }
+ }
+}
+
+void CellFormatPagePosition::apply(FormatManipulator* _obj)
+{
+ Format::Align ax;
+ Format::AlignY ay;
+
+ if ( top->isChecked() )
+ ay = Format::Top;
+ else if ( bottom->isChecked() )
+ ay = Format::Bottom;
+ else if ( middle->isChecked() )
+ ay = Format::Middle;
+ else
+ ay = Format::Middle; // Default, just in case
+
+ if ( left->isChecked() )
+ ax = Format::Left;
+ else if ( right->isChecked() )
+ ax = Format::Right;
+ else if ( center->isChecked() )
+ ax = Format::Center;
+ else if ( standard->isChecked() )
+ ax = Format::Undefined;
+ else
+ ax = Format::Undefined; //Default, just in case
+
+ if ( top->isChecked() && ay != dlg->alignY )
+ _obj->setVerticalAlignment( Format::Top );
+ else if ( bottom->isChecked() && ay != dlg->alignY )
+ _obj->setVerticalAlignment( Format::Bottom );
+ else if ( middle->isChecked() && ay != dlg->alignY )
+ _obj->setVerticalAlignment( Format::Middle );
+
+ if ( left->isChecked() && ax != dlg->alignX )
+ _obj->setHorizontalAlignment( Format::Left );
+ else if ( right->isChecked() && ax != dlg->alignX )
+ _obj->setHorizontalAlignment( Format::Right );
+ else if ( center->isChecked() && ax != dlg->alignX )
+ _obj->setHorizontalAlignment( Format::Center );
+ else if ( standard->isChecked() && ax != dlg->alignX )
+ _obj->setHorizontalAlignment( Format::Undefined );
+
+ if ( m_bOptionText )
+ {
+ if ( multi->isEnabled() )
+ _obj->setMultiRow( multi->isChecked() );
+ else
+ _obj->setMultiRow( false );
+ }
+
+ if ( m_bOptionText )
+ {
+ if ( vertical->isEnabled() )
+ _obj->setVerticalText( vertical->isChecked() );
+ else
+ _obj->setVerticalText( false );
+ }
+
+ if ( dlg->textRotation!=angleRotation->value() )
+ _obj->setAngle( (-angleRotation->value() ) );
+ if ( m_indent->isEnabled()
+ && dlg->indent != m_indent->value() )
+ _obj->setIndent( m_indent->value() );
+}
+
+double CellFormatPagePosition::getSizeHeight() const
+{
+ if ( defaultHeight->isChecked() )
+ return dlg->defaultHeightSize; // guess who calls this!
+ else
+ return height->value();
+}
+
+double CellFormatPagePosition::getSizeWidth() const
+{
+ if ( defaultWidth->isChecked() )
+ return dlg->defaultWidthSize; // guess who calls this!
+ else
+ return width->value();
+}
+
+
+
+/***************************************************************************
+ *
+ * BorderButton
+ *
+ ***************************************************************************/
+
+BorderButton::BorderButton( QWidget *parent, const char *_name ) : QPushButton(parent,_name)
+{
+ penStyle = Qt::NoPen;
+ penWidth = 1;
+ penColor = colorGroup().text();
+ setToggleButton( true );
+ setOn( false);
+ setChanged(false);
+}
+void BorderButton::mousePressEvent( QMouseEvent * )
+{
+
+ this->setOn(!isOn());
+ emit clicked( this );
+}
+
+void BorderButton::setUndefined()
+{
+ setPenStyle(SolidLine );
+ setPenWidth(1);
+ setColor(colorGroup().midlight());
+}
+
+
+void BorderButton::unselect()
+{
+ setOn(false);
+ setPenWidth(1);
+ setPenStyle(Qt::NoPen);
+ setColor( colorGroup().text() );
+ setChanged(true);
+}
+
+
+
+/***************************************************************************
+ *
+ * Border
+ *
+ ***************************************************************************/
+
+Border::Border( QWidget *parent, const char *_name,bool _oneCol, bool _oneRow )
+ : QFrame( parent, _name )
+{
+ oneCol=_oneCol;
+ oneRow=_oneRow;
+}
+
+
+#define OFFSETX 5
+#define OFFSETY 5
+void Border::paintEvent( QPaintEvent *_ev )
+{
+ QFrame::paintEvent( _ev );
+ QPen pen;
+ QPainter painter;
+ painter.begin( this );
+ pen=QPen( colorGroup().midlight(),2,SolidLine);
+ painter.setPen( pen );
+
+ painter.drawLine( OFFSETX-5, OFFSETY, OFFSETX , OFFSETY );
+ painter.drawLine( OFFSETX, OFFSETY-5, OFFSETX , OFFSETY );
+ painter.drawLine( width()-OFFSETX, OFFSETY, width() , OFFSETY );
+ painter.drawLine( width()-OFFSETX, OFFSETY-5, width()-OFFSETX , OFFSETY );
+
+ painter.drawLine( OFFSETX, height()-OFFSETY, OFFSETX , height() );
+ painter.drawLine( OFFSETX-5, height()-OFFSETY, OFFSETX , height()-OFFSETY );
+
+ painter.drawLine( width()-OFFSETX, height()-OFFSETY, width() , height()-OFFSETY );
+ painter.drawLine( width()-OFFSETX, height()-OFFSETY, width()-OFFSETX , height() );
+ if (oneCol==false)
+ {
+ painter.drawLine( width()/2, OFFSETY-5, width()/2 , OFFSETY );
+ painter.drawLine( width()/2-5, OFFSETY, width()/2+5 , OFFSETY );
+ painter.drawLine( width()/2, height()-OFFSETY, width()/2 , height() );
+ painter.drawLine( width()/2-5, height()-OFFSETY, width()/2+5 , height()-OFFSETY );
+ }
+ if (oneRow==false)
+ {
+ painter.drawLine( OFFSETX-5, height()/2, OFFSETX , height()/2 );
+ painter.drawLine( OFFSETX, height()/2-5, OFFSETX , height()/2+5 );
+ painter.drawLine( width()-OFFSETX, height()/2, width(), height()/2 );
+ painter.drawLine( width()-OFFSETX, height()/2-5, width()-OFFSETX , height()/2+5 );
+ }
+ painter.end();
+ emit redraw();
+}
+
+void Border::mousePressEvent( QMouseEvent* _ev )
+{
+ emit choosearea(_ev);
+}
+
+
+
+/***************************************************************************
+ *
+ * CellFormatPageBorder
+ *
+ ***************************************************************************/
+
+CellFormatPageBorder::CellFormatPageBorder( QWidget* parent, CellFormatDialog *_dlg )
+ : QWidget( parent ),
+ dlg( _dlg )
+{
+ sheet = dlg->getSheet();
+
+ InitializeGrids();
+ InitializeBorderButtons();
+ InitializePatterns();
+ SetConnections();
+
+ preview->slotSelect();
+ pattern[2]->slotSelect();
+
+ style->setEnabled(false);
+ size->setEnabled(false);
+ preview->setPattern( black , 1, SolidLine );
+ this->resize( 400, 400 );
+}
+
+void CellFormatPageBorder::InitializeGrids()
+{
+ QGridLayout *grid = new QGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
+ QGridLayout *grid2 = NULL;
+ QGroupBox* tmpQGroupBox = NULL;
+
+ /***********************/
+ /* here is the data to initialize all the border buttons with */
+ const char borderButtonNames[BorderType_END][20] =
+ {"top", "bottom", "left", "right", "vertical", "fall", "go", "horizontal"};
+
+ const char shortcutButtonNames[BorderShortcutType_END][20] =
+ {"remove", "all", "outline"};
+
+ QString borderButtonIconNames[BorderType_END] =
+ {"border_top", "border_bottom", "border_left", "border_right",
+ "border_vertical", "border_horizontal", "border_fall", "border_up"};
+
+ QString shortcutButtonIconNames[BorderShortcutType_END] =
+ { "border_remove", "", "border_outline"};
+
+ int borderButtonPositions[BorderType_END][2] =
+ {{0,2}, {4,2}, {2,0}, {2,4}, {4,4}, {4,0}, {0,0}, {0,4}};
+
+ int shortcutButtonPositions[BorderShortcutType_END][2] =
+ { {0,0}, {0,1},{0,2} };
+ /***********************/
+
+ /* set up a layout box for most of the border setting buttons */
+ tmpQGroupBox = new QGroupBox( this, "GroupBox_1" );
+ tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
+ tmpQGroupBox->setTitle( i18n("Border") );
+ tmpQGroupBox->setAlignment( AlignLeft );
+ grid2 = new QGridLayout(tmpQGroupBox,6,5,KDialog::marginHint(), KDialog::spacingHint());
+ int fHeight = tmpQGroupBox->fontMetrics().height();
+ grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
+
+ area=new Border(tmpQGroupBox,"area",dlg->oneCol,dlg->oneRow);
+ grid2->addMultiCellWidget(area,2,4,1,3);
+ area->setBackgroundColor( colorGroup().base() );
+
+ /* initailize the buttons that are in this box */
+ for (int i=BorderType_Top; i < BorderType_END; i++)
+ {
+ borderButtons[i] = new BorderButton(tmpQGroupBox,
+ borderButtonNames[i]);
+ loadIcon(borderButtonIconNames[i], borderButtons[i]);
+ grid2->addWidget(borderButtons[i], borderButtonPositions[i][0] + 1,
+ borderButtonPositions[i][1]);
+ }
+
+ grid->addMultiCellWidget(tmpQGroupBox,0,2,0,0);
+
+ /* the remove, all, and outline border buttons are in a second box down
+ below.*/
+
+ tmpQGroupBox = new QGroupBox( this, "GroupBox_3" );
+ tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
+ tmpQGroupBox->setTitle( i18n("Preselect") );
+ tmpQGroupBox->setAlignment( AlignLeft );
+
+ grid2 = new QGridLayout(tmpQGroupBox,1,3,KDialog::marginHint(), KDialog::spacingHint());
+
+ /* the "all" button is different depending on what kind of region is currently
+ selected */
+ if ((dlg->oneRow==true)&&(dlg->oneCol==false))
+ {
+ shortcutButtonIconNames[BorderShortcutType_All] = "border_vertical";
+ }
+ else if ((dlg->oneRow==false)&&(dlg->oneCol==true))
+ {
+ shortcutButtonIconNames[BorderShortcutType_All] = "border_horizontal";
+ }
+ else
+ {
+ shortcutButtonIconNames[BorderShortcutType_All] = "border_inside";
+ }
+
+ for (int i=BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
+ {
+ shortcutButtons[i] = new BorderButton(tmpQGroupBox,
+ shortcutButtonNames[i]);
+ loadIcon(shortcutButtonIconNames[i], shortcutButtons[i]);
+ grid2->addWidget(shortcutButtons[i], shortcutButtonPositions[i][0],
+ shortcutButtonPositions[i][1]);
+ }
+
+ if (dlg->oneRow && dlg->oneCol)
+ {
+ shortcutButtons[BorderShortcutType_All]->setEnabled(false);
+ }
+
+ grid->addMultiCellWidget(tmpQGroupBox,3,4,0,0);
+
+ /* now set up the group box with the pattern selector */
+ tmpQGroupBox = new QGroupBox( this, "GroupBox_10" );
+ tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
+ tmpQGroupBox->setTitle( i18n("Pattern") );
+ tmpQGroupBox->setAlignment( AlignLeft );
+
+ grid2 = new QGridLayout(tmpQGroupBox,7,2,KDialog::marginHint(), KDialog::spacingHint());
+ fHeight = tmpQGroupBox->fontMetrics().height();
+ grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
+
+ char name[] = "PatternXX";
+ Q_ASSERT(NUM_BORDER_PATTERNS < 100);
+
+ for (int i=0; i < NUM_BORDER_PATTERNS; i++)
+ {
+ name[7] = '0' + (i+1) / 10;
+ name[8] = '0' + (i+1) % 10;
+ pattern[i] = new PatternSelect( tmpQGroupBox, name );
+ pattern[i]->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(pattern[i], i % 5 + 1, i / 5);
+ /* this puts them in the pattern:
+ 1 6
+ 2 7
+ 3 8
+ 4 9
+ 5 10
+ */
+ }
+
+ color = new KColorButton (tmpQGroupBox, "PushButton_1" );
+ grid2->addWidget(color,7,1);
+
+ QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_6" );
+ tmpQLabel->setText( i18n("Color:") );
+ grid2->addWidget(tmpQLabel,7,0);
+
+ /* tack on the 'customize' border pattern selector */
+ QGridLayout *grid3 = new QGridLayout( this, 2, 2, KDialog::marginHint(), KDialog::spacingHint() );
+ customize = new QCheckBox(i18n("Customize"),tmpQGroupBox);
+ grid3->addWidget(customize,0,0);
+ connect( customize, SIGNAL( clicked()), SLOT(cutomize_chosen_slot()) );
+
+ size=new QComboBox(true,tmpQGroupBox);
+ grid3->addWidget(size,1,1);
+ size->setValidator(new KIntValidator( size ));
+ QString tmp;
+ for ( int i=0;i<10;i++)
+ {
+ tmp=tmp.setNum(i);
+ size->insertItem(tmp);
+ }
+ size->setCurrentItem(1);
+
+ style=new QComboBox(tmpQGroupBox);
+ grid3->addWidget(style,1,0);
+ style->insertItem(paintFormatPixmap(DotLine),0 );
+ style->insertItem(paintFormatPixmap(DashLine) ,1);
+ style->insertItem(paintFormatPixmap(DashDotLine),2 );
+ style->insertItem(paintFormatPixmap(DashDotDotLine),3 );
+ style->insertItem(paintFormatPixmap(SolidLine),4);
+ style->setBackgroundColor( colorGroup().background() );
+
+ grid2->addMultiCell(grid3,6,6,0,1);
+ grid->addMultiCellWidget(tmpQGroupBox,0,3,1,1);
+
+ /* Now the preview box is put together */
+ tmpQGroupBox = new QGroupBox(this, "GroupBox_4" );
+ tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
+ tmpQGroupBox->setTitle( i18n("Preview") );
+ tmpQGroupBox->setAlignment( AlignLeft );
+
+ grid2 = new QGridLayout(tmpQGroupBox,1,1,KDialog::marginHint(), KDialog::spacingHint());
+ fHeight = tmpQGroupBox->fontMetrics().height();
+ grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
+
+ preview = new PatternSelect( tmpQGroupBox, "Pattern_preview" );
+ preview->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(preview,1,0);
+
+ grid->addWidget(tmpQGroupBox,4,1);
+}
+
+void CellFormatPageBorder::InitializeBorderButtons()
+{
+ for (int i=BorderType_Top; i < BorderType_END; i++)
+ {
+ if (dlg->borders[i].style != Qt::NoPen ||
+ !dlg->borders[i].bStyle )
+ {
+ /* the horozontil and vertical buttons might be disabled depending on what
+ kind of area is selected so check that first. */
+ if ((dlg->oneRow == true && i == BorderType_Horizontal) ||
+ (dlg->oneCol == true && i == BorderType_Vertical))
+ {
+ borderButtons[i]->setEnabled(false);
+ }
+ else if ( dlg->borders[i].bColor && dlg->borders[i].bStyle )
+ {
+ borderButtons[i]->setPenStyle(dlg->borders[i].style );
+ borderButtons[i]->setPenWidth(dlg->borders[i].width);
+ borderButtons[i]->setColor(dlg->borders[i].color);
+ borderButtons[i]->setOn(true);
+ }
+ else
+ {
+ borderButtons[i]->setUndefined();
+ }
+ }
+ }
+
+
+}
+
+void CellFormatPageBorder::InitializePatterns()
+{
+ pattern[0]->setPattern( black, 1, DotLine );
+ pattern[1]->setPattern( black, 1, DashLine );
+ pattern[2]->setPattern( black, 1, SolidLine );
+ pattern[3]->setPattern( black, 1, DashDotLine );
+ pattern[4]->setPattern( black, 1, DashDotDotLine );
+ pattern[5]->setPattern( black, 2, SolidLine );
+ pattern[6]->setPattern( black, 3, SolidLine );
+ pattern[7]->setPattern( black, 4, SolidLine );
+ pattern[8]->setPattern( black, 5, SolidLine );
+ pattern[9]->setPattern( black, 1, NoPen );
+
+ slotSetColorButton( black );
+}
+
+void CellFormatPageBorder::SetConnections()
+{
+ connect( color, SIGNAL( changed( const QColor & ) ),
+ this, SLOT( slotSetColorButton( const QColor & ) ) );
+
+ for (int i=0; i < NUM_BORDER_PATTERNS; i++)
+ {
+ connect( pattern[i], SIGNAL( clicked( PatternSelect* ) ),
+ this, SLOT( slotUnselect2( PatternSelect* ) ) );
+ }
+
+ for (int i = BorderType_Top; i < BorderType_END; i++)
+ {
+ connect( borderButtons[i], SIGNAL( clicked (BorderButton *) ),
+ this, SLOT( changeState( BorderButton *) ) );
+ }
+
+ for (int i = BorderShortcutType_Remove; i < BorderShortcutType_END; i++)
+ {
+ connect( shortcutButtons[i], SIGNAL( clicked(BorderButton *) ),
+ this, SLOT( preselect(BorderButton *) ) );
+ }
+
+ connect( area ,SIGNAL( redraw()),this,SLOT(draw()));
+ connect( area ,SIGNAL( choosearea(QMouseEvent * )),
+ this,SLOT( slotPressEvent(QMouseEvent *)));
+
+ connect( style, SIGNAL( activated(int)), this, SLOT(slotChangeStyle(int)));
+ connect( size, SIGNAL( textChanged(const QString &)),
+ this, SLOT(slotChangeStyle(const QString &)));
+ connect( size ,SIGNAL( activated(int)), this, SLOT(slotChangeStyle(int)));
+}
+
+void CellFormatPageBorder::cutomize_chosen_slot()
+{
+ if ( customize->isChecked() )
+ {
+ style->setEnabled( true );
+ size->setEnabled( true );
+ slotUnselect2( preview );
+ }
+ else
+ {
+ style->setEnabled( false );
+ size->setEnabled( false );
+ pattern[2]->slotSelect();
+ preview->setPattern( black , 1, SolidLine );
+ }
+}
+
+void CellFormatPageBorder::slotChangeStyle(const QString &)
+{
+ /* if they try putting text in the size box, then erase the line */
+ slotChangeStyle(0);
+}
+
+void CellFormatPageBorder::slotChangeStyle(int)
+{
+ int index = style->currentItem();
+ QString tmp;
+ int penSize = size->currentText().toInt();
+ if ( !penSize)
+ {
+ preview->setPattern( preview->getColor(), penSize, NoPen );
+ }
+ else
+ {
+ switch(index)
+ {
+ case 0:
+ preview->setPattern( preview->getColor(), penSize, DotLine );
+ break;
+ case 1:
+ preview->setPattern( preview->getColor(), penSize, DashLine );
+ break;
+ case 2:
+ preview->setPattern( preview->getColor(), penSize, DashDotLine );
+ break;
+ case 3:
+ preview->setPattern( preview->getColor(), penSize, DashDotDotLine );
+ break;
+ case 4:
+ preview->setPattern( preview->getColor(), penSize, SolidLine );
+ break;
+ default:
+ kdDebug(36001)<<"Error in combobox\n";
+ break;
+ }
+ }
+ slotUnselect2(preview);
+}
+
+QPixmap CellFormatPageBorder::paintFormatPixmap(PenStyle _style)
+{
+ QPixmap pixmap( style->width(), 14 );
+ QPainter painter;
+ QPen pen;
+ pen=QPen( colorGroup().text(),1,_style);
+ painter.begin( &pixmap );
+ painter.fillRect( 0, 0, style->width(), 14, colorGroup().background() );
+ painter.setPen( pen );
+ painter.drawLine( 0, 7, style->width(), 7 );
+ painter.end();
+ return pixmap;
+}
+
+void CellFormatPageBorder::loadIcon( QString _pix, BorderButton *_button)
+{
+ _button->setPixmap( QPixmap( BarIcon(_pix, Factory::global()) ) );
+}
+
+void CellFormatPageBorder::apply(FormatManipulator* obj)
+{
+ if (borderButtons[BorderType_Horizontal]->isChanged())
+ applyHorizontalOutline(obj);
+
+ if (borderButtons[BorderType_Vertical]->isChanged())
+ applyVerticalOutline(obj);
+
+ if ( borderButtons[BorderType_Left]->isChanged() )
+ applyLeftOutline(obj);
+
+ if ( borderButtons[BorderType_Right]->isChanged() )
+ applyRightOutline(obj);
+
+ if ( borderButtons[BorderType_Top]->isChanged() )
+ applyTopOutline(obj);
+
+ if ( borderButtons[BorderType_Bottom]->isChanged() )
+ applyBottomOutline(obj);
+
+ if ( borderButtons[BorderType_RisingDiagonal]->isChanged() ||
+ borderButtons[BorderType_FallingDiagonal]->isChanged() )
+ applyDiagonalOutline(obj);
+}
+
+void CellFormatPageBorder::applyTopOutline(FormatManipulator* obj)
+{
+ BorderButton * top = borderButtons[BorderType_Top];
+
+ QPen tmpPen( top->getColor(), top->getPenWidth(), top->getPenStyle());
+
+ if ( dlg->getStyle() )
+ {
+ dlg->getStyle()->changeTopBorderPen( tmpPen );
+ }
+ else
+ {
+ if (borderButtons[BorderType_Top]->isChanged())
+ obj->setTopBorderPen( tmpPen );
+ }
+}
+
+void CellFormatPageBorder::applyBottomOutline(FormatManipulator* obj)
+{
+ BorderButton * bottom = borderButtons[BorderType_Bottom];
+
+ QPen tmpPen( bottom->getColor(), bottom->getPenWidth(), bottom->getPenStyle() );
+
+ if ( dlg->getStyle() )
+ {
+ dlg->getStyle()->changeBottomBorderPen( tmpPen );
+ }
+ else
+ {
+ if (borderButtons[BorderType_Bottom]->isChanged())
+ obj->setBottomBorderPen( tmpPen );
+ }
+}
+
+void CellFormatPageBorder::applyLeftOutline(FormatManipulator* obj)
+{
+ BorderButton * left = borderButtons[BorderType_Left];
+ QPen tmpPen( left->getColor(), left->getPenWidth(), left->getPenStyle() );
+
+ if ( dlg->getStyle() )
+ {
+ dlg->getStyle()->changeLeftBorderPen( tmpPen );
+ }
+ else
+ {
+ if (borderButtons[BorderType_Left]->isChanged())
+ obj->setLeftBorderPen( tmpPen );
+ }
+}
+
+void CellFormatPageBorder::applyRightOutline(FormatManipulator* obj)
+{
+ BorderButton* right = borderButtons[BorderType_Right];
+ QPen tmpPen( right->getColor(), right->getPenWidth(), right->getPenStyle() );
+
+ if ( dlg->getStyle() )
+ {
+ dlg->getStyle()->changeRightBorderPen( tmpPen );
+ }
+ else
+ {
+ if (borderButtons[BorderType_Right]->isChanged())
+ obj->setRightBorderPen( tmpPen );
+ }
+}
+
+void CellFormatPageBorder::applyDiagonalOutline(FormatManipulator* obj)
+{
+ BorderButton * fallDiagonal = borderButtons[BorderType_FallingDiagonal];
+ BorderButton * goUpDiagonal = borderButtons[BorderType_RisingDiagonal];
+ QPen tmpPenFall( fallDiagonal->getColor(), fallDiagonal->getPenWidth(),
+ fallDiagonal->getPenStyle());
+ QPen tmpPenGoUp( goUpDiagonal->getColor(), goUpDiagonal->getPenWidth(),
+ goUpDiagonal->getPenStyle());
+
+ if ( dlg->getStyle() )
+ {
+ if ( fallDiagonal->isChanged() )
+ dlg->getStyle()->changeFallBorderPen( tmpPenFall );
+ if ( goUpDiagonal->isChanged() )
+ dlg->getStyle()->changeGoUpBorderPen( tmpPenGoUp );
+ }
+ else
+ {
+ if ( fallDiagonal->isChanged() )
+ obj->setFallDiagonalPen( tmpPenFall );
+ if ( goUpDiagonal->isChanged() )
+ obj->setGoUpDiagonalPen( tmpPenGoUp );
+ }
+}
+
+void CellFormatPageBorder::applyHorizontalOutline(FormatManipulator* obj)
+{
+ QPen tmpPen( borderButtons[BorderType_Horizontal]->getColor(),
+ borderButtons[BorderType_Horizontal]->getPenWidth(),
+ borderButtons[BorderType_Horizontal]->getPenStyle());
+
+ if ( dlg->getStyle() )
+ {
+ dlg->getStyle()->changeTopBorderPen( tmpPen );
+ }
+ else
+ {
+ if (borderButtons[BorderType_Horizontal]->isChanged())
+ obj->setHorizontalPen( tmpPen );
+ }
+}
+
+void CellFormatPageBorder::applyVerticalOutline(FormatManipulator* obj)
+{
+ BorderButton* vertical = borderButtons[BorderType_Vertical];
+ QPen tmpPen( vertical->getColor(), vertical->getPenWidth(),
+ vertical->getPenStyle());
+
+ if ( dlg->getStyle() )
+ {
+ dlg->getStyle()->changeLeftBorderPen( tmpPen );
+ }
+ else
+ {
+ if (borderButtons[BorderType_Vertical]->isChanged())
+ obj->setVerticalPen( tmpPen );
+ }
+}
+
+
+void CellFormatPageBorder::slotSetColorButton( const QColor &_color )
+{
+ currentColor = _color;
+
+ for ( int i = 0; i < NUM_BORDER_PATTERNS; ++i )
+ {
+ pattern[i]->setColor( currentColor );
+ }
+ preview->setColor( currentColor );
+}
+
+void CellFormatPageBorder::slotUnselect2( PatternSelect *_p )
+{
+ for ( int i = 0; i < NUM_BORDER_PATTERNS; ++i )
+ {
+ if ( pattern[i] != _p )
+ {
+ pattern[i]->slotUnselect();
+ }
+ }
+ preview->setPattern( _p->getColor(), _p->getPenWidth(), _p->getPenStyle() );
+}
+
+void CellFormatPageBorder::preselect( BorderButton *_p )
+{
+ BorderButton* top = borderButtons[BorderType_Top];
+ BorderButton* bottom = borderButtons[BorderType_Bottom];
+ BorderButton* left = borderButtons[BorderType_Left];
+ BorderButton* right = borderButtons[BorderType_Right];
+ BorderButton* vertical = borderButtons[BorderType_Vertical];
+ BorderButton* horizontal = borderButtons[BorderType_Horizontal];
+ BorderButton* remove = shortcutButtons[BorderShortcutType_Remove];
+ BorderButton* outline = shortcutButtons[BorderShortcutType_Outline];
+ BorderButton* all = shortcutButtons[BorderShortcutType_All];
+
+ _p->setOn(false);
+ if (_p == remove)
+ {
+ for (int i=BorderType_Top; i < BorderType_END; i++)
+ {
+ if (borderButtons[i]->isOn())
+ {
+ borderButtons[i]->unselect();
+ }
+ }
+ }
+ if (_p==outline)
+ {
+ top->setOn(true);
+ top->setPenWidth(preview->getPenWidth());
+ top->setPenStyle(preview->getPenStyle());
+ top->setColor( currentColor );
+ top->setChanged(true);
+ bottom->setOn(true);
+ bottom->setPenWidth(preview->getPenWidth());
+ bottom->setPenStyle(preview->getPenStyle());
+ bottom->setColor( currentColor );
+ bottom->setChanged(true);
+ left->setOn(true);
+ left->setPenWidth(preview->getPenWidth());
+ left->setPenStyle(preview->getPenStyle());
+ left->setColor( currentColor );
+ left->setChanged(true);
+ right->setOn(true);
+ right->setPenWidth(preview->getPenWidth());
+ right->setPenStyle(preview->getPenStyle());
+ right->setColor( currentColor );
+ right->setChanged(true);
+ }
+ if (_p==all)
+ {
+ if (dlg->oneRow==false)
+ {
+ horizontal->setOn(true);
+ horizontal->setPenWidth(preview->getPenWidth());
+ horizontal->setPenStyle(preview->getPenStyle());
+ horizontal->setColor( currentColor );
+ horizontal->setChanged(true);
+ }
+ if (dlg->oneCol==false)
+ {
+ vertical->setOn(true);
+ vertical->setPenWidth(preview->getPenWidth());
+ vertical->setPenStyle(preview->getPenStyle());
+ vertical->setColor( currentColor );
+ vertical->setChanged(true);
+ }
+ }
+ area->repaint();
+}
+
+void CellFormatPageBorder::changeState( BorderButton *_p)
+{
+ _p->setChanged(true);
+
+ if (_p->isOn())
+ {
+ _p->setPenWidth(preview->getPenWidth());
+ _p->setPenStyle(preview->getPenStyle());
+ _p->setColor( currentColor );
+ }
+ else
+ {
+ _p->setPenWidth(1);
+ _p->setPenStyle(Qt::NoPen);
+ _p->setColor( colorGroup().text() );
+ }
+
+ area->repaint();
+}
+
+void CellFormatPageBorder::draw()
+{
+ BorderButton* top = borderButtons[BorderType_Top];
+ BorderButton* bottom = borderButtons[BorderType_Bottom];
+ BorderButton* left = borderButtons[BorderType_Left];
+ BorderButton* right = borderButtons[BorderType_Right];
+ BorderButton* risingDiagonal = borderButtons[BorderType_RisingDiagonal];
+ BorderButton* fallingDiagonal = borderButtons[BorderType_FallingDiagonal];
+ BorderButton* vertical = borderButtons[BorderType_Vertical];
+ BorderButton* horizontal = borderButtons[BorderType_Horizontal];
+ QPen pen;
+ QPainter painter;
+ painter.begin( area );
+
+ if ((bottom->getPenStyle())!=Qt::NoPen)
+ {
+ pen=QPen( bottom->getColor(), bottom->getPenWidth(),bottom->getPenStyle());
+ painter.setPen( pen );
+ painter.drawLine( OFFSETX, area->height()-OFFSETY, area->width()-OFFSETX , area->height()-OFFSETY );
+ }
+ if ((top->getPenStyle())!=Qt::NoPen)
+ {
+ pen=QPen( top->getColor(), top->getPenWidth(),top->getPenStyle());
+ painter.setPen( pen );
+ painter.drawLine( OFFSETX, OFFSETY, area->width() -OFFSETX, OFFSETY );
+ }
+ if ((left->getPenStyle())!=Qt::NoPen)
+ {
+ pen=QPen( left->getColor(), left->getPenWidth(),left->getPenStyle());
+ painter.setPen( pen );
+ painter.drawLine( OFFSETX, OFFSETY, OFFSETX , area->height()-OFFSETY );
+ }
+ if ((right->getPenStyle())!=Qt::NoPen)
+ {
+ pen=QPen( right->getColor(), right->getPenWidth(),right->getPenStyle());
+ painter.setPen( pen );
+ painter.drawLine( area->width()-OFFSETX, OFFSETY, area->width()-OFFSETX,
+ area->height()-OFFSETY );
+
+ }
+ if ((fallingDiagonal->getPenStyle())!=Qt::NoPen)
+ {
+ pen=QPen( fallingDiagonal->getColor(), fallingDiagonal->getPenWidth(),
+ fallingDiagonal->getPenStyle());
+ painter.setPen( pen );
+ painter.drawLine( OFFSETX, OFFSETY, area->width()-OFFSETX,
+ area->height()-OFFSETY );
+ if (dlg->oneCol==false&& dlg->oneRow==false)
+ {
+ painter.drawLine( area->width()/2, OFFSETY, area->width()-OFFSETX,
+ area->height()/2 );
+ painter.drawLine( OFFSETX,area->height()/2 , area->width()/2,
+ area->height()-OFFSETY );
+ }
+ }
+ if ((risingDiagonal->getPenStyle())!=Qt::NoPen)
+ {
+ pen=QPen( risingDiagonal->getColor(), risingDiagonal->getPenWidth(),
+ risingDiagonal->getPenStyle());
+ painter.setPen( pen );
+ painter.drawLine( OFFSETX, area->height()-OFFSETY , area->width()-OFFSETX ,
+ OFFSETY );
+ if (dlg->oneCol==false&& dlg->oneRow==false)
+ {
+ painter.drawLine( area->width()/2, OFFSETY, OFFSETX, area->height()/2 );
+ painter.drawLine( area->width()/2,area->height()-OFFSETY ,
+ area->width()-OFFSETX, area->height()/2 );
+ }
+
+ }
+ if ((vertical->getPenStyle())!=Qt::NoPen)
+ {
+ pen=QPen( vertical->getColor(), vertical->getPenWidth(),
+ vertical->getPenStyle());
+ painter.setPen( pen );
+ painter.drawLine( area->width()/2, 5 , area->width()/2 , area->height()-5 );
+ }
+ if ((horizontal->getPenStyle())!=Qt::NoPen)
+ {
+ pen=QPen( horizontal->getColor(), horizontal->getPenWidth(),
+ horizontal->getPenStyle());
+ painter.setPen( pen );
+ painter.drawLine( OFFSETX,area->height()/2,area->width()-OFFSETX,
+ area->height()/2 );
+ }
+ painter.end();
+}
+
+void CellFormatPageBorder::invertState(BorderButton *_p)
+{
+ if (_p->isOn())
+ {
+ _p->unselect();
+ }
+ else
+ {
+ _p->setOn(true);
+ _p->setPenWidth(preview->getPenWidth());
+ _p->setPenStyle(preview->getPenStyle());
+ _p->setColor( currentColor );
+ _p->setChanged(true);
+ }
+}
+
+void CellFormatPageBorder::slotPressEvent(QMouseEvent *_ev)
+{
+ BorderButton* top = borderButtons[BorderType_Top];
+ BorderButton* bottom = borderButtons[BorderType_Bottom];
+ BorderButton* left = borderButtons[BorderType_Left];
+ BorderButton* right = borderButtons[BorderType_Right];
+ BorderButton* vertical = borderButtons[BorderType_Vertical];
+ BorderButton* horizontal = borderButtons[BorderType_Horizontal];
+
+
+ QRect rect(OFFSETX,OFFSETY-8,area->width()-OFFSETX,OFFSETY+8);
+ if (rect.contains(QPoint(_ev->x(),_ev->y())))
+ {
+ if (((top->getPenWidth()!=preview->getPenWidth()) ||
+ (top->getColor()!=currentColor) ||
+ (top->getPenStyle()!=preview->getPenStyle()))
+ && top->isOn())
+ {
+ top->setPenWidth(preview->getPenWidth());
+ top->setPenStyle(preview->getPenStyle());
+ top->setColor( currentColor );
+ top->setChanged(true);
+ }
+ else
+ invertState(top);
+ }
+ rect.setCoords(OFFSETX,area->height()-OFFSETY-8,area->width()-OFFSETX,
+ area->height()-OFFSETY+8);
+ if (rect.contains(QPoint(_ev->x(),_ev->y())))
+ {
+ if (((bottom->getPenWidth()!=preview->getPenWidth()) ||
+ (bottom->getColor()!=currentColor) ||
+ (bottom->getPenStyle()!=preview->getPenStyle()))
+ && bottom->isOn())
+ {
+ bottom->setPenWidth(preview->getPenWidth());
+ bottom->setPenStyle(preview->getPenStyle());
+ bottom->setColor( currentColor );
+ bottom->setChanged(true);
+ }
+ else
+ invertState(bottom);
+ }
+
+ rect.setCoords(OFFSETX-8,OFFSETY,OFFSETX+8,area->height()-OFFSETY);
+ if (rect.contains(QPoint(_ev->x(),_ev->y())))
+ {
+ if (((left->getPenWidth()!=preview->getPenWidth()) ||
+ (left->getColor()!=currentColor) ||
+ (left->getPenStyle()!=preview->getPenStyle()))
+ && left->isOn())
+ {
+ left->setPenWidth(preview->getPenWidth());
+ left->setPenStyle(preview->getPenStyle());
+ left->setColor( currentColor );
+ left->setChanged(true);
+ }
+ else
+ invertState(left);
+ }
+ rect.setCoords(area->width()-OFFSETX-8,OFFSETY,area->width()-OFFSETX+8,
+ area->height()-OFFSETY);
+ if (rect.contains(QPoint(_ev->x(),_ev->y())))
+ {
+ if (((right->getPenWidth()!=preview->getPenWidth()) ||
+ (right->getColor()!=currentColor) ||
+ (right->getPenStyle()!=preview->getPenStyle()))
+ && right->isOn())
+ {
+ right->setPenWidth(preview->getPenWidth());
+ right->setPenStyle(preview->getPenStyle());
+ right->setColor( currentColor );
+ right->setChanged(true);
+ }
+ else
+ invertState(right);
+ }
+
+//don't work because I don't know how create a rectangle
+//for diagonal
+/*rect.setCoords(OFFSETX,OFFSETY,XLEN-OFFSETX,YHEI-OFFSETY);
+if (rect.contains(QPoint(_ev->x(),_ev->y())))
+ {
+ invertState(fallDiagonal);
+ }
+rect.setCoords(OFFSETX,YHEI-OFFSETY,XLEN-OFFSETX,OFFSETY);
+if (rect.contains(QPoint(_ev->x(),_ev->y())))
+ {
+ invertState(goUpDiagonal);
+ } */
+
+ if (dlg->oneCol==false)
+ {
+ rect.setCoords(area->width()/2-8,OFFSETY,area->width()/2+8,
+ area->height()-OFFSETY);
+
+ if (rect.contains(QPoint(_ev->x(),_ev->y())))
+ {
+ if (((vertical->getPenWidth()!=preview->getPenWidth()) ||
+ (vertical->getColor()!=currentColor) ||
+ (vertical->getPenStyle()!=preview->getPenStyle()))
+ && vertical->isOn())
+ {
+ vertical->setPenWidth(preview->getPenWidth());
+ vertical->setPenStyle(preview->getPenStyle());
+ vertical->setColor( currentColor );
+ vertical->setChanged(true);
+ }
+ else
+ invertState(vertical);
+ }
+ }
+ if (dlg->oneRow==false)
+ {
+ rect.setCoords(OFFSETX,area->height()/2-8,area->width()-OFFSETX,
+ area->height()/2+8);
+ if (rect.contains(QPoint(_ev->x(),_ev->y())))
+ {
+ if (((horizontal->getPenWidth()!=preview->getPenWidth()) ||
+ (horizontal->getColor()!=currentColor) ||
+ (horizontal->getPenStyle()!=preview->getPenStyle()))
+ && horizontal->isOn())
+ {
+ horizontal->setPenWidth(preview->getPenWidth());
+ horizontal->setPenStyle(preview->getPenStyle());
+ horizontal->setColor( currentColor );
+ horizontal->setChanged(true);
+ }
+ else
+ invertState(horizontal);
+ }
+ }
+
+ area->repaint();
+}
+
+
+
+/***************************************************************************
+ *
+ * BrushSelect
+ *
+ ***************************************************************************/
+
+BrushSelect::BrushSelect( QWidget *parent, const char * ) : QFrame( parent )
+{
+ brushStyle = Qt::NoBrush;
+ brushColor = Qt::red;
+ selected = false;
+}
+
+void BrushSelect::setPattern( const QColor &_color,BrushStyle _style )
+{
+ brushStyle = _style;
+ brushColor = _color;
+ repaint();
+}
+
+
+void BrushSelect::paintEvent( QPaintEvent *_ev )
+{
+ QFrame::paintEvent( _ev );
+
+ QPainter painter;
+ QBrush brush(brushColor,brushStyle);
+ painter.begin( this );
+ painter.setPen( Qt::NoPen );
+ painter.setBrush( brush);
+ painter.drawRect( 2, 2, width()-4, height()-4);
+ painter.end();
+}
+
+void BrushSelect::mousePressEvent( QMouseEvent * )
+{
+ slotSelect();
+
+ emit clicked( this );
+}
+
+void BrushSelect::slotUnselect()
+{
+ selected = false;
+
+ setLineWidth( 1 );
+ setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ repaint();
+}
+
+void BrushSelect::slotSelect()
+{
+ selected = true;
+
+ setLineWidth( 2 );
+ setFrameStyle( QFrame::Panel | QFrame::Plain );
+ repaint();
+}
+
+
+
+/***************************************************************************
+ *
+ * CellFormatPagePattern
+ *
+ ***************************************************************************/
+
+CellFormatPagePattern::CellFormatPagePattern( QWidget* parent, CellFormatDialog *_dlg ) : QWidget( parent )
+{
+ dlg = _dlg;
+
+ bBgColorUndefined = !dlg->bBgColor;
+
+ QGridLayout *grid = new QGridLayout(this,5,2,KDialog::marginHint(), KDialog::spacingHint());
+
+ QGroupBox* tmpQGroupBox;
+ tmpQGroupBox = new QGroupBox( this, "GroupBox_20" );
+ tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
+ tmpQGroupBox->setTitle( i18n("Pattern") );
+ tmpQGroupBox->setAlignment( AlignLeft );
+
+ QGridLayout *grid2 = new QGridLayout(tmpQGroupBox,8,3,KDialog::marginHint(), KDialog::spacingHint());
+ int fHeight = tmpQGroupBox->fontMetrics().height();
+ grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
+
+
+ brush1 = new BrushSelect( tmpQGroupBox, "Frame_1" );
+ brush1->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush1,1,0);
+
+ brush2 = new BrushSelect( tmpQGroupBox, "Frame_2" );
+ brush2->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush2,1,1);
+
+ brush3 = new BrushSelect( tmpQGroupBox, "Frame_3" );
+ brush3->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush3,1,2);
+
+ brush4 = new BrushSelect( tmpQGroupBox, "Frame_4" );
+ brush4->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush4,2,0);
+
+ brush5 = new BrushSelect( tmpQGroupBox, "Frame_5" );
+ brush5->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush5,2,1);
+
+ brush6 = new BrushSelect( tmpQGroupBox, "Frame_6" );
+ brush6->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush6,2,2);
+
+ brush7 = new BrushSelect( tmpQGroupBox, "Frame_7" );
+ brush7->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush7,3,0);
+
+ brush8 = new BrushSelect( tmpQGroupBox, "Frame_8" );
+ brush8->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush8,3,1);
+
+ brush9 = new BrushSelect( tmpQGroupBox, "Frame_9" );
+ brush9->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush9,3,2);
+
+ brush10 = new BrushSelect( tmpQGroupBox, "Frame_10" );
+ brush10->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush10,4,0);
+
+ brush11 = new BrushSelect( tmpQGroupBox, "Frame_11" );
+ brush11->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush11,4,1);
+
+ brush12 = new BrushSelect( tmpQGroupBox, "Frame_12" );
+ brush12->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush12,4,2);
+
+ brush13 = new BrushSelect( tmpQGroupBox, "Frame_13" );
+ brush13->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush13,5,0);
+
+ brush14 = new BrushSelect( tmpQGroupBox, "Frame_14" );
+ brush14->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush14,5,1);
+
+ brush15 = new BrushSelect( tmpQGroupBox, "Frame_15" );
+ brush15->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(brush15,5,2);
+
+ QGridLayout *grid3 = new QGridLayout( 1, 2 );
+ color = new KColorButton (tmpQGroupBox, "ColorButton_1" );
+ grid3->addWidget(color,0,1);
+
+ QLabel *tmpQLabel = new QLabel( tmpQGroupBox, "Label_1" );
+ tmpQLabel->setText( i18n("Color:") );
+ grid3->addWidget(tmpQLabel,0,0);
+
+ grid2->addMultiCell(grid3,6,6,0,2);
+
+ grid3 = new QGridLayout( 1, 3 );
+ grid3->setSpacing(KDialog::spacingHint());
+
+ tmpQLabel = new QLabel( tmpQGroupBox, "Label_2" );
+ grid3->addWidget(tmpQLabel,0,0);
+ tmpQLabel->setText( i18n("Background color:") );
+
+ bgColorButton = new KColorButton( tmpQGroupBox, "ColorButton" );
+ grid3->addWidget(bgColorButton,0,1);
+ if ( dlg->bBgColor )
+ bgColor = dlg->bgColor;
+ else
+ bgColor = colorGroup().base();
+
+ if (!bgColor.isValid())
+ bgColor = colorGroup().base();
+
+ bgColorButton->setColor( bgColor );
+ connect( bgColorButton, SIGNAL( changed( const QColor & ) ),
+ this, SLOT( slotSetBackgroundColor( const QColor & ) ) );
+
+ notAnyColor=new QPushButton(i18n("No Color"),tmpQGroupBox);
+ grid3->addWidget(notAnyColor,0,2);
+ connect( notAnyColor, SIGNAL( clicked( ) ),
+ this, SLOT( slotNotAnyColor( ) ) );
+ b_notAnyColor=false;
+
+ grid2->addMultiCell(grid3,7,7,0,2);
+
+ grid->addMultiCellWidget(tmpQGroupBox,0,3,0,0);
+
+ tmpQGroupBox = new QGroupBox( this, "GroupBox1" );
+ tmpQGroupBox->setTitle( i18n("Preview") );
+ tmpQGroupBox->setFrameStyle( QFrame::Box | QFrame::Sunken );
+ tmpQGroupBox->setAlignment( AlignLeft );
+
+ grid2 = new QGridLayout(tmpQGroupBox,2,1,KDialog::marginHint(), KDialog::spacingHint());
+ fHeight = tmpQGroupBox->fontMetrics().height();
+ grid2->addRowSpacing( 0, fHeight/2 ); // groupbox title
+
+ current = new BrushSelect( tmpQGroupBox, "Current" );
+ current->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ grid2->addWidget(current,1,0);
+ grid->addWidget( tmpQGroupBox,4,0);
+
+ connect( brush1, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush2, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush3, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush4, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush5, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush6, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush7, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush8, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush9, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush10, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush11, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush12, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush13, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush14, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+ connect( brush15, SIGNAL( clicked( BrushSelect* ) ),
+ this, SLOT( slotUnselect2( BrushSelect* ) ) );
+
+ brush1->setPattern( Qt::red, Qt::VerPattern );
+ brush2->setPattern( Qt::red,Qt::HorPattern );
+ brush3->setPattern( Qt::red,Qt::Dense1Pattern );
+ brush4->setPattern( Qt::red,Qt::Dense2Pattern );
+ brush5->setPattern( Qt::red,Qt::Dense3Pattern );
+ brush6->setPattern( Qt::red,Qt::Dense4Pattern );
+ brush7->setPattern( Qt::red,Qt::Dense5Pattern );
+ brush8->setPattern( Qt::red,Qt::Dense6Pattern );
+ brush9->setPattern( Qt::red,Qt::Dense7Pattern );
+ brush10->setPattern( Qt::red,Qt::CrossPattern );
+ brush11->setPattern( Qt::red,Qt::BDiagPattern );
+ brush12->setPattern( Qt::red,Qt::FDiagPattern );
+ brush13->setPattern( Qt::red,Qt::VerPattern );
+ brush14->setPattern( Qt::red,Qt::DiagCrossPattern );
+ brush15->setPattern( Qt::red,Qt::NoBrush );
+
+ current->setPattern(dlg->brushColor,dlg->brushStyle);
+ current->slotSelect();
+ selectedBrush=current;
+ color->setColor(dlg->brushColor);
+ current->setBackgroundColor( bgColor );
+
+ connect( color, SIGNAL( changed( const QColor & ) ),
+ this, SLOT( slotSetColorButton( const QColor & ) ) );
+
+ slotSetColorButton( dlg->brushColor );
+ init();
+ this->resize( 400, 400 );
+}
+
+void CellFormatPagePattern::slotNotAnyColor()
+{
+ b_notAnyColor = true;
+ bgColorButton->setColor( colorGroup().base() );
+ current->setBackgroundColor( colorGroup().base() );
+}
+
+void CellFormatPagePattern::slotSetBackgroundColor( const QColor &_color )
+{
+ bgColor =_color;
+ current->setBackgroundColor( bgColor );
+ bBgColorUndefined = false;
+ b_notAnyColor = false;
+}
+
+void CellFormatPagePattern::init()
+{
+ if (dlg->brushStyle == Qt::VerPattern)
+ {
+ brush1->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::HorPattern)
+ {
+ brush2->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::Dense1Pattern)
+ {
+ brush3->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::Dense2Pattern)
+ {
+ brush4->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::Dense3Pattern)
+ {
+ brush5->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::Dense4Pattern)
+ {
+ brush6->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::Dense5Pattern)
+ {
+ brush7->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::Dense6Pattern)
+ {
+ brush8->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::Dense7Pattern)
+ {
+ brush9->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::CrossPattern)
+ {
+ brush10->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::BDiagPattern)
+ {
+ brush11->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::FDiagPattern)
+ {
+ brush12->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::VerPattern)
+ {
+ brush13->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::DiagCrossPattern)
+ {
+ brush14->slotSelect();
+ }
+ else if (dlg->brushStyle == Qt::NoBrush)
+ {
+ brush15->slotSelect();
+ }
+ else
+ kdDebug(36001) << "Error in brushStyle" << endl;
+}
+
+void CellFormatPagePattern::slotSetColorButton( const QColor &_color )
+{
+ currentColor = _color;
+
+ brush1->setBrushColor( currentColor );
+ brush2->setBrushColor( currentColor );
+ brush3->setBrushColor( currentColor );
+ brush4->setBrushColor( currentColor );
+ brush5->setBrushColor( currentColor );
+ brush6->setBrushColor( currentColor );
+ brush7->setBrushColor( currentColor );
+ brush8->setBrushColor( currentColor );
+ brush9->setBrushColor( currentColor );
+ brush10->setBrushColor( currentColor );
+ brush11->setBrushColor( currentColor );
+ brush12->setBrushColor( currentColor );
+ brush13->setBrushColor( currentColor );
+ brush14->setBrushColor( currentColor );
+ brush15->setBrushColor( currentColor );
+ current->setBrushColor( currentColor );
+}
+
+void CellFormatPagePattern::slotUnselect2( BrushSelect *_p )
+{
+ selectedBrush = _p;
+
+ if ( brush1 != _p )
+ brush1->slotUnselect();
+ if ( brush2 != _p )
+ brush2->slotUnselect();
+ if ( brush3 != _p )
+ brush3->slotUnselect();
+ if ( brush4 != _p )
+ brush4->slotUnselect();
+ if ( brush5 != _p )
+ brush5->slotUnselect();
+ if ( brush6 != _p )
+ brush6->slotUnselect();
+ if ( brush7 != _p )
+ brush7->slotUnselect();
+ if ( brush8 != _p )
+ brush8->slotUnselect();
+ if ( brush9 != _p )
+ brush9->slotUnselect();
+ if ( brush10 != _p )
+ brush10->slotUnselect();
+ if ( brush11 != _p )
+ brush11->slotUnselect();
+ if ( brush12 != _p )
+ brush12->slotUnselect();
+ if ( brush13 != _p )
+ brush13->slotUnselect();
+ if ( brush14 != _p )
+ brush14->slotUnselect();
+ if ( brush15 != _p )
+ brush15->slotUnselect();
+
+ current->setBrushStyle( selectedBrush->getBrushStyle() );
+}
+
+void CellFormatPagePattern::apply( CustomStyle * style )
+{
+ if ( selectedBrush != 0L
+ && ( dlg->brushStyle != selectedBrush->getBrushStyle()
+ || dlg->brushColor != selectedBrush->getBrushColor() ) )
+ style->changeBackGroundBrush( QBrush( selectedBrush->getBrushColor(), selectedBrush->getBrushStyle() ) );
+
+ /*
+ TODO: check...
+ if ( b_notAnyColor)
+ style->changeBgColor( QColor() );
+ else
+ */
+ if ( bgColor != dlg->getStyle()->bgColor() )
+ style->changeBgColor( bgColor );
+}
+
+void CellFormatPagePattern::apply(FormatManipulator *_obj)
+{
+ if ( selectedBrush != 0L
+ && ( dlg->brushStyle != selectedBrush->getBrushStyle()
+ || dlg->brushColor != selectedBrush->getBrushColor() ) )
+ _obj->setBackgroundBrush( QBrush( selectedBrush->getBrushColor(), selectedBrush->getBrushStyle() ) );
+
+ if ( bgColor == dlg->bgColor )
+ return;
+
+ if ( b_notAnyColor)
+ _obj->setBackgroundColor( QColor() );
+ else if ( !bBgColorUndefined )
+ _obj->setBackgroundColor( bgColor );
+}
+
+#include "kspread_dlg_layout.moc"
+
diff --git a/kspread/dialogs/kspread_dlg_layout.h b/kspread/dialogs/kspread_dlg_layout.h
new file mode 100644
index 00000000..0dfb10fa
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_layout.h
@@ -0,0 +1,636 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2001-2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 1999-2002 Harri Porten <porten@kde.org>
+ (C) 2000-2001 David Faure <faure@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+ (C) 2000 Werner Trobin <trobin@kde.org>
+ (C) 1999 Reginald Stadlbauer <reggie@kde.org>
+ (C) 1998-1999 Stephan Kulow <coolo@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_layout_h__
+#define __kspread_dlg_layout_h__
+
+
+#include <qtabdialog.h>
+#include <qapplication.h>
+#include <qbuttongroup.h>
+#include <qgroupbox.h>
+#include <knuminput.h>
+#include <kcompletion.h>
+#include "kspread_view.h"
+#include "kspread_format.h"
+#include "kspread_doc.h"
+#include "kspread_value.h"
+#include "position_cell_format.h"
+#include "font_cell_format.h"
+#include "protection_cell_format.h"
+
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+
+class KoUnitDoubleSpinBox;
+class QPixmap;
+class QRadioButton;
+class QPushButton;
+class QDate;
+class QTime;
+class QLabel;
+class QWidget;
+class KLineEdit;
+class QFrame;
+class QListBox;
+class QCheckBox;
+class KColorButton;
+class QComboBox;
+class KComboBox;
+class KoUnitDoubleSpinBox;
+
+namespace KSpread
+{
+class Sheet;
+class CustomStyle;
+class StyleManager;
+class CellFormatDialog;
+class FormatManipulator;
+
+enum BorderType
+{
+ BorderType_Top = 0,
+ BorderType_Bottom,
+ BorderType_Left,
+ BorderType_Right,
+ BorderType_Vertical,
+ BorderType_Horizontal,
+ BorderType_FallingDiagonal,
+ BorderType_RisingDiagonal,
+ BorderType_END
+};
+
+enum BorderShortcutType
+{
+ BorderShortcutType_Remove = 0,
+ BorderShortcutType_All,
+ BorderShortcutType_Outline,
+ BorderShortcutType_END
+};
+
+class PatternSelect : public QFrame
+{
+ Q_OBJECT
+public:
+ PatternSelect( QWidget *parent, const char *_name );
+
+ void setPenStyle( PenStyle _pat ) { penStyle = _pat; repaint(); }
+ PenStyle getPenStyle() { return penStyle; }
+ void setColor( const QColor &_col ) { penColor = _col; repaint(); }
+ const QColor& getColor() { return penColor; }
+ void setPenWidth( int _w ) { penWidth = _w; repaint(); }
+ int getPenWidth() { return penWidth; }
+
+ void setPattern( const QColor &_color, int _width, PenStyle _style );
+ void setUndefined();
+ void setDefined() { undefined = FALSE; repaint(); }
+
+ bool isDefined() { return !undefined; }
+
+signals:
+ void clicked( PatternSelect *_this );
+
+public slots:
+ void slotUnselect();
+ void slotSelect();
+
+protected:
+ virtual void paintEvent( QPaintEvent *_ev );
+ virtual void mousePressEvent( QMouseEvent *_ev );
+
+ PenStyle penStyle;
+ QColor penColor;
+ int penWidth;
+
+ bool selected;
+ bool undefined;
+};
+
+class GeneralTab : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ GeneralTab( QWidget * parent, CellFormatDialog * _dlg );
+ ~GeneralTab();
+
+ bool apply( CustomStyle * style );
+
+ protected slots:
+ void slotNewParent( const QString & parentName );
+ void slotNameChanged();
+
+ private:
+ CellFormatDialog * m_dlg;
+ KComboBox * m_parentBox;
+ KLineEdit * m_nameEdit;
+
+ QString m_name;
+ QString m_parent;
+
+ bool checkParent( const QString & parentName );
+ bool checkName();
+};
+
+/**
+ */
+class CellFormatPageFont : public FontTab
+{
+ Q_OBJECT
+public:
+ CellFormatPageFont( QWidget* parent, CellFormatDialog *_dlg );
+
+ void apply( CustomStyle * style );
+ void apply( FormatManipulator *_obj );
+
+signals:
+ /**
+ * Connect to this to monitor the font as it as selected if you are
+ * not running modal.
+ */
+ void fontSelected( const QFont &font );
+
+private slots:
+
+ void family_chosen_slot(const QString & );
+ void size_chosen_slot(const QString & );
+ void weight_chosen_slot(const QString &);
+ void style_chosen_slot(const QString &);
+ void underline_chosen_slot();
+ void strike_chosen_slot();
+ void display_example(const QFont &font);
+ void slotSetTextColor( const QColor &_color );
+
+private:
+
+ void setCombos();
+ QColor textColor;
+ QFont selFont;
+ bool fontChanged;
+ bool bTextColorUndefined;
+ CellFormatDialog *dlg;
+};
+
+/**
+ * Format of numbers.
+ * This widget is part of the format dialog.
+ * It allows the user to cinfigure the way numbers are formatted.
+ */
+class CellFormatPageFloat : public QWidget
+{
+ Q_OBJECT
+public:
+ CellFormatPageFloat( QWidget *parent, CellFormatDialog *_dlg );
+ void apply( CustomStyle * style );
+ void apply( FormatManipulator *_obj );
+
+public slots:
+ void slotChangeState();
+ void makeformat();
+ void updateFormatType();
+ void init();
+ void slotChangeValue(int);
+ void formatChanged(int);
+ void currencyChanged(const QString &);
+protected:
+ QLineEdit* postfix;
+ KIntNumInput* precision;
+ QLineEdit* prefix;
+ QComboBox *format;
+ QComboBox *currency;
+ QLabel *currencyLabel;
+ QRadioButton *generic;
+ QRadioButton *number;
+ QRadioButton *percent;
+ QRadioButton *date;
+ QRadioButton *money;
+ QRadioButton *scientific;
+ QRadioButton *fraction;
+ QRadioButton *time;
+ QRadioButton *textFormat;
+ QRadioButton *customFormat;
+ QListBox *listFormat;
+ QLineEdit* customFormatEdit;
+ QLabel *exampleLabel;
+ CellFormatDialog *dlg;
+ FormatType cellFormatType, newFormatType;
+ //test if value changed
+ bool m_bFormatTypeChanged;
+ bool m_bFormatColorChanged;
+};
+
+class CellFormatPagePosition : public PositionTab
+{
+ Q_OBJECT
+public:
+ CellFormatPagePosition( QWidget *parent, CellFormatDialog *_dlg );
+
+ void apply( CustomStyle * style );
+ void apply( FormatManipulator *_obj );
+
+ double getSizeHeight() const;
+ double getSizeWidth() const;
+ bool getMergedCellState() const;
+
+public slots:
+ void slotChangeHeightState();
+ void slotChangeWidthState();
+ void slotChangeAngle(int);
+ void slotStateChanged(int);
+ void slotChangeVerticalState();
+ void slotChangeMultiState();
+
+protected:
+ KoUnitDoubleSpinBox *width;
+ KoUnitDoubleSpinBox *height;
+ KoUnitDoubleSpinBox *m_indent;
+ CellFormatDialog *dlg;
+ bool m_bOptionText;
+};
+
+
+
+class Border : public QFrame
+{
+ Q_OBJECT
+public:
+ Border( QWidget *parent,const char *_name,bool _oneCol,bool _oneRow );
+signals:
+ void redraw();
+ void choosearea(QMouseEvent * _ev);
+protected:
+ virtual void paintEvent( QPaintEvent *_ev );
+ virtual void mousePressEvent( QMouseEvent* _ev );
+ bool oneCol;
+ bool oneRow;
+};
+
+class BorderButton : public QPushButton
+{
+ Q_OBJECT
+public:
+ BorderButton( QWidget *parent, const char *_name );
+ void setPenStyle( PenStyle _pat ) { penStyle = _pat;}
+ PenStyle getPenStyle() { return penStyle; }
+ void setColor( const QColor &_col ) { penColor = _col; }
+ const QColor& getColor() { return penColor; }
+ void setPenWidth( int _w ) { penWidth = _w; }
+ int getPenWidth() { return penWidth; }
+ bool isChanged() { return changed; }
+ void setChanged(bool _changed ) { changed=_changed;}
+ void setUndefined();
+ void unselect();
+ signals:
+ void clicked(BorderButton *);
+ protected:
+ virtual void mousePressEvent( QMouseEvent *_ev );
+ PenStyle penStyle;
+ QColor penColor;
+ int penWidth;
+ bool changed;
+
+};
+
+class CellFormatPageBorder : public QWidget
+{
+ Q_OBJECT
+public:
+ CellFormatPageBorder( QWidget *parent, CellFormatDialog *_dlg );
+
+ void apply(FormatManipulator* obj);
+ void invertState(BorderButton *_button);
+ QPixmap paintFormatPixmap(PenStyle _style);
+
+public slots:
+ void changeState(BorderButton *_this);
+ void preselect( BorderButton *_this);
+ void draw();
+ void slotSetColorButton( const QColor &_color );
+ void slotUnselect2( PatternSelect *_select );
+ void loadIcon( QString pix,BorderButton *_button);
+ void slotPressEvent(QMouseEvent *_ev);
+ void slotChangeStyle(int );
+ void slotChangeStyle(const QString & );
+ void cutomize_chosen_slot();
+
+protected:
+
+ Sheet* sheet;
+ BorderButton* borderButtons[BorderType_END];
+ BorderButton* shortcutButtons[BorderShortcutType_END];
+#define NUM_BORDER_PATTERNS 10
+
+ /* the patterns to choose from */
+ PatternSelect* pattern[NUM_BORDER_PATTERNS];
+
+ /* the pattern box that is the 'preview' of what is selected above. */
+ PatternSelect* preview;
+ QComboBox* size;
+ QComboBox* style;
+ KColorButton* color;
+ QCheckBox* customize;
+ QColor currentColor;
+ Border *area;
+ CellFormatDialog *dlg;
+private:
+
+ /*some helper functions to space some tasks apart */
+ void InitializeGrids();
+ void InitializeBorderButtons();
+ void InitializePatterns();
+ void SetConnections();
+ void applyTopOutline(FormatManipulator* obj);
+ void applyBottomOutline(FormatManipulator* obj);
+ void applyLeftOutline(FormatManipulator* obj);
+ void applyRightOutline(FormatManipulator* obj);
+ void applyVerticalOutline(FormatManipulator* obj);
+ void applyHorizontalOutline(FormatManipulator* obj);
+ void applyDiagonalOutline(FormatManipulator* obj);
+};
+
+class BrushSelect : public QFrame
+{
+ Q_OBJECT
+public:
+ BrushSelect( QWidget *parent, const char *_name );
+
+ void setBrushStyle( BrushStyle _pat ) { brushStyle = _pat; repaint(); }
+ BrushStyle getBrushStyle() const { return brushStyle; }
+ QColor getBrushColor() const { return brushColor; }
+ void setBrushColor(const QColor &_c) { brushColor=_c;}
+ void setPattern( const QColor &_color, BrushStyle _style );
+
+signals:
+ void clicked( BrushSelect *_this );
+
+public slots:
+ void slotUnselect();
+ void slotSelect();
+
+protected:
+ virtual void paintEvent( QPaintEvent *_ev );
+ virtual void mousePressEvent( QMouseEvent *_ev );
+
+ BrushStyle brushStyle;
+ QColor brushColor;
+ bool selected;
+};
+
+
+class CellFormatPagePattern : public QWidget
+{
+ Q_OBJECT
+public:
+ CellFormatPagePattern( QWidget *parent, CellFormatDialog *_dlg );
+
+ void apply( CustomStyle * style );
+ void apply( FormatManipulator *_obj );
+
+ void init();
+public slots:
+ void slotUnselect2( BrushSelect *_select );
+ void slotSetColorButton( const QColor &_color );
+ void slotSetBackgroundColor( const QColor &_color );
+ void slotNotAnyColor( );
+protected:
+ BrushSelect *selectedBrush;
+ BrushSelect *brush1;
+ BrushSelect *brush2;
+ BrushSelect *brush3;
+ BrushSelect *brush4;
+ BrushSelect *brush5;
+ BrushSelect *brush6;
+ BrushSelect *brush7;
+ BrushSelect *brush8;
+ BrushSelect *brush9;
+ BrushSelect *brush10;
+ BrushSelect *brush11;
+ BrushSelect *brush12;
+ BrushSelect *brush13;
+ BrushSelect *brush14;
+ BrushSelect *brush15;
+ BrushSelect *current;
+ KColorButton* color;
+ QPushButton* notAnyColor;
+ QColor currentColor;
+
+ QColor bgColor;
+ bool bBgColorUndefined;
+ KColorButton *bgColorButton;
+ bool b_notAnyColor;
+ CellFormatDialog *dlg;
+};
+
+class CellFormatPageProtection : public ProtectionTab
+{
+ Q_OBJECT
+
+ public:
+ CellFormatPageProtection( QWidget * parent, CellFormatDialog * _dlg );
+ ~CellFormatPageProtection();
+ ///when protection is set through Style Manager
+ void apply( CustomStyle * style );
+ void apply( FormatManipulator * _obj );
+
+ protected:
+ CellFormatDialog * m_dlg;
+ bool m_isProtected;
+ bool m_hideFormula;
+ bool m_hideAll;
+ bool m_dontPrint;
+};
+
+/**
+ * Dialog for the "Cell Format..." action
+ */
+class CellFormatDialog : public QObject
+{
+ Q_OBJECT
+public:
+ /**
+ * Create a format dlg for the rectangular area in '_sheet'.
+ */
+ CellFormatDialog( View * _view, Sheet * _sheet );
+ CellFormatDialog( View * _view, CustomStyle * _style, StyleManager * _manager,
+ Doc * doc );
+
+ ~CellFormatDialog();
+
+ void init();
+ void initGUI();
+ void initMembers();
+
+ void initParameters(Format *_obj,int column,int row);
+ void checkBorderRight(Format *obj,int x,int y);
+ void checkBorderLeft(Format *obj,int x,int y);
+ void checkBorderTop(Format *obj,int x,int y);
+ void checkBorderBottom(Format *obj,int x,int y);
+ void checkBorderVertical(Format *obj,int x,int y);
+ void checkBorderHorizontal(Format *obj,int x,int y);
+ /**
+ * Run the dialogs event loop and return when closed.
+ */
+ int exec();
+
+ Doc * getDoc() const { return m_doc; }
+ Sheet * getSheet() const { return m_sheet; }
+ CustomStyle * getStyle() const { return m_style; }
+ StyleManager * getStyleManager() const { return m_styleManager; }
+
+ bool isSingleCell() { return ( left == right && top == bottom ); }
+ bool checkCircle( QString const & name, QString const & parent );
+
+ KLocale * locale() const { return m_pView->doc()->locale(); }
+
+
+ struct CellBorderFormat
+ {
+ int width;
+ bool bStyle;
+ QColor color;
+ bool bColor;
+ PenStyle style;
+ };
+
+ // The format of the selected area
+ CellBorderFormat borders[BorderType_END];
+
+ BrushStyle brushStyle;
+ QColor brushColor;
+
+ bool oneCol;
+ bool oneRow;
+
+ QString prefix;
+ QString postfix;
+ int precision;
+ Format::FloatFormat floatFormat;
+ bool bFloatFormat;
+ Format::FloatColor floatColor;
+ Format::Currency cCurrency;
+ bool bFloatColor;
+ bool bCurrency;
+ QColor textColor;
+ bool bTextColor;
+ bool bTextFontBold;
+ bool textFontBold;
+ bool bTextFontItalic;
+ bool textFontItalic;
+ bool bTextFontSize;
+ int textFontSize;
+ bool bTextFontFamily;
+ QString textFontFamily;
+ bool bStrike;
+ bool strike;
+ bool bUnderline;
+ bool underline;
+ QFont textFont;
+ QColor bgColor;
+ bool bBgColor;
+ QString actionText;
+ Format::Align alignX;
+ Format::AlignY alignY;
+ QString styleName;
+ QString styleParent;
+
+ bool bMultiRow;
+ bool bVerticalText;
+
+ bool bDontPrintText;
+ bool bHideFormula;
+ bool bHideAll;
+ bool bIsProtected;
+
+ double defaultHeightSize;
+ double defaultWidthSize;
+ double heightSize;
+ double widthSize;
+
+ double indent;
+
+ QPixmap* formatOnlyNegSignedPixmap;
+ QPixmap* formatRedOnlyNegSignedPixmap;
+ QPixmap* formatRedNeverSignedPixmap;
+ QPixmap* formatAlwaysSignedPixmap;
+ QPixmap* formatRedAlwaysSignedPixmap;
+
+ int textRotation;
+ bool bTextRotation;
+
+ FormatType formatType;
+ bool bFormatType;
+
+ Value value;
+
+ bool isMerged;
+ bool oneCell;
+
+ bool isRowSelected;
+ bool isColumnSelected;
+
+ // The rectangular area for which this dlg has been opened.
+ int left;
+ int right;
+ int top;
+ int bottom;
+
+
+public slots:
+ void slotApply();
+
+protected:
+
+ /**
+ * Draws a pixmap showing a text consisting of two parts, @p _string1 and @p _string2 .
+ * The parts' colors are given by @p _color1 and @p _color2 .
+ */
+ QPixmap* paintFormatPixmap( const char *_string1, const QColor & _color1,
+ const char *_string2, const QColor & _color2 );
+
+ GeneralTab * generalPage;
+ CellFormatPageFloat *floatPage;
+ CellFormatPageBorder *borderPage;
+ CellFormatPageFont *fontPage;
+ CellFormatPagePosition *positionPage;
+ CellFormatPagePattern *patternPage;
+ CellFormatPageProtection *protectPage;
+ QTabDialog *tab;
+
+ Doc * m_doc;
+ Sheet * m_sheet;
+ View * m_pView;
+ CustomStyle * m_style;
+ StyleManager * m_styleManager;
+
+ void applyStyle();
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_list.cc b/kspread/dialogs/kspread_dlg_list.cc
new file mode 100644
index 00000000..bb3c75e9
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_list.cc
@@ -0,0 +1,321 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Ariya Hidayat <ariya@kde.org>
+ (C) 2001-2003 Laurent Montel <montel@kde.org>
+ (C) 1998, 1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlistbox.h>
+#include <qmultilineedit.h>
+#include <qpushbutton.h>
+
+#include <kbuttonbox.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+
+#include "kspread_autofill.h"
+#include "kspread_factory.h"
+#include "kspread_locale.h"
+
+#include "kspread_dlg_list.h"
+
+using namespace KSpread;
+
+ListDialog::ListDialog( QWidget* parent, const char* name )
+ : KDialogBase( parent, name, true, i18n("Custom Lists"), Ok|Cancel )
+{
+ QWidget* page = new QWidget( this );
+ setMainWidget( page );
+
+ QGridLayout *grid1 = new QGridLayout( page,10,3,KDialog::marginHint(), KDialog::spacingHint());
+
+ QLabel *lab=new QLabel(page);
+ lab->setText(i18n("List:" ));
+ grid1->addWidget(lab,0,0);
+
+ list=new QListBox(page);
+ grid1->addMultiCellWidget(list,1,8,0,0);
+
+
+ lab=new QLabel(page);
+ lab->setText(i18n("Entry:" ));
+ grid1->addWidget(lab,0,1);
+
+ entryList=new QMultiLineEdit(page);
+ grid1->addMultiCellWidget(entryList,1,8,1,1);
+
+ m_pRemove=new QPushButton(i18n("&Remove"),page);
+ grid1->addWidget(m_pRemove,3,2);
+
+ m_pAdd=new QPushButton(i18n("&Add"),page);
+ grid1->addWidget(m_pAdd,1,2);
+
+ m_pNew=new QPushButton(i18n("&New"),page);
+ grid1->addWidget(m_pNew,2,2);
+
+ m_pModify=new QPushButton(i18n("&Modify"),page);
+ grid1->addWidget(m_pModify,4,2);
+
+ m_pCopy=new QPushButton(i18n("Co&py"),page);
+ grid1->addWidget(m_pCopy,5,2);
+
+ m_pAdd->setEnabled(false);
+
+ connect( m_pRemove, SIGNAL( clicked() ), this, SLOT( slotRemove() ) );
+ connect( m_pAdd, SIGNAL( clicked() ), this, SLOT( slotAdd() ) );
+ connect( m_pNew, SIGNAL( clicked() ), this, SLOT( slotNew() ) );
+ connect( m_pModify, SIGNAL( clicked() ), this, SLOT( slotModify() ) );
+ connect( m_pCopy, SIGNAL( clicked() ), this, SLOT( slotCopy() ) );
+ connect( list, SIGNAL(doubleClicked(QListBoxItem *)),this,SLOT(slotDoubleClicked(QListBoxItem *)));
+ connect( list, SIGNAL(clicked ( QListBoxItem * )),this,SLOT(slotTextClicked(QListBoxItem * )));
+ init();
+ entryList->setEnabled(false);
+ m_pModify->setEnabled(false);
+ if(list->count()<=2)
+ m_pRemove->setEnabled(false);
+ resize( 600, 250 );
+ m_bChanged=false;
+}
+
+
+void ListDialog::slotTextClicked(QListBoxItem*)
+{
+ //we can't remove the two first item
+ bool state=list->currentItem()>1;
+ m_pRemove->setEnabled(state);
+ m_pModify->setEnabled(state);
+
+}
+
+void ListDialog::init()
+{
+ QString month;
+ month+=i18n("January")+", ";
+ month+=i18n("February")+", ";
+ month+=i18n("March") +", ";
+ month+=i18n("April")+", ";
+ month+=i18n("May")+", ";
+ month+=i18n("June")+", ";
+ month+=i18n("July")+", ";
+ month+=i18n("August")+", ";
+ month+=i18n("September")+", ";
+ month+=i18n("October")+", ";
+ month+=i18n("November")+", ";
+ month+=i18n("December");
+ QStringList lst;
+ lst.append(month);
+
+ QString smonth;
+ smonth+=i18n("Jan")+", ";
+ smonth+=i18n("Feb")+", ";
+ smonth+=i18n("Mar") +", ";
+ smonth+=i18n("Apr")+", ";
+ smonth+=i18n("May")+", ";
+ smonth+=i18n("Jun")+", ";
+ smonth+=i18n("Jul")+", ";
+ smonth+=i18n("Aug")+", ";
+ smonth+=i18n("Sep")+", ";
+ smonth+=i18n("Oct")+", ";
+ smonth+=i18n("Nov")+", ";
+ smonth+=i18n("Dec");
+ lst.append(smonth);
+
+ QString day=i18n("Monday")+", ";
+ day+=i18n("Tuesday")+", ";
+ day+=i18n("Wednesday")+", ";
+ day+=i18n("Thursday")+", ";
+ day+=i18n("Friday")+", ";
+ day+=i18n("Saturday")+", ";
+ day+=i18n("Sunday");
+ lst.append(day);
+
+ QString sday=i18n("Mon")+", ";
+ sday+=i18n("Tue")+", ";
+ sday+=i18n("Wed")+", ";
+ sday+=i18n("Thu")+", ";
+ sday+=i18n("Fri")+", ";
+ sday+=i18n("Sat")+", ";
+ sday+=i18n("Sun");
+ lst.append(sday);
+
+ config = Factory::global()->config();
+ config->setGroup( "Parameters" );
+ QStringList other=config->readListEntry("Other list");
+ QString tmp;
+ for ( QStringList::Iterator it = other.begin(); it != other.end();++it )
+ {
+ if((*it)!="\\")
+ tmp+=(*it)+", ";
+ else if( it!=other.begin())
+ {
+ tmp=tmp.left(tmp.length()-2);
+ lst.append(tmp);
+ tmp="";
+ }
+ }
+ list->insertStringList(lst);
+}
+
+void ListDialog::slotDoubleClicked(QListBoxItem *)
+{
+ //we can't modify the two first item
+ if(list->currentItem()<2)
+ return;
+ QString tmp=list->currentText();
+ entryList->setText("");
+ QStringList result=result.split(", ",tmp);
+ int index=0;
+ for ( QStringList::Iterator it = result.begin(); it != result.end();++it )
+ {
+ entryList->insertLine((*it),index);
+ index++;
+ }
+ entryList->setEnabled(true);
+ m_pModify->setEnabled(true);
+}
+
+void ListDialog::slotAdd()
+{
+ m_pAdd->setEnabled(false);
+ list->setEnabled(true);
+ QString tmp;
+ for(int i=0;i<entryList->numLines();i++)
+ {
+ if(!entryList->textLine(i).isEmpty())
+ {
+ if(tmp.isEmpty())
+ tmp=entryList->textLine(i);
+ else
+ tmp+=", "+entryList->textLine(i);
+ }
+ }
+ if(!tmp.isEmpty())
+ list->insertItem(tmp,list->count());
+
+ entryList->setText("");
+ entryList->setEnabled(false);
+ entryList->setFocus();
+ slotTextClicked(0L);
+ m_bChanged=true;
+}
+
+void ListDialog::slotNew()
+{
+ m_pAdd->setEnabled(true);
+ list->setEnabled(false);
+ entryList->setText("");
+ entryList->setEnabled(true);
+ entryList->setFocus();
+}
+
+void ListDialog::slotRemove()
+{
+ if(list->currentItem()==-1)
+ return;
+ //don't remove the two first line
+ if(list->currentItem()<2)
+ return;
+ int ret = KMessageBox::warningContinueCancel( this, i18n("Do you really want to remove this list?"),i18n("Remove List"),KStdGuiItem::del());
+ if(ret==Cancel) // reponse = No
+ return;
+ list->removeItem(list->currentItem ());
+ entryList->setEnabled(false);
+ entryList->setText("");
+ if(list->count()<=2)
+ m_pRemove->setEnabled(false);
+ m_bChanged=true;
+}
+
+void ListDialog::slotOk()
+{
+ if(!entryList->text().isEmpty())
+ {
+ int ret = KMessageBox::warningYesNo( this, i18n("Entry area is not empty.\nDo you want to continue?"));
+ if(ret==4) // reponse = No
+ return;
+ }
+ if(m_bChanged)
+ {
+ QStringList result;
+ result.append("\\");
+
+ //don't save the two first line
+ for(unsigned int i=2;i<list->count();i++)
+ {
+ QStringList tmp=result.split(", ",list->text(i));
+ if ( !tmp.isEmpty() )
+ {
+ result+=tmp;
+ result+="\\";
+ }
+ }
+ config->setGroup( "Parameters" );
+ config->writeEntry("Other list",result);
+ //todo refresh AutoFillSequenceItem::other
+ // I don't know how to do for the moment
+ if(AutoFillSequenceItem::other!=0L)
+ {
+ delete(AutoFillSequenceItem::other);
+ AutoFillSequenceItem::other=0L;
+ }
+ }
+ accept();
+}
+
+void ListDialog::slotModify()
+{
+ //you can modify list but not the two first list
+ if(list->currentItem ()>1 && !entryList->text().isEmpty())
+ {
+ QString tmp;
+ for(int i=0;i<entryList->numLines();i++)
+ {
+ if(!entryList->textLine(i).isEmpty())
+ {
+ if(tmp.isEmpty())
+ tmp=entryList->textLine(i);
+ else
+ tmp+=", "+entryList->textLine(i);
+ }
+ }
+ list->insertItem(tmp,list->currentItem());
+ list->removeItem(list->currentItem());
+
+
+ entryList->setText("");
+ m_bChanged=true;
+
+ }
+ entryList->setEnabled(false);
+ m_pModify->setEnabled(false);
+
+}
+
+void ListDialog::slotCopy()
+{
+ if(list->currentItem()!=-1)
+ {
+ list->insertItem(list->currentText(),list->count());
+ }
+}
+
+
+#include "kspread_dlg_list.moc"
diff --git a/kspread/dialogs/kspread_dlg_list.h b/kspread/dialogs/kspread_dlg_list.h
new file mode 100644
index 00000000..88d3c243
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_list.h
@@ -0,0 +1,71 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Ariya Hidayat <ariya@kde.org>
+ (C) 2001-2003 Laurent Montel <montel@kde.org>
+ (C) 1998, 1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_list__
+#define __kspread_dlg_list__
+
+#include <kdialogbase.h>
+
+class QListBox;
+class QListBoxItem;
+class QLineEdit;
+class QMultiLineEdit;
+class QPushButton;
+
+class KConfig;
+
+namespace KSpread
+{
+
+class ListDialog: public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ ListDialog( QWidget* parent, const char* name );
+ void init();
+
+public slots:
+ virtual void slotOk();
+ void slotDoubleClicked(QListBoxItem *);
+ void slotTextClicked(QListBoxItem*);
+ void slotRemove();
+ void slotAdd();
+ void slotNew();
+ void slotModify();
+ void slotCopy();
+
+protected:
+ KConfig *config;
+
+ QListBox * list;
+ QMultiLineEdit *entryList;
+ QPushButton* m_pRemove;
+ QPushButton* m_pNew;
+ QPushButton* m_pAdd;
+ QPushButton* m_pModify;
+ QPushButton* m_pCopy;
+ bool m_bChanged;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_paperlayout.cc b/kspread/dialogs/kspread_dlg_paperlayout.cc
new file mode 100644
index 00000000..771cee5b
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_paperlayout.cc
@@ -0,0 +1,554 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
+ (C) 2002-2003 Ariya Hidayat <ariya@kde.org>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "kspread_dlg_paperlayout.h"
+#include <kspread_doc.h>
+#include "kspread_map.h"
+#include "kspread_sheet.h"
+#include "kspread_sheetprint.h"
+#include <kspread_undo.h>
+#include <kspread_util.h>
+#include <kspread_view.h>
+#include <selection.h>
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qcombobox.h>
+#include <qlayout.h>
+#include <qhgroupbox.h>
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+using namespace KSpread;
+
+PaperLayout::PaperLayout( QWidget * parent, const char * name,
+ const KoPageLayout & layout,
+ const KoHeadFoot & headfoot,
+ int tabs, KoUnit::Unit unit,
+ Sheet * sheet, View * view)
+ : KoPageLayoutDia( parent, name, layout, headfoot, tabs, unit, false /*no modal*/),
+ m_pSheet( sheet ),
+ m_pView( view )
+{
+ initTab();
+ connect(view->selectionInfo(), SIGNAL(changed(const Region&)),
+ this, SLOT(slotSelectionChanged()));
+ qApp->installEventFilter( this );
+ m_focus= 0L;
+}
+
+void PaperLayout::initTab()
+{
+ SheetPrint* print = m_pSheet->print();
+
+ QWidget *tab = addPage(i18n( "Options" ));
+ QVBoxLayout *vbox = new QVBoxLayout( tab, KDialog::marginHint(), KDialog::spacingHint() );
+
+ pApplyToAll = new QCheckBox ( i18n( "&Apply to all sheets" ), tab );
+ pApplyToAll->setChecked( print->printGrid() );
+ vbox->addWidget( pApplyToAll );
+
+ //Range properties
+ initGeneralOptions( tab, vbox );
+
+ //Range properties
+ initRanges( tab, vbox );
+
+ //Scale properties
+ initScaleOptions( tab, vbox );
+
+ vbox->addStretch( 1 );
+}
+
+void PaperLayout::initGeneralOptions( QWidget * tab, QVBoxLayout * vbox )
+{
+ SheetPrint* print = m_pSheet->print();
+
+ QGroupBox *group = new QGroupBox( i18n("General Options"), tab );
+ QGridLayout *l = new QGridLayout( group, 2, 3 );
+
+ pPrintGrid = new QCheckBox ( i18n("Print &grid"), group );
+ pPrintGrid->setChecked( print->printGrid() );
+ l->addWidget( pPrintGrid, 0, 0 );
+
+ pPrintCommentIndicator = new QCheckBox ( i18n("Print &comment indicator"), group );
+ pPrintCommentIndicator->setChecked( print->printCommentIndicator() );
+ l->addWidget( pPrintCommentIndicator, 0, 1 );
+
+ pPrintFormulaIndicator = new QCheckBox ( i18n("Print &formula indicator"), group );
+ pPrintFormulaIndicator->setChecked( print->printFormulaIndicator() );
+ l->addWidget( pPrintFormulaIndicator, 0, 2 );
+
+ pPrintObjects = new QCheckBox ( i18n("Print &objects"), group );
+ pPrintObjects->setChecked( print->printObjects() );
+ l->addWidget( pPrintObjects, 1, 0 );
+
+ pPrintCharts = new QCheckBox ( i18n("Print &charts"), group );
+ pPrintCharts->setChecked( print->printCharts() );
+ l->addWidget( pPrintCharts, 1, 1 );
+
+// Not used yet unless someone implement some kind of drawing object
+// pPrintGraphics = new QCheckBox ( i18n("Print &drawings"), group );
+// pPrintGraphics->setChecked( print->printGraphics() );
+// l->addWidget( pPrintGraphics, 1, 2 );
+
+ vbox->addWidget( group );
+}
+
+void PaperLayout::initRanges( QWidget * tab, QVBoxLayout * vbox )
+{
+ SheetPrint* print = m_pSheet->print();
+
+ QGroupBox *rangeGroup = new QGroupBox( i18n("Ranges"), tab );
+ rangeGroup->setColumnLayout( 0, Qt::Vertical );
+ rangeGroup->setMargin( KDialog::marginHint() );
+ vbox->addWidget( rangeGroup );
+
+ QGridLayout *grid = new QGridLayout( rangeGroup->layout(), 3, 2, KDialog::spacingHint() );
+
+ QLabel *pPrintRange = new QLabel ( i18n("Print range:"), rangeGroup );
+ grid->addWidget( pPrintRange, 0, 0 );
+
+ ePrintRange = new QLineEdit( rangeGroup );
+ ePrintRange->setText( util_rangeName( print->printRange() ) );
+ grid->addWidget( ePrintRange, 0, 1 );
+
+ QLabel *pRepeatCols = new QLabel ( i18n("Repeat columns on each page:"), rangeGroup );
+ grid->addWidget( pRepeatCols, 1, 0 );
+
+ eRepeatCols = new QLineEdit( rangeGroup );
+ if ( print->printRepeatColumns().first != 0 )
+ eRepeatCols->setText( Cell::columnName( print->printRepeatColumns().first ) + ":" +
+ Cell::columnName( print->printRepeatColumns().second ) );
+ grid->addWidget( eRepeatCols, 1, 1 );
+
+ QLabel *pRepeatRows = new QLabel ( i18n("Repeat rows on each page:"), rangeGroup );
+ grid->addWidget( pRepeatRows, 2, 0 );
+
+ eRepeatRows = new QLineEdit( rangeGroup );
+ if ( print->printRepeatRows().first != 0 )
+ eRepeatRows->setText( QString().setNum( print->printRepeatRows().first ) +
+ ":" +
+ QString().setNum( print->printRepeatRows().second ) );
+ grid->addWidget( eRepeatRows, 2, 1 );
+
+ grid->addColSpacing( 0, pPrintRange->width() );
+ grid->addColSpacing( 0, pRepeatRows->width() );
+ grid->addColSpacing( 0, pRepeatCols->width() );
+ grid->addColSpacing( 1, ePrintRange->width() );
+ grid->addColSpacing( 1, eRepeatRows->width() );
+ grid->addColSpacing( 1, eRepeatCols->width() );
+
+ grid->addRowSpacing( 0, pPrintRange->height() );
+ grid->addRowSpacing( 0, ePrintRange->height() );
+ grid->addRowSpacing( 1, pRepeatRows->height() );
+ grid->addRowSpacing( 1, eRepeatRows->height() );
+ grid->addRowSpacing( 2, pRepeatCols->height() );
+ grid->addRowSpacing( 2, eRepeatCols->height() );
+}
+
+void PaperLayout::initScaleOptions( QWidget * tab, QVBoxLayout * vbox )
+{
+ SheetPrint* print = m_pSheet->print();
+
+ QButtonGroup *zoomGroup = new QButtonGroup( i18n("Scale Printout"), tab );
+ zoomGroup->setColumnLayout( 0, Qt::Vertical );
+ zoomGroup->setMargin( KDialog::marginHint() );
+ vbox->addWidget( zoomGroup );
+
+ QGridLayout *grid = new QGridLayout( zoomGroup->layout(), 2, 6,
+ KDialog::spacingHint() );
+
+ m_rScalingZoom = new QRadioButton ( i18n("Zoom:"), zoomGroup );
+ grid->addWidget( m_rScalingZoom, 0, 0 );
+
+ m_cZoom = new QComboBox( true, zoomGroup, "Zoom" );
+ grid->addMultiCellWidget( m_cZoom, 0, 0, 1, 5, Qt::AlignLeft );
+
+ QStringList lst;
+ for( int i = 5; i < 500; i += 5 )
+ {
+ lst.append( QString( i18n( "%1%" ) ).arg( i ) );
+ if( qRound( print->zoom() * 100 ) > i &&
+ qRound( print->zoom() * 100 ) < i + 5 )
+ {
+ lst.append( QString( i18n( "%1%" ) ).arg( qRound( print->zoom() * 100 ) ) );
+ }
+ }
+ m_cZoom->insertStringList( lst );
+
+ int number_of_entries = m_cZoom->count();
+ QString string = QString( i18n( "%1%" ) ).arg( qRound( print->zoom() * 100 ) );
+ for (int i = 0; i < number_of_entries ; i++)
+ {
+ if ( string == (QString) m_cZoom->text(i) )
+ {
+ m_cZoom->setCurrentItem( i );
+ break;
+ }
+ }
+
+ m_rScalingLimitPages = new QRadioButton ( i18n("Limit pages:"), zoomGroup );
+ grid->addWidget( m_rScalingLimitPages, 1, 0 );
+
+ QLabel *pLimitPagesX = new QLabel ( i18n("X:"), zoomGroup );
+ grid->addWidget( pLimitPagesX, 1, 1 );
+
+ m_cLimitPagesX = new QComboBox( true, zoomGroup, "pagesX" );
+ grid->addWidget( m_cLimitPagesX, 1, 2 );
+
+ QStringList lstX;
+ lstX.append( i18n( "No Limit" ) );
+ for( int i = 1; i <= 20; i += 1 )
+ {
+ lstX.append( QString( "%1" ).arg( i ) );
+ }
+ if( print->pageLimitX() > 20 )
+ {
+ lstX.append( QString( "%1" ).arg( print->pageLimitX() ) );
+ }
+ m_cLimitPagesX->insertStringList( lstX );
+
+ if ( print->pageLimitX() <= 20 )
+ m_cLimitPagesX->setCurrentItem( print->pageLimitX() );
+ else
+ m_cLimitPagesX->setCurrentItem( 21 );
+
+ QLabel *pLimitPagesY = new QLabel ( i18n("Y:"), zoomGroup );
+ grid->addWidget( pLimitPagesY, 1, 3 );
+
+ m_cLimitPagesY = new QComboBox( true, zoomGroup, "pagesY" );
+ grid->addWidget( m_cLimitPagesY, 1, 4 );
+
+ QStringList lstY;
+ lstY.append( i18n( "No Limit" ) );
+ for( int i = 1; i <= 20; i += 1 )
+ {
+ lstY.append( QString( "%1" ).arg( i ) );
+ }
+ if( print->pageLimitY() > 20 )
+ {
+ lstY.append( QString( "%1" ).arg( print->pageLimitY() ) );
+ }
+ m_cLimitPagesY->insertStringList( lstY );
+
+ if ( print->pageLimitY() <= 20 )
+ m_cLimitPagesY->setCurrentItem( print->pageLimitY() );
+ else
+ m_cLimitPagesY->setCurrentItem( 21 );
+
+ if ( print->pageLimitY() != 0 || print->pageLimitX() != 0 )
+ {
+ m_rScalingLimitPages->setChecked( true );
+ }
+ else
+ {
+ m_rScalingZoom->setChecked( true );
+ }
+
+ connect( m_cZoom, SIGNAL( activated( int ) ), this, SLOT( slotChooseZoom( int ) ) );
+ connect( m_cLimitPagesX, SIGNAL( activated( int ) ), this, SLOT( slotChoosePageLimit( int ) ) );
+ connect( m_cLimitPagesY, SIGNAL( activated( int ) ), this, SLOT( slotChoosePageLimit( int ) ) );
+}
+
+void PaperLayout::slotChooseZoom( int /*index*/ )
+{
+ m_rScalingZoom->setChecked( true );
+}
+
+void PaperLayout::slotChoosePageLimit( int /*index*/ )
+{
+ m_rScalingLimitPages->setChecked( true );
+}
+
+void PaperLayout::slotOk()
+{
+ if ( !m_pSheet->doc()->undoLocked() )
+ {
+ UndoAction* undo = new UndoPaperLayout( m_pSheet->doc(), m_pSheet );
+ m_pSheet->doc()->addCommand( undo );
+ }
+
+ // get new values for borders
+ Map * map = 0;
+ Sheet * sheet = 0;
+
+ if ( pApplyToAll->isChecked() )
+ map = m_pSheet->doc()->map();
+
+ if ( map )
+ sheet = map->firstSheet();
+ else
+ sheet = m_pSheet;
+
+ m_pView->doc()->emitBeginOperation( false );
+ while ( sheet )
+ {
+ SheetPrint *print = sheet->print();
+
+ KoPageLayout pl = layout();
+ KoHeadFoot hf = headFoot();
+ KoUnit::Unit unit = sheet->doc()->unit();
+ print->setPrintGrid( pPrintGrid->isChecked() );
+ print->setPrintCommentIndicator( pPrintCommentIndicator->isChecked() );
+ print->setPrintFormulaIndicator( pPrintFormulaIndicator->isChecked() );
+ print->setPrintObjects( pPrintObjects->isChecked() );
+ print->setPrintCharts( pPrintCharts->isChecked() );
+// print->setPrintGraphics( pPrintGraphics->isChecked() );
+ QString tmpPrintRange = ePrintRange->text();
+ QString tmpRepeatCols = eRepeatCols->text();
+ QString tmpRepeatRows = eRepeatRows->text();
+ if ( tmpPrintRange.isEmpty() )
+ {
+ print->setPrintRange( QRect( QPoint( 1, 1 ), QPoint( KS_colMax, KS_rowMax ) ) );
+ }
+ else
+ {
+ bool error = true;
+ int first = tmpPrintRange.find(":");
+ if ( ( first != -1 ) && ( (int)tmpPrintRange.length() > first ) )
+ {
+ Point point1 ( tmpPrintRange.left( first ) );
+ if ( point1.isValid() )
+ {
+ Point point2 ( tmpPrintRange.mid( first+1 ) );
+ if ( point2.isValid() )
+ {
+ error = false;
+ print->setPrintRange ( QRect( QPoint( QMIN( point1.pos().x(), point2.pos().x() ),
+ QMIN( point1.pos().y(), point2.pos().y() ) ),
+ QPoint( QMAX( point1.pos().x(), point2.pos().x() ),
+ QMAX( point1.pos().y(), point2.pos().y() ) ) ) );
+ }
+ }
+ }
+
+ if ( error ) KMessageBox::information( 0, i18n( "Print range wrong, changes are ignored." ) );
+ }
+
+ if ( tmpRepeatCols.isEmpty() )
+ {
+ print->setPrintRepeatColumns( qMakePair( 0, 0 ) );
+ }
+ else
+ {
+ bool error = true;
+ int first = tmpRepeatCols.find(":");
+ if ( ( first != -1 ) && ( (int)tmpRepeatCols.length() > first ) )
+ {
+ int col1 = util_decodeColumnLabelText( tmpRepeatCols.left( first ) );
+ if ( col1 > 0 && col1 <= KS_colMax )
+ {
+ int col2 = util_decodeColumnLabelText( tmpRepeatCols.mid( first+1 ) );
+ if ( col2 > 0 && col2 <= KS_colMax )
+ {
+ error = false;
+ print->setPrintRepeatColumns ( qMakePair( col1, col2 ) );
+ }
+ }
+ }
+
+ if ( error )
+ KMessageBox::information( 0, i18n( "Repeated columns range wrong, changes are ignored.\nMust be in format column:column (eg. B:C)" ) );
+ }
+
+ if ( tmpRepeatRows.isEmpty() )
+ {
+ print->setPrintRepeatRows ( qMakePair( 0, 0 ) );
+ }
+ else
+ {
+ bool error = true;
+ int first = tmpRepeatRows.find(":");
+ if ( ( first != -1 ) && ( (int)tmpRepeatRows.length() > first ) )
+ {
+ int row1 = tmpRepeatRows.left( first ).toInt();
+ if ( row1 > 0 && row1 <= KS_rowMax )
+ {
+ int row2 = tmpRepeatRows.mid( first+1 ).toInt();
+ if ( row2 > 0 && row2 <= KS_rowMax )
+ {
+ error = false;
+ print->setPrintRepeatRows ( qMakePair( row1, row2 ) );
+ }
+ }
+ }
+
+ if ( error )
+ KMessageBox::information( 0, i18n( "Repeated rows range wrong, changes are ignored.\nMust be in format row:row (eg. 2:3)" ) );
+ }
+
+ if ( m_rScalingZoom->isChecked() )
+ {
+ kdDebug() << "Zoom is selected" << endl;
+ if( QString( "%1%" ).arg( qRound( print->zoom() * 100 ) ) != m_cZoom->currentText() )
+ {
+ kdDebug() << "New zoom is different than original: " << m_cZoom->currentText() << endl;
+ QString zoomtext = m_cZoom->currentText();
+ zoomtext.replace("%","");
+ bool convertok = false;
+ double zoomvalue = zoomtext.toDouble(&convertok);
+ if (!convertok)
+ {
+ kdWarning() << "Could not convert zoom text to double value!!!" << endl;
+ }
+ else if( zoomvalue != 0.0 )
+ {
+ //reset page limits
+ print->setPageLimitX(0);
+ print->setPageLimitY(0);
+ kdDebug() << "Setting print zoom: " << zoomvalue*0.01 << endl;
+ print->setZoom( 0.01 * zoomvalue );
+ kdDebug() << "New print zoom: " << print->zoom() << endl;
+ }
+ else
+ kdDebug() << "Did not set print zoom" << endl;
+ }
+ else
+ kdDebug() << "new zoom is same as original: " << m_cZoom->currentText() << endl;
+ }
+ else if (m_rScalingLimitPages->isChecked())
+ {
+ kdDebug() << "Limit pages is selected" << endl;
+ kdDebug() << "Current zoom: " << print->zoom() << endl;
+
+ //reset first, otherwise setting the first limit
+ //would still check against the second limit and
+ //possibly result in a smaller total zoom
+ print->setPageLimitX( 0 );
+ print->setPageLimitY( 0 );
+
+ //start with at least 100%
+
+ if (print->zoom() < 1.0)
+ {
+ kdDebug() << "Resetting zoom to 1.0" << endl;
+ print->setZoom(1.0,false); //don't check page limits here
+ kdDebug() << "Zoom is now: " << print->zoom() << endl;
+ }
+
+ bool convertok = false;
+
+ int limitX = m_cLimitPagesX->currentText().toInt(&convertok);
+ if (!convertok) //THIS IS THE CASE WITH "No Limit"
+ limitX = 0; //0 means no limit
+
+ convertok=false;
+ int limitY = m_cLimitPagesY->currentText().toInt(&convertok);
+ if (!convertok) //THIS IS THE CASE WITH "No Limit"
+ limitY=0; //0 means no limit
+
+ kdDebug() << "Zoom before setting limits: " << print->zoom() << endl;
+ kdDebug() << "Chosen Limits: x: " << limitX << "; y: " << limitY << endl;
+ print->setPageLimitX( limitX );
+ kdDebug() << "Zoom after setting x limit: " << print->zoom() << endl;
+ print->setPageLimitY( limitY );
+ kdDebug() << "Zoom after setting y limit: " << print->zoom() << endl;
+ }
+ else
+ kdWarning() << "ERROR: unknown zoom option selected" << endl;
+
+ sheet->doc()->setModified( true );
+
+ if ( pl.format == PG_CUSTOM )
+ {
+ print->setPaperWidth( qRound( POINT_TO_MM( pl.ptWidth ) *1000 ) / 1000 );
+ print->setPaperHeight( qRound( POINT_TO_MM( pl.ptHeight ) *1000 ) / 1000 );
+ }
+
+ print->setPaperLayout( POINT_TO_MM(pl.ptLeft), POINT_TO_MM(pl.ptTop),
+ POINT_TO_MM(pl.ptRight), POINT_TO_MM(pl.ptBottom),
+ pl.format, pl.orientation );
+
+ print->setHeadFootLine( print->delocalizeHeadFootLine( hf.headLeft ),
+ print->delocalizeHeadFootLine( hf.headMid ),
+ print->delocalizeHeadFootLine( hf.headRight ),
+ print->delocalizeHeadFootLine( hf.footLeft ),
+ print->delocalizeHeadFootLine( hf.footMid ),
+ print->delocalizeHeadFootLine( hf.footRight ) );
+
+ sheet->doc()->setUnit( unit );
+
+ if ( map )
+ sheet = map->nextSheet();
+ else
+ sheet = 0;
+ }
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+void PaperLayout::closeEvent ( QCloseEvent * )
+{
+ delete this;
+}
+
+void PaperLayout::slotSelectionChanged()
+{
+ // TODO Stefan: check for improvement
+ if (!m_pView->selectionInfo()->isValid())
+ return;
+
+ QString area = util_rangeName( m_pView->selectionInfo()->lastRange() );
+ if ( m_focus )
+ {
+ if ( m_focus == ePrintRange )
+ area = util_rangeName( m_pView->selectionInfo()->lastRange() );
+ else if ( m_focus == eRepeatRows )
+ area = util_rangeRowName( m_pView->selectionInfo()->lastRange() );
+ else if ( m_focus == eRepeatCols )
+ area = util_rangeColumnName( m_pView->selectionInfo()->lastRange() );
+ else
+ return;
+ m_focus->setText( area );
+ }
+}
+
+void PaperLayout::slotCancel()
+{
+ reject();
+}
+
+bool PaperLayout::eventFilter( QObject* obj, QEvent* ev )
+{
+ if ( obj == ePrintRange && ev->type() == QEvent::FocusIn )
+ m_focus = ePrintRange;
+ else if ( obj == eRepeatCols && ev->type() == QEvent::FocusIn )
+ m_focus = eRepeatCols;
+ else if ( obj == eRepeatRows && ev->type() == QEvent::FocusIn )
+ m_focus = eRepeatRows;
+ else
+ return false;
+
+ return false;
+}
+
+
+#include "kspread_dlg_paperlayout.moc"
diff --git a/kspread/dialogs/kspread_dlg_paperlayout.h b/kspread/dialogs/kspread_dlg_paperlayout.h
new file mode 100644
index 00000000..93981628
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_paperlayout.h
@@ -0,0 +1,94 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Ariya Hidayat <ariya@kde.org>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_paperlayout__
+#define __kspread_dlg_paperlayout__
+
+#include <kdialogbase.h>
+#include <KoPageLayoutDia.h>
+
+class QCheckBox;
+class QComboBox;
+class QRadioButton;
+class QLineEdit;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class PaperLayout: public KoPageLayoutDia
+{
+ Q_OBJECT
+public:
+ PaperLayout( QWidget* parent, const char* name,
+ const KoPageLayout& layout,
+ const KoHeadFoot& headfoot,
+ int tabs, KoUnit::Unit unit,
+ Sheet * sheet, View *view);
+
+ bool eventFilter( QObject* obj, QEvent* ev );
+
+protected slots:
+ virtual void slotOk();
+ virtual void slotCancel();
+ void slotSelectionChanged();
+
+protected:
+ void initTab();
+
+protected:
+ virtual void closeEvent ( QCloseEvent * );
+
+private slots:
+ void slotChooseZoom( int index );
+ void slotChoosePageLimit( int index );
+
+private:
+ void initGeneralOptions( QWidget * tab, QVBoxLayout * vbox );
+ void initRanges( QWidget * tab, QVBoxLayout * vbox );
+ void initScaleOptions( QWidget * tab, QVBoxLayout * vbox );
+
+ Sheet * m_pSheet;
+ View * m_pView;
+
+ QCheckBox * pApplyToAll;
+ QCheckBox * pPrintGrid;
+ QCheckBox * pPrintCommentIndicator;
+ QCheckBox * pPrintFormulaIndicator;
+ QCheckBox * pPrintObjects;
+ QCheckBox * pPrintCharts;
+ QCheckBox * pPrintGraphics;
+ QLineEdit * ePrintRange;
+ QLineEdit * eRepeatCols;
+ QLineEdit * eRepeatRows;
+ QLineEdit * m_focus;
+ QComboBox * m_cZoom;
+ QComboBox * m_cLimitPagesX;
+ QComboBox * m_cLimitPagesY;
+ QRadioButton * m_rScalingZoom;
+ QRadioButton * m_rScalingLimitPages;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_pasteinsert.cc b/kspread/dialogs/kspread_dlg_pasteinsert.cc
new file mode 100644
index 00000000..98a37296
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_pasteinsert.cc
@@ -0,0 +1,77 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2000-2002 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qlayout.h>
+#include <klocale.h>
+#include <kbuttonbox.h>
+#include <qbuttongroup.h>
+#include <kdebug.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+
+#include "kspread_dlg_pasteinsert.h"
+#include "kspread_canvas.h"
+#include "kspread_doc.h"
+#include "kspread_sheet.h"
+#include "kspread_view.h"
+#include "selection.h"
+
+using namespace KSpread;
+
+PasteInsertDialog::PasteInsertDialog( View* parent, const char* name,const QRect &_rect)
+ : KDialogBase( parent, name, TRUE,i18n("Paste Inserting Cells"),Ok|Cancel )
+{
+ m_pView = parent;
+ rect=_rect;
+
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+ QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
+
+ QButtonGroup *grp = new QButtonGroup( 1, QGroupBox::Horizontal, i18n("Insert"),page);
+ grp->setRadioButtonExclusive( TRUE );
+ grp->layout();
+ lay1->addWidget(grp);
+ rb1 = new QRadioButton( i18n("Move towards right"), grp );
+ rb2 = new QRadioButton( i18n("Move towards bottom"), grp );
+ rb1->setChecked(true);
+
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+}
+
+void PasteInsertDialog::slotOk()
+{
+ m_pView->doc()->emitBeginOperation( false );
+ if( rb1->isChecked() )
+ m_pView->activeSheet()->paste( m_pView->selectionInfo()->lastRange(),
+ true, Paste::Normal, Paste::OverWrite,
+ true, -1 );
+ else if( rb2->isChecked() )
+ m_pView->activeSheet()->paste( m_pView->selectionInfo()->lastRange(),
+ true, Paste::Normal, Paste::OverWrite,
+ true, +1 );
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+#include "kspread_dlg_pasteinsert.moc"
diff --git a/kspread/dialogs/kspread_dlg_pasteinsert.h b/kspread/dialogs/kspread_dlg_pasteinsert.h
new file mode 100644
index 00000000..8914f90d
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_pasteinsert.h
@@ -0,0 +1,53 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2000-2002 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_pasteinsert__
+#define __kspread_dlg_pasteinsert__
+
+#include <kdialogbase.h>
+
+class QCheckBox;
+class QRadioButton;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class PasteInsertDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ PasteInsertDialog( View* parent, const char* name, const QRect &_rect );
+
+public slots:
+ void slotOk();
+private:
+ View* m_pView;
+ QRadioButton *rb1;
+ QRadioButton *rb2;
+ QRect rect;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_preference.cc b/kspread/dialogs/kspread_dlg_preference.cc
new file mode 100644
index 00000000..b6d0c216
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_preference.cc
@@ -0,0 +1,1042 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
+ (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2000-2005 Laurent Montel <montel@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2001-2002 David Faure <faure@kde.org>
+ (C) 2001 Werner Trobin <trobin@kde.org>
+ (C) 2000 Bernd Johannes Wuebben <wuebben@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qvbox.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qvgroupbox.h>
+#include <qwhatsthis.h>
+
+#include <kconfig.h>
+#include <kstatusbar.h>
+#include <knuminput.h>
+#include <kspell.h>
+#include <kmessagebox.h>
+#include <kdeversion.h>
+#include <kcolorbutton.h>
+
+#include <KoTabBar.h>
+#include <KoSpeaker.h>
+
+#include "kspread_sheet.h"
+#include "kspread_sheetprint.h"
+#include "kspread_doc.h"
+#include "kspread_canvas.h"
+#include "kspread_view.h"
+#include "kspread_locale.h"
+#include "kspread_editors.h"
+
+#include "kspread_dlg_preference.h"
+
+using namespace KSpread;
+
+PreferenceDialog::PreferenceDialog( View* parent, const char* /*name*/)
+ : KDialogBase(KDialogBase::IconList,i18n("Configure KSpread") ,
+ KDialogBase::Ok | KDialogBase::Cancel| KDialogBase::Default,
+ KDialogBase::Ok)
+
+{
+ m_pView=parent;
+
+ connect(this, SIGNAL(okClicked()),this,SLOT(slotApply()));
+
+ QVBox *page2=addVBoxPage(i18n("Locale Settings"), QString::null,BarIcon("gohome",KIcon::SizeMedium));
+ _localePage=new parameterLocale(parent,page2 );
+
+ QVBox *page3=addVBoxPage(i18n("Interface"), QString::null,BarIcon("signature", KIcon::SizeMedium) );
+ _configure = new configure(parent,page3 );
+
+ QVBox * page4=addVBoxPage(i18n("Misc"), QString::null,BarIcon("misc",KIcon::SizeMedium) );
+ _miscParameter = new miscParameters(parent,page4 );
+
+ QVBox *page5=addVBoxPage(i18n("Color"), QString::null,BarIcon("colorize",KIcon::SizeMedium) );
+ _colorParameter=new colorParameters(parent,page5 );
+
+ QVBox *page6=addVBoxPage(i18n("Page Layout"), QString::null,BarIcon("edit",KIcon::SizeMedium) );
+ _layoutPage=new configureLayoutPage(parent,page6 );
+
+ QVBox *page7 = addVBoxPage( i18n("Spelling"), i18n("Spell Checker Behavior"),
+ BarIcon("spellcheck", KIcon::SizeMedium) );
+ _spellPage=new configureSpellPage(parent,page7);
+
+ if (KoSpeaker::isKttsdInstalled()) {
+ QVBox *page8 = addVBoxPage( i18n("Abbreviation for Text-to-Speech", "TTS"),
+ i18n("Text-to-Speech Settings"), BarIcon("access", KIcon::SizeMedium) );
+ _ttsPage=new configureTTSPage(parent, page8);
+ } else _ttsPage = 0;
+
+}
+
+void PreferenceDialog::openPage(int flags)
+{
+ if(flags & KS_LOCALE)
+ showPage( 0 );
+ else if(flags & KS_INTERFACE)
+ showPage( 1 );
+ else if(flags & KS_MISC)
+ showPage( 2 );
+ else if(flags & KS_COLOR)
+ showPage( 3 );
+ else if(flags & KS_LAYOUT)
+ showPage( 4 );
+ else if(flags & KS_SPELLING)
+ showPage( 5 );
+}
+
+void PreferenceDialog::slotApply()
+{
+ m_pView->doc()->emitBeginOperation( false );
+ _configure->apply();
+ _miscParameter->apply();
+ _colorParameter->apply();
+ _layoutPage->apply();
+ _spellPage->apply();
+ _localePage->apply();
+ if (_ttsPage) _ttsPage->apply();
+ m_pView->doc()->refreshInterface();
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+}
+
+void PreferenceDialog::slotDefault()
+{
+ switch(activePageIndex())
+ {
+ case 1:
+ _configure->slotDefault();
+ break;
+ case 2:
+ _miscParameter->slotDefault();
+ break;
+ case 3:
+ _colorParameter->slotDefault();
+ break;
+ case 4:
+ _layoutPage->slotDefault();
+ break;
+ case 5:
+ _spellPage->slotDefault();
+ break;
+ case 6:
+ _ttsPage->slotDefault();
+ break;
+ default:
+ break;
+ }
+}
+
+
+parameterLocale::parameterLocale( View* _view, QVBox *box , char *name )
+ :QObject ( box->parent(),name)
+{
+ m_pView = _view;
+ m_bUpdateLocale=false;
+ QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Settings"), box, "GroupBox" );
+
+ KLocale* locale=_view->doc()->locale();
+
+ m_language=new QLabel( tmpQGroupBox,"label");
+ m_number=new QLabel( tmpQGroupBox,"label6");
+ m_date=new QLabel( tmpQGroupBox,"label1");
+ m_shortDate=new QLabel( tmpQGroupBox,"label5");
+ m_time=new QLabel( tmpQGroupBox,"label2");
+ m_money=new QLabel( tmpQGroupBox,"label3");
+
+ updateToMatchLocale(locale);
+
+ m_updateButton=new QPushButton ( i18n("&Update Locale Settings"), tmpQGroupBox);
+ connect(m_updateButton, SIGNAL(clicked()),this,SLOT(updateDefaultSystemConfig()));
+}
+
+void parameterLocale::apply()
+{
+ if (m_bUpdateLocale)
+ {
+ m_pView->doc()->emitBeginOperation( false );
+ m_pView->doc()->refreshLocale();
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ }
+}
+
+void parameterLocale::updateDefaultSystemConfig()
+{
+ m_bUpdateLocale=true;
+ static_cast<Locale*>(m_pView->doc()->locale())->defaultSystemConfig( );
+ KLocale* locale=m_pView->doc()->locale();
+ updateToMatchLocale( locale );
+}
+
+void parameterLocale::updateToMatchLocale(KLocale* locale)
+{
+ m_language->setText( i18n("Language: %1").arg( locale->language() ));
+ m_number->setText( i18n("Default number format: %1").arg( locale->formatNumber(12.55) ));
+ m_date->setText( i18n("Long date format: %1").arg( locale->formatDate( QDate::currentDate() )));
+ m_shortDate->setText( i18n("Short date format: %1").arg( locale->formatDate( QDate::currentDate() ,true) ));
+ m_time->setText( i18n("Time format: %1").arg( locale->formatTime( QTime::currentTime() ) ));
+ m_money->setText( i18n("Currency format: %1").arg( locale->formatMoney(12.55) ));
+}
+
+configure::configure( View* _view, QVBox *box , char *name )
+ :QObject ( box->parent(),name)
+ {
+ m_pView = _view;
+
+ bool vertical=true;
+ bool horizontal=true;
+ bool rowHeader=true;
+ bool colHeader=true;
+ bool tabbar=true;
+ bool formulaBar=true;
+ bool statusBar=true;
+ m_oldBackupFile = true;
+
+ QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Settings"), box, "GroupBox" );
+
+ config = Factory::global()->config();
+ int _page=1;
+
+ oldRecent=10;
+ oldAutoSaveValue=KoDocument::defaultAutoSave()/60;
+
+ if( config->hasGroup("Parameters" ))
+ {
+ config->setGroup( "Parameters" );
+ _page=config->readNumEntry( "NbPage" ,1) ;
+ horizontal=config->readBoolEntry("Horiz ScrollBar",true);
+ vertical=config->readBoolEntry("Vert ScrollBar",true);
+ colHeader=config->readBoolEntry("Column Header",true);
+ rowHeader=config->readBoolEntry("Row Header",true);
+ tabbar=config->readBoolEntry("Tabbar",true);
+ formulaBar=config->readBoolEntry("Formula bar",true);
+ statusBar=config->readBoolEntry("Status bar",true);
+ oldRecent=config->readNumEntry( "NbRecentFile" ,10);
+ oldAutoSaveValue=config->readNumEntry("AutoSave",KoDocument::defaultAutoSave()/60);
+ m_oldBackupFile=config->readBoolEntry("BackupFile",m_oldBackupFile);
+ }
+ nbPage=new KIntNumInput(_page, tmpQGroupBox , 10);
+ nbPage->setRange(1, 10, 1);
+ nbPage->setLabel(i18n("Number of sheets open at the &beginning:"));
+ QWhatsThis::add(nbPage, i18n( "Controls how many worksheets will be created if the option Start with an empty document is chosen when KSpread is started." ) );
+
+ nbRecentFile=new KIntNumInput(oldRecent, tmpQGroupBox , 10);
+ nbRecentFile->setRange(1, 20, 1);
+ nbRecentFile->setLabel(i18n("&Number of files to show in Recent Files list:"));
+ QWhatsThis::add(nbRecentFile, i18n( "Controls the maximum number of filenames that are shown when you select File-> Open Recent." ) );
+
+ autoSaveDelay=new KIntNumInput(oldAutoSaveValue, tmpQGroupBox , 10);
+ autoSaveDelay->setRange(0, 60, 1);
+ autoSaveDelay->setLabel(i18n("Au&tosave delay (minutes):"));
+ autoSaveDelay->setSpecialValueText(i18n("Do not save automatically"));
+ autoSaveDelay->setSuffix(i18n("min"));
+ QWhatsThis::add(autoSaveDelay, i18n( "Here you can select the time between autosaves, or disable this feature altogether by choosing Do not save automatically (drag the slider to the far left)." ) );
+
+ m_createBackupFile = new QCheckBox( i18n("Create backup files"), tmpQGroupBox );
+ m_createBackupFile->setChecked( m_oldBackupFile );
+ QWhatsThis::add(m_createBackupFile, i18n( "Check this box if you want some backup files created. This is checked per default." ) );
+
+ showVScrollBar=new QCheckBox(i18n("Show &vertical scrollbar"),tmpQGroupBox);
+ showVScrollBar->setChecked(vertical);
+ QWhatsThis::add(showVScrollBar, i18n( "Check or uncheck this box to show or hide the vertical scrollbar in all sheets." ) );
+
+ showHScrollBar=new QCheckBox(i18n("Show &horizontal scrollbar"),tmpQGroupBox);
+ showHScrollBar->setChecked(horizontal);
+ QWhatsThis::add(showHScrollBar, i18n( "Check or uncheck this box to show or hide the horizontal scrollbar in all sheets." ) );
+
+ showColHeader=new QCheckBox(i18n("Show c&olumn header"),tmpQGroupBox);
+ showColHeader->setChecked(colHeader);
+ QWhatsThis::add(showColHeader, i18n( "Check this box to show the column letters across the top of each worksheet." ) );
+ showRowHeader=new QCheckBox(i18n("Show &row header"),tmpQGroupBox);
+ showRowHeader->setChecked(rowHeader);
+ QWhatsThis::add(showRowHeader, i18n( "Check this box to show the row numbers down the left side." ) );
+
+ showTabBar =new QCheckBox(i18n("Show ta&bs"),tmpQGroupBox);
+ showTabBar->setChecked(tabbar);
+ QWhatsThis::add(showTabBar, i18n( "This check box controls whether the sheet tabs are shown at the bottom of the worksheet." ) );
+
+ showFormulaBar =new QCheckBox(i18n("Sho&w formula toolbar"),tmpQGroupBox);
+ showFormulaBar->setChecked(formulaBar);
+ QWhatsThis::add(showFormulaBar, i18n( "Here is where you can choose to show or hide the Formula bar." ) );
+
+ showStatusBar =new QCheckBox(i18n("Show stat&us bar"),tmpQGroupBox);
+ showStatusBar->setChecked(statusBar);
+ QWhatsThis::add(showStatusBar, i18n( "Uncheck this box if you want to hide the status bar." ) );
+}
+
+
+void configure::slotDefault()
+{
+ showHScrollBar->setChecked(true);
+ showRowHeader->setChecked(true);
+ showVScrollBar->setChecked(true);
+ showColHeader->setChecked(true);
+ showTabBar->setChecked(true);
+ showFormulaBar->setChecked(true);
+ showStatusBar->setChecked(true);
+ nbPage->setValue(1);
+ nbRecentFile->setValue(10);
+ autoSaveDelay->setValue(KoDocument::defaultAutoSave()/60);
+ m_createBackupFile->setChecked( true );
+}
+
+
+void configure::apply()
+{
+ m_pView->doc()->emitBeginOperation( false );
+ config->setGroup( "Parameters" );
+ config->writeEntry( "NbPage", nbPage->value());
+ Doc *doc =m_pView->doc();
+ bool active=true;
+ active=showHScrollBar->isChecked();
+ if( m_pView->horzScrollBar()->isVisible()!=active)
+ {
+ config->writeEntry( "Horiz ScrollBar",active);
+ if( active)
+ m_pView->horzScrollBar()->show();
+ else
+ m_pView->horzScrollBar()->hide();
+ doc->setShowHorizontalScrollBar(active);
+ }
+ active=showVScrollBar->isChecked();
+ if( m_pView->vertScrollBar()->isVisible()!=active)
+ {
+ config->writeEntry( "Vert ScrollBar", active);
+ if(active)
+ m_pView->vertScrollBar()->show();
+ else
+ m_pView->vertScrollBar()->hide();
+ doc->setShowVerticalScrollBar(active);
+
+ }
+ active=showColHeader->isChecked();
+ if( m_pView->hBorderWidget()->isVisible()!=active)
+ {
+ config->writeEntry( "Column Header", active);
+ if( active)
+ m_pView->hBorderWidget()->show();
+ else
+ m_pView->hBorderWidget()->hide();
+ doc->setShowColHeader(active);
+ }
+
+ active=showRowHeader->isChecked();
+ if( m_pView->vBorderWidget()->isVisible()!=active)
+ {
+ config->writeEntry( "Row Header", active);
+ if( active)
+ m_pView->vBorderWidget()->show();
+ else
+ m_pView->vBorderWidget()->hide();
+ doc->setShowRowHeader(active);
+ }
+
+ active=showTabBar->isChecked();
+ if(m_pView->tabBar()->isVisible()!=active)
+ {
+ config->writeEntry( "Tabbar", active);
+ if(active)
+ m_pView->tabBar()->show();
+ else
+ m_pView->tabBar()->hide();
+ doc->setShowTabBar(active);
+ }
+
+ active=showFormulaBar->isChecked();
+ if(m_pView->posWidget()->isVisible()!=active)
+ {
+ config->writeEntry( "Formula bar",active);
+ m_pView->editWidget()->showEditWidget(active);
+ if(active)
+ m_pView->posWidget()->show();
+ else
+ m_pView->posWidget()->hide();
+ doc->setShowFormulaBar(active);
+ }
+
+ active=showStatusBar->isChecked();
+ config->writeEntry( "Status bar",active);
+ m_pView->showStatusBar( active );
+
+ int val=nbRecentFile->value();
+ if( oldRecent!= val)
+ {
+ config->writeEntry( "NbRecentFile",val);
+ m_pView->changeNbOfRecentFiles(val);
+ }
+ val=autoSaveDelay->value();
+ if(val!=oldAutoSaveValue)
+ {
+ config->writeEntry( "AutoSave", val );
+ doc->setAutoSave(val*60);
+ }
+
+ bool state =m_createBackupFile->isChecked();
+ if(state!=m_oldBackupFile)
+ {
+ config->writeEntry( "BackupFile", state );
+ doc->setBackupFile( state);
+ m_oldBackupFile=state;
+ }
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+}
+
+
+miscParameters::miscParameters( View* _view,QVBox *box, char *name )
+ :QObject ( box->parent(),name)
+ {
+ m_pView = _view;
+
+
+ QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Misc"), box, "GroupBox" );
+
+ config = Factory::global()->config();
+ indentUnit = _view->doc()->unit();
+ double _indent = KoUnit::toUserValue( 10.0, indentUnit);
+ bool m_bMsgError=false;
+ if( config->hasGroup("Parameters" ))
+ {
+ config->setGroup( "Parameters" );
+ _indent = config->readDoubleNumEntry( "Indent" , _indent ) ;
+ m_bMsgError=config->readBoolEntry( "Msg error" ,false) ;
+ }
+
+ if( config->hasGroup("Misc") )
+ {
+ config->setGroup( "Misc" );
+ m_oldNbRedo=config->readNumEntry("UndoRedo",m_oldNbRedo);
+ }
+
+ m_undoRedoLimit=new KIntNumInput( m_oldNbRedo, tmpQGroupBox );
+ m_undoRedoLimit->setLabel(i18n("Undo/redo limit:"));
+ m_undoRedoLimit->setRange(10, 60, 1);
+
+
+ QLabel *label=new QLabel(i18n("&Completion mode:"), tmpQGroupBox);
+
+ typeCompletion=new QComboBox(tmpQGroupBox);
+ label->setBuddy(typeCompletion);
+ QWhatsThis::add(typeCompletion, i18n( "Lets you choose the (auto) text completion mode from a range of options in the drop down selection box." ) );
+ QStringList listType;
+ listType+=i18n("None");
+ listType+=i18n("Manual");
+ listType+=i18n("Popup");
+ listType+=i18n("Automatic");
+ listType+=i18n("Semi-Automatic");
+ typeCompletion->insertStringList(listType);
+ typeCompletion->setCurrentItem(0);
+ comboChanged=false;
+ connect(typeCompletion,SIGNAL(activated( const QString & )),this,SLOT(slotTextComboChanged(const QString &)));
+
+ label=new QLabel(i18n("&Pressing enter moves cell cursor:"), tmpQGroupBox);
+ typeOfMove=new QComboBox( tmpQGroupBox);
+ label->setBuddy(typeOfMove);
+ listType.clear();
+ listType+=i18n("Down");
+ listType+=i18n("Up");
+ listType+=i18n("Right");
+ listType+=i18n("Left");
+ listType+=i18n("Down, First Column");
+ typeOfMove->insertStringList(listType);
+ typeOfMove->setCurrentItem(0);
+ QWhatsThis::add(typeOfMove, i18n( "When you have selected a cell, pressing the Enter key will move the cell cursor one cell left, right, up or down, as determined by this setting." ) );
+
+ label=new QLabel(i18n("&Method of calc:"), tmpQGroupBox);
+
+ typeCalc=new QComboBox( tmpQGroupBox);
+ label->setBuddy(typeCalc);
+ QStringList listTypeCalc;
+ listTypeCalc+=i18n("Sum");
+ listTypeCalc+=i18n("Min");
+ listTypeCalc+=i18n("Max");
+ listTypeCalc+=i18n("Average");
+ listTypeCalc+=i18n("Count");
+ listTypeCalc+=i18n("CountA");
+ listTypeCalc+=i18n("None");
+ typeCalc->insertStringList(listTypeCalc);
+ typeCalc->setCurrentItem(0);
+ QWhatsThis::add(typeCalc, i18n( "This drop down selection box can be used to choose the calculation performed by the Statusbar Summary function." ) );
+
+// valIndent = new KDoubleNumInput( _indent, tmpQGroupBox , 10.0 );
+ valIndent = new KDoubleNumInput( tmpQGroupBox );
+ valIndent->setRange( KoUnit::toUserValue( 0.0, indentUnit ),
+ KoUnit::toUserValue( 400.0, indentUnit ),
+ KoUnit::toUserValue( 10.0, indentUnit) );
+// valIndent->setRange( 0.0, 100.0, 10.0 );
+ valIndent->setValue ( KoUnit::toUserValue( _indent, indentUnit ) );
+ QWhatsThis::add(valIndent, i18n( "Lets you define the amount of indenting used by the Increase Indent and Decrease Indent option in the Format menu." ) );
+ valIndent->setLabel(i18n("&Indentation step (%1):").arg(KoUnit::unitName(indentUnit)));
+
+ msgError= new QCheckBox(i18n("&Show error message for invalid formulae"),tmpQGroupBox);
+ msgError->setChecked(m_bMsgError);
+ QWhatsThis::add(msgError, i18n( "If this box is checked a message box will pop up when what you have entered into a cell cannot be understood by KSpread." ) );
+
+ initComboBox();
+}
+
+void miscParameters::slotTextComboChanged(const QString &)
+{
+ comboChanged=true;
+}
+
+void miscParameters::initComboBox()
+{
+ KGlobalSettings::Completion tmpCompletion=KGlobalSettings::CompletionAuto;
+ if( config->hasGroup("Parameters" ))
+ {
+ config->setGroup( "Parameters" );
+ tmpCompletion=( KGlobalSettings::Completion)config->readNumEntry( "Completion Mode" ,KGlobalSettings::CompletionAuto) ;
+ config->writeEntry( "Completion Mode", (int)tmpCompletion);
+ }
+switch(tmpCompletion )
+ {
+ case KGlobalSettings::CompletionNone:
+ typeCompletion->setCurrentItem(0);
+ break;
+ case KGlobalSettings::CompletionAuto:
+ typeCompletion->setCurrentItem(3);
+ break;
+ case KGlobalSettings::CompletionMan:
+ typeCompletion->setCurrentItem(4);
+ break;
+ case KGlobalSettings::CompletionShell:
+ typeCompletion->setCurrentItem(1);
+ break;
+ case KGlobalSettings::CompletionPopup:
+ typeCompletion->setCurrentItem(2);
+ break;
+ default :
+ typeCompletion->setCurrentItem(0);
+ break;
+ }
+switch( m_pView->doc()->getMoveToValue( ))
+ {
+ case Bottom:
+ typeOfMove->setCurrentItem(0);
+ break;
+ case Left:
+ typeOfMove->setCurrentItem(3);
+ break;
+ case Top:
+ typeOfMove->setCurrentItem(1);
+ break;
+ case Right:
+ typeOfMove->setCurrentItem(2);
+ break;
+ case BottomFirst:
+ typeOfMove->setCurrentItem(4);
+ break;
+ default :
+ typeOfMove->setCurrentItem(0);
+ break;
+ }
+
+switch( m_pView->doc()->getTypeOfCalc())
+ {
+ case SumOfNumber:
+ typeCalc->setCurrentItem(0);
+ break;
+ case Min:
+ typeCalc->setCurrentItem(1);
+ break;
+ case Max:
+ typeCalc->setCurrentItem(2);
+ break;
+ case Average:
+ typeCalc->setCurrentItem(3);
+ break;
+ case Count:
+ typeCalc->setCurrentItem(4);
+ break;
+ case CountA:
+ typeCalc->setCurrentItem(5);
+ break;
+ case NoneCalc:
+ typeCalc->setCurrentItem(6);
+ break;
+ default :
+ typeCalc->setCurrentItem(0);
+ break;
+ }
+
+}
+
+void miscParameters::slotDefault()
+{
+ m_undoRedoLimit->setValue(30);
+ valIndent->setValue( KoUnit::toUserValue( 10.0, indentUnit) );
+ typeCompletion->setCurrentItem(3);
+ typeOfMove->setCurrentItem(0);
+ msgError->setChecked(false);
+ typeCalc->setCurrentItem(0);
+}
+
+
+void miscParameters::apply()
+{
+ kdDebug() << "Applying misc preferences" << endl;
+
+ config->setGroup( "Misc" );
+ int const newUndo=m_undoRedoLimit->value();
+ if( newUndo!=m_oldNbRedo )
+ {
+ config->writeEntry("UndoRedo",newUndo);
+ m_pView->doc()->setUndoRedoLimit(newUndo);
+ m_oldNbRedo=newUndo;
+ }
+
+ config->setGroup( "Parameters" );
+ KGlobalSettings::Completion tmpCompletion=KGlobalSettings::CompletionNone;
+
+ switch(typeCompletion->currentItem())
+ {
+ case 0:
+ tmpCompletion=KGlobalSettings::CompletionNone;
+ break;
+ case 1:
+ tmpCompletion=KGlobalSettings::CompletionShell;
+ break;
+ case 2:
+ tmpCompletion=KGlobalSettings::CompletionPopup;
+ break;
+ case 3:
+ tmpCompletion=KGlobalSettings::CompletionAuto;
+ break;
+ case 4:
+ tmpCompletion=KGlobalSettings::CompletionMan;
+ break;
+ }
+
+
+ if(comboChanged)
+ {
+ m_pView->doc()->setCompletionMode(tmpCompletion);
+ config->writeEntry( "Completion Mode", (int)tmpCompletion);
+ }
+
+ KSpread::MoveTo tmpMoveTo=Bottom;
+ switch(typeOfMove->currentItem())
+ {
+ case 0:
+ tmpMoveTo=Bottom;
+ break;
+ case 1:
+ tmpMoveTo=Top;
+ break;
+ case 2:
+ tmpMoveTo=Right;
+ break;
+ case 3:
+ tmpMoveTo=Left;
+ break;
+ case 4:
+ tmpMoveTo=BottomFirst;
+ break;
+ }
+ if(tmpMoveTo!=m_pView->doc()->getMoveToValue())
+ {
+ m_pView->doc()->setMoveToValue(tmpMoveTo);
+ config->writeEntry( "Move", (int)tmpMoveTo);
+ }
+
+ MethodOfCalc tmpMethodCalc=SumOfNumber;
+ switch(typeCalc->currentItem())
+ {
+ case 0:
+ tmpMethodCalc =SumOfNumber;
+ break;
+ case 1:
+ tmpMethodCalc=Min;
+ break;
+ case 2:
+ tmpMethodCalc=Max;
+ break;
+ case 3:
+ tmpMethodCalc=Average;
+ break;
+ case 4:
+ tmpMethodCalc=Count;
+ break;
+ case 5:
+ tmpMethodCalc=CountA;
+ break;
+ case 6:
+ tmpMethodCalc=NoneCalc;
+ break;
+
+ }
+ if(tmpMethodCalc!=m_pView->doc()->getTypeOfCalc())
+ {
+ m_pView->doc()->setTypeOfCalc(tmpMethodCalc);
+ config->writeEntry( "Method of Calc", (int)tmpMethodCalc);
+ m_pView->calcStatusBarOp();
+ m_pView->initCalcMenu();
+ }
+
+ double val = valIndent->value();
+ if( val != m_pView->doc()->getIndentValue() )
+ {
+ KoUnit::Unit oldUnit = m_pView->doc()->unit();
+ m_pView->doc()->setUnit(indentUnit);
+ m_pView->doc()->setIndentValue( val );
+ m_pView->doc()->setUnit(oldUnit);
+ config->writeEntry( "Indent", KoUnit::fromUserValue( val, indentUnit ) );
+ }
+
+ bool active=msgError->isChecked();
+ if(active!=m_pView->doc()->getShowMessageError())
+ {
+ m_pView->doc()->setShowMessageError( active);
+ config->writeEntry( "Msg error" ,(int)active);
+ }
+}
+
+
+
+colorParameters::colorParameters( View* _view,QVBox *box , char *name )
+ :QObject ( box->parent(),name)
+{
+ m_pView = _view;
+ config = Factory::global()->config();
+
+ QColor _gridColor(Qt::lightGray);
+
+ if ( config->hasGroup("KSpread Color" ) )
+ {
+ config->setGroup( "KSpread Color" );
+ _gridColor = config->readColorEntry("GridColor",&_gridColor);
+ }
+
+ QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Color"), box, "GroupBox" );
+
+ QLabel *label = new QLabel(i18n("&Grid color:"), tmpQGroupBox,"label20" );
+
+ gridColor = new KColorButton( _gridColor,
+ Qt::lightGray,
+ tmpQGroupBox );
+ QWhatsThis::add(gridColor, i18n( "Click here to change the grid color ie the color of the borders of each cell." ) );
+ label->setBuddy(gridColor);
+
+ QColor _pbColor(Qt::red);
+ if ( config->hasGroup("KSpread Color" ) )
+ {
+ config->setGroup( "KSpread Color" );
+ _pbColor = config->readColorEntry("PageBorderColor", &_pbColor);
+ }
+
+ QLabel * label2 = new QLabel( i18n("&Page borders:"), tmpQGroupBox, "label21" );
+
+ pageBorderColor = new KColorButton( _pbColor,
+ Qt::red,
+ tmpQGroupBox );
+ QWhatsThis::add(pageBorderColor, i18n( "When the View ->Show Page Borders menu item is checked, the page borders are displayed. Click here to choose another color for the borders than the default red." ) );
+
+ label2->setBuddy(pageBorderColor);
+}
+
+void colorParameters::apply()
+{
+ QColor _col = gridColor->color();
+ if ( m_pView->doc()->gridColor() != _col )
+ {
+ m_pView->doc()->setGridColor( _col );
+ config->setGroup( "KSpread Color" );
+ config->writeEntry( "GridColor", _col );
+ }
+
+ QColor _pbColor = pageBorderColor->color();
+ if ( m_pView->doc()->pageBorderColor() != _pbColor )
+ {
+ m_pView->doc()->changePageBorderColor( _pbColor );
+ config->setGroup( "KSpread Color" );
+ config->writeEntry( "PageBorderColor", _pbColor );
+ }
+}
+
+void colorParameters::slotDefault()
+{
+ gridColor->setColor( lightGray );
+ pageBorderColor->setColor( red );
+}
+
+
+
+configureLayoutPage::configureLayoutPage( View* _view,QVBox *box , char *name )
+ :QObject ( box->parent(),name)
+{
+ m_pView = _view;
+
+ QGroupBox* tmpQGroupBox = new QGroupBox( 0, Qt::Vertical, i18n("Default Parameters"), box, "GroupBox" );
+ tmpQGroupBox->layout()->setSpacing(KDialog::spacingHint());
+ tmpQGroupBox->layout()->setMargin(KDialog::marginHint());
+
+ QGridLayout *grid1 = new QGridLayout(tmpQGroupBox->layout(),8,1);
+ grid1->addRowSpacing( 0, KDialog::marginHint() );
+ grid1->setRowStretch( 7, 10 );
+
+ config = Factory::global()->config();
+
+ QLabel *label=new QLabel(i18n("Default page &size:"), tmpQGroupBox);
+
+ grid1->addWidget(label,0,0);
+
+ defaultSizePage=new QComboBox( tmpQGroupBox);
+ label->setBuddy(defaultSizePage);
+ defaultSizePage->insertStringList( KoPageFormat::allFormats() );
+ defaultSizePage->setCurrentItem(1);
+ QWhatsThis::add(defaultSizePage, i18n( "Choose the default page size for your worksheet among all the most common page sizes.\nNote that you can overwrite the page size for the current sheet using the Format -> Page Layout... dialog." ) );
+ grid1->addWidget(defaultSizePage,1,0);
+
+ label=new QLabel(i18n("Default page &orientation:"), tmpQGroupBox);
+ grid1->addWidget(label,2,0);
+
+ defaultOrientationPage=new QComboBox( tmpQGroupBox);
+ label->setBuddy(defaultOrientationPage);
+
+ QStringList listType;
+ listType+=i18n( "Portrait" );
+ listType+=i18n( "Landscape" );
+ defaultOrientationPage->insertStringList(listType);
+ defaultOrientationPage->setCurrentItem(0);
+ QWhatsThis::add(defaultOrientationPage, i18n( "Choose the sheet orientation: portrait or lanscape.\nNote that you can overwrite the orientation for the current sheet using the Format -> Page Layout... dialog." ) );
+ grid1->addWidget(defaultOrientationPage,3,0);
+
+ label=new QLabel(tmpQGroupBox);
+ label->setText(i18n("Default page &unit:"));
+ grid1->addWidget(label,4,0);
+ defaultUnit=new QComboBox( tmpQGroupBox);
+ label->setBuddy(defaultUnit);
+
+ defaultUnit->insertStringList(KoUnit::listOfUnitName());
+ defaultUnit->setCurrentItem(0);
+ QWhatsThis::add(defaultUnit, i18n( "Choose the default unit that will be used in your sheet.\nNote that you can overwrite the unit for the current sheet using the Format -> Page Layout... dialog." ) );
+ grid1->addWidget(defaultUnit,5,0);
+ initCombo();
+
+}
+
+void configureLayoutPage::slotDefault()
+{
+ defaultSizePage->setCurrentItem(1);
+ defaultOrientationPage->setCurrentItem(0);
+ defaultUnit->setCurrentItem(0);
+}
+
+void configureLayoutPage::initCombo()
+{
+ paper=1;
+ orientation=0;
+ unit=0;
+ if( config->hasGroup("KSpread Page Layout" ))
+ {
+ config->setGroup( "KSpread Page Layout" );
+ paper=config->readNumEntry( "Default size page" ,1);
+ orientation=config->readNumEntry( "Default orientation page" ,0);
+ unit=config->readNumEntry( "Default unit page" ,0);
+ }
+
+ defaultUnit->setCurrentItem(m_pView->doc()->unit());
+ defaultSizePage->setCurrentItem(paper);
+ defaultOrientationPage->setCurrentItem(orientation);
+}
+
+
+void configureLayoutPage::apply()
+{
+ m_pView->doc()->emitBeginOperation( false );
+ config->setGroup( "KSpread Page Layout" );
+
+ if( paper != defaultSizePage->currentItem() )
+ {
+ unsigned int sizePage = defaultSizePage->currentItem();
+ config->writeEntry( "Default size page", sizePage );
+ m_pView->activeSheet()->print()->setPaperFormat( (KoFormat)sizePage );
+ }
+ if( orientation != defaultOrientationPage->currentItem() )
+ {
+ unsigned int orientationPage = defaultOrientationPage->currentItem();
+ config->writeEntry( "Default orientation page", orientationPage );
+ m_pView->activeSheet()->print()->setPaperOrientation( (KoOrientation)orientationPage );
+ }
+ if( unit != defaultUnit->currentItem() )
+ {
+ unsigned int unitPage = defaultUnit->currentItem();
+ config->writeEntry( "Default unit page", unitPage );
+ m_pView->doc()->setUnit( (KoUnit::Unit)unitPage );
+ }
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+}
+
+configureSpellPage::configureSpellPage( View* _view,QVBox *box , char *name )
+ :QObject ( box->parent(),name)
+{
+ m_pView = _view;
+
+ config = Factory::global()->config();
+
+
+ m_spellConfigWidget = new KSpellConfig( box, "spell_check",m_pView->doc()->getKSpellConfig()/*, false*/);
+ dontCheckUpperWord = new QCheckBox( i18n("Skip all uppercase words"),box);
+ QWhatsThis::add(dontCheckUpperWord, i18n( "If checked, the words written in uppercase letters are not spell checked. This might be useful if you have a lot of acronyms such as KDE for example." ) );
+ dontCheckTitleCase = new QCheckBox( i18n("Do not check title case"),box);
+ QWhatsThis::add(dontCheckTitleCase, i18n( "Check this box if you want the spellchecker to ignore the title case, for example My Own Spreadsheet or My own spreadsheet. If this is unchecked, the spell checker will ask for a uppercase letter in the title nouns." ) );
+
+ QWidget* spacer = new QWidget( box );
+ spacer->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
+
+ if( config->hasGroup("KSpell kspread") )
+ {
+ config->setGroup( "KSpell kspread" );
+
+ dontCheckUpperWord->setChecked(config->readBoolEntry("KSpell_dont_check_upper_word",false));
+ dontCheckTitleCase->setChecked(config->readBoolEntry("KSpell_dont_check_title_case",false));
+ }
+ //m_spellConfigWidget->addIgnoreList( m_pView->doc()->spellListIgnoreAll() );
+}
+
+
+void configureSpellPage::apply()
+{
+ m_pView->doc()->emitBeginOperation( false );
+
+ KSpellConfig *_spellConfig = m_spellConfigWidget;
+ config->setGroup( "KSpell kspread" );
+ config->writeEntry ("KSpell_NoRootAffix",(int) _spellConfig->noRootAffix ());
+ config->writeEntry ("KSpell_RunTogether", (int) _spellConfig->runTogether ());
+ config->writeEntry ("KSpell_Dictionary", _spellConfig->dictionary ());
+ config->writeEntry ("KSpell_DictFromList",(int) _spellConfig->dictFromList());
+ config->writeEntry ("KSpell_Encoding", (int) _spellConfig->encoding());
+ config->writeEntry ("KSpell_Client", _spellConfig->client());
+// m_spellConfigWidget->saveDictionary();
+ Doc* doc = m_pView->doc();
+ doc->setKSpellConfig(*_spellConfig);
+
+ bool state=dontCheckUpperWord->isChecked();
+ config->writeEntry ("KSpell_dont_check_upper_word",(int)state);
+ doc->setDontCheckUpperWord(state);
+
+ state=dontCheckTitleCase->isChecked();
+ config->writeEntry("KSpell_dont_check_title_case",(int)state);
+ doc->setDontCheckTitleCase(state);
+
+ //m_pView->doc()->addIgnoreWordAllList( m_spellConfigWidget->ignoreList() );
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+}
+
+void configureSpellPage::slotDefault()
+{
+ //FIXME
+ //m_spellConfigWidget->setDefault();
+}
+
+////
+
+configureTTSPage::configureTTSPage( View *_view, QVBox *box, char *name )
+ : QObject( box->parent(), name )
+{
+ Q_UNUSED(_view);
+
+ m_cbSpeakPointerWidget = new QCheckBox(i18n("Speak widget under &mouse pointer"), box);
+ m_cbSpeakFocusWidget = new QCheckBox(i18n("Speak widget with &focus"), box);
+ m_gbScreenReaderOptions = new QVGroupBox("", box);
+ m_gbScreenReaderOptions->setMargin( KDialog::marginHint() );
+ m_gbScreenReaderOptions->setInsideSpacing( KDialog::spacingHint() );
+ m_cbSpeakTooltips = new QCheckBox(i18n("Speak &tool tips"), m_gbScreenReaderOptions);
+ m_cbSpeakWhatsThis = new QCheckBox(i18n("Speak &What's This"), m_gbScreenReaderOptions);
+ m_cbSpeakDisabled = new QCheckBox(i18n("Verbal indication if widget is disabled (grayed)",
+ "&Say whether disabled"), m_gbScreenReaderOptions);
+ m_cbSpeakAccelerators = new QCheckBox(i18n("Spea&k accelerators"), m_gbScreenReaderOptions);
+ QHBox* hbAcceleratorPrefix = new QHBox(m_gbScreenReaderOptions);
+ QWidget* spacer = new QWidget(hbAcceleratorPrefix);
+ spacer->setMinimumWidth(2 * KDialog::marginHint());
+ m_lblAcceleratorPrefix =
+ new QLabel(i18n("A word spoken before another word", "Pr&efaced by the word:"),
+ hbAcceleratorPrefix);
+ m_leAcceleratorPrefixWord = new QLineEdit(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"),
+ hbAcceleratorPrefix);
+ m_lblAcceleratorPrefix->setBuddy(m_leAcceleratorPrefixWord);
+ QHBox* hbPollingInterval = new QHBox(m_gbScreenReaderOptions);
+ hbPollingInterval->setMargin( 0 );
+ QLabel* lblPollingInterval = new QLabel(i18n("&Polling interval:"), hbPollingInterval);
+ m_iniPollingInterval = new KIntNumInput(hbPollingInterval);
+ m_iniPollingInterval->setSuffix(" ms");
+ m_iniPollingInterval->setRange(100, 5000, 100, true);
+ lblPollingInterval->setBuddy(m_iniPollingInterval);
+
+ config = Factory::global()->config();
+ config->setGroup("TTS");
+ m_cbSpeakPointerWidget->setChecked(config->readBoolEntry("SpeakPointerWidget", false));
+ m_cbSpeakFocusWidget->setChecked(config->readBoolEntry("SpeakFocusWidget", false));
+ m_cbSpeakTooltips->setChecked(config->readBoolEntry("SpeakTooltips", true));
+ m_cbSpeakWhatsThis->setChecked(config->readBoolEntry("SpeakWhatsThis", false));
+ m_cbSpeakDisabled->setChecked(config->readBoolEntry("SpeakDisabled", true));
+ m_cbSpeakAccelerators->setChecked(config->readBoolEntry("SpeakAccelerators", true));
+ m_leAcceleratorPrefixWord->setText(config->readEntry("AcceleratorPrefixWord",
+ i18n("Keyboard accelerator, such as Alt+F", "Accelerator")));
+ m_iniPollingInterval->setValue(config->readNumEntry("PollingInterval", 600));
+
+ screenReaderOptionChanged();
+ connect(m_cbSpeakPointerWidget, SIGNAL(toggled(bool)), this, SLOT(screenReaderOptionChanged()));
+ connect(m_cbSpeakFocusWidget, SIGNAL(toggled(bool)), this, SLOT(screenReaderOptionChanged()));
+ connect(m_cbSpeakAccelerators, SIGNAL(toggled(bool)), this, SLOT(screenReaderOptionChanged()));
+}
+
+void configureTTSPage::slotDefault()
+{
+ m_cbSpeakPointerWidget->setChecked(false);
+ m_cbSpeakFocusWidget->setChecked(false);
+ m_cbSpeakTooltips->setChecked(true);
+ m_cbSpeakWhatsThis->setChecked(false);
+ m_cbSpeakDisabled->setChecked(true);
+ m_cbSpeakAccelerators->setChecked(true);
+ m_leAcceleratorPrefixWord->setText(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"));
+ m_iniPollingInterval->setValue(600);
+}
+
+void configureTTSPage::apply()
+{
+ config->setGroup("TTS");
+ config->writeEntry("SpeakPointerWidget", m_cbSpeakPointerWidget->isChecked());
+ config->writeEntry("SpeakFocusWidget", m_cbSpeakFocusWidget->isChecked());
+ config->writeEntry("SpeakTooltips", m_cbSpeakTooltips->isChecked());
+ config->writeEntry("SpeakWhatsThis", m_cbSpeakWhatsThis->isChecked());
+ config->writeEntry("SpeakDisabled", m_cbSpeakDisabled->isChecked());
+ config->writeEntry("SpeakAccelerators", m_cbSpeakAccelerators->isChecked());
+ config->writeEntry("AcceleratorPrefixWord", m_leAcceleratorPrefixWord->text());
+ config->writeEntry("PollingInterval", m_iniPollingInterval->value());
+ if (kospeaker) kospeaker->readConfig(config);
+}
+
+void configureTTSPage::screenReaderOptionChanged()
+{
+ m_gbScreenReaderOptions->setEnabled(
+ m_cbSpeakPointerWidget->isChecked() || m_cbSpeakFocusWidget->isChecked());
+ m_leAcceleratorPrefixWord->setEnabled(m_cbSpeakAccelerators->isChecked());
+ m_lblAcceleratorPrefix->setEnabled(m_cbSpeakAccelerators->isChecked());
+}
+
+#include "kspread_dlg_preference.moc"
diff --git a/kspread/dialogs/kspread_dlg_preference.h b/kspread/dialogs/kspread_dlg_preference.h
new file mode 100644
index 00000000..d23739b8
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_preference.h
@@ -0,0 +1,223 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2000-2003 Laurent Montel <montel@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2001-2002 David Faure <faure@kde.org>
+ (C) 2001 Werner Trobin <trobin@kde.org>
+ (C) 2000 Bernd Johannes Wuebben <wuebben@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_preference__
+#define __kspread_dlg_preference__
+
+#include <kdialogbase.h>
+
+class KConfig;
+class KIntNumInput;
+class KDoubleNumInput;
+class KSpellConfig;
+class QCheckBox;
+class QComboBox;
+class QVGroupBox;
+class QPushButton;
+class KColorButton;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class parameterLocale : public QObject
+{
+ Q_OBJECT
+public:
+ parameterLocale( View* _view,QVBox *box, char *name = 0);
+ void apply();
+public slots:
+ void updateDefaultSystemConfig();
+ protected:
+ /**
+ * Updates the GUI widgets to match the specified locale.
+ */
+ void updateToMatchLocale(KLocale* locale);
+
+ QLabel *m_shortDate,*m_time,*m_money,*m_date,*m_language,*m_number;
+ QPushButton *m_updateButton;
+ View* m_pView;
+ bool m_bUpdateLocale;
+};
+
+class configure : public QObject
+{
+ Q_OBJECT
+public:
+ configure( View* _view,QVBox *box, char *name = 0 );
+ void apply();
+ void slotDefault();
+protected:
+ View* m_pView;
+ KIntNumInput *nbPage;
+ KIntNumInput* nbRecentFile;
+ KIntNumInput* autoSaveDelay;
+ QCheckBox *showVScrollBar;
+ QCheckBox *showHScrollBar;
+ QCheckBox *showColHeader;
+ QCheckBox *showRowHeader;
+ QCheckBox *showTabBar;
+ QCheckBox *showFormulaBar;
+ QCheckBox *showStatusBar;
+ QCheckBox *m_createBackupFile;
+ bool m_oldBackupFile;
+
+ KConfig* config;
+ int oldRecent;
+ int oldAutoSaveValue;
+} ;
+
+
+class miscParameters : public QObject
+{
+ Q_OBJECT
+public:
+ miscParameters( View* _view, QVBox *box, char *name = 0 );
+ void apply();
+ void slotDefault();
+
+ void initComboBox();
+
+public slots:
+ void slotTextComboChanged(const QString &);
+
+protected:
+ View* m_pView;
+ KDoubleNumInput *valIndent;
+
+ /**
+ * Needed to ensure the same unit for loading and saving.
+ */
+ KoUnit::Unit indentUnit;
+ KConfig* config;
+ QComboBox *typeCompletion;
+ QComboBox *typeCalc;
+ QComboBox *typeOfMove;
+ QCheckBox *msgError;
+ KIntNumInput* m_undoRedoLimit;
+ bool comboChanged;
+ int m_oldNbRedo;
+} ;
+
+class colorParameters : public QObject
+{
+ Q_OBJECT
+public:
+ colorParameters( View* _view, QVBox *box, char *name = 0 );
+ void apply();
+ void slotDefault();
+protected:
+ View* m_pView;
+ KColorButton* gridColor;
+ KColorButton* pageBorderColor;
+ KConfig* config;
+} ;
+
+class configureLayoutPage : public QObject
+{
+ Q_OBJECT
+public:
+ configureLayoutPage( View* _view,QVBox *box, char *name = 0 );
+ void apply();
+ void slotDefault();
+ void initCombo();
+protected:
+ View* m_pView;
+ QComboBox *defaultOrientationPage;
+ QComboBox *defaultSizePage;
+ QComboBox *defaultUnit;
+ //store old config
+ int paper;
+ int orientation;
+ int unit;
+
+ KConfig* config;
+} ;
+
+class configureSpellPage : public QObject
+{
+ Q_OBJECT
+public:
+ configureSpellPage( View* _view, QVBox *box, char *name = 0 );
+ void apply();
+ void slotDefault();
+protected:
+ View * m_pView;
+ KConfig * config;
+ KSpellConfig *m_spellConfigWidget;
+ QCheckBox *dontCheckUpperWord;
+ QCheckBox *dontCheckTitleCase;
+} ;
+
+class configureTTSPage : public QObject
+{
+ Q_OBJECT
+public:
+ configureTTSPage( View *_view, QVBox *box, char *name = 0 );
+ void slotDefault();
+ void apply();
+private slots:
+ void screenReaderOptionChanged();
+private:
+ KConfig* config;
+ QCheckBox* m_cbSpeakPointerWidget;
+ QCheckBox* m_cbSpeakFocusWidget;
+ QVGroupBox* m_gbScreenReaderOptions;
+ QCheckBox* m_cbSpeakTooltips;
+ QCheckBox* m_cbSpeakWhatsThis;
+ QCheckBox* m_cbSpeakDisabled;
+ QCheckBox* m_cbSpeakAccelerators;
+ QLabel* m_lblAcceleratorPrefix;
+ QLineEdit* m_leAcceleratorPrefixWord;
+ KIntNumInput* m_iniPollingInterval;
+};
+
+class PreferenceDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ enum { KS_PREFERENCES = 1, KS_LOCALE = 2, KS_INTERFACE = 4,
+ KS_MISC = 8, KS_COLOR = 16, KS_LAYOUT = 32, KS_SPELLING = 64 };
+ PreferenceDialog( View* parent, const char* name);
+public slots:
+ void slotApply();
+ void slotDefault();
+ void openPage(int flags);
+private :
+ View* m_pView;
+ configure * _configure;
+ miscParameters *_miscParameter;
+ colorParameters *_colorParameter;
+ configureLayoutPage *_layoutPage;
+ configureSpellPage *_spellPage;
+ parameterLocale *_localePage;
+ configureTTSPage *_ttsPage;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_reference.cc b/kspread/dialogs/kspread_dlg_reference.cc
new file mode 100644
index 00000000..5c7faf2b
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_reference.cc
@@ -0,0 +1,368 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Harri Porten <porten@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+
+
+#include "kspread_dlg_reference.h"
+#include "kspread_canvas.h"
+#include "kspread_doc.h"
+#include "kspread_util.h"
+#include "kspread_map.h"
+#include "kspread_view.h"
+#include "kspread_sheet.h"
+#include "selection.h"
+#include "kspread_locale.h"
+
+#include <qvariant.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+
+#include <kbuttonbox.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+#include <kdeversion.h>
+
+#include <kstdguiitem.h>
+
+using namespace KSpread;
+
+reference::reference( View* parent, const char* name )
+ : QDialog( parent, name,TRUE )
+{
+ m_pView = parent;
+ QVBoxLayout *lay1 = new QVBoxLayout( this );
+ lay1->setMargin( KDialog::marginHint() );
+ lay1->setSpacing( KDialog::spacingHint() );
+ m_list = new QListBox(this);
+ lay1->addWidget( m_list );
+
+ setCaption( i18n("Area Name") );
+
+ m_rangeName = new QLabel(this);
+ lay1->addWidget(m_rangeName);
+
+ m_pRemove = new QPushButton(i18n("&Remove"), this);
+ lay1->addWidget( m_pRemove );
+ //m_pRemove->setEnabled(false);
+ KButtonBox *bb = new KButtonBox( this );
+ // bb->addStretch();
+ m_pEdit = bb->addButton( i18n("&Edit...") );
+ m_pOk = bb->addButton( KStdGuiItem::ok() );
+ m_pCancel = bb->addButton( KStdGuiItem::cancel() );
+ m_pOk->setDefault( TRUE );
+ bb->layout();
+ lay1->addWidget( bb );
+
+ QString text;
+ QStringList sheetName;
+ QPtrListIterator<Sheet> it2 ( m_pView->doc()->map()->sheetList() );
+ for( ; it2.current(); ++it2 )
+ {
+ sheetName.append( it2.current()->sheetName());
+ }
+
+ QValueList<Reference>::Iterator it;
+ QValueList<Reference> area = m_pView->doc()->listArea();
+ for ( it = area.begin(); it != area.end(); ++it )
+ {
+ text = (*it).ref_name;
+ if ( sheetName.contains((*it).sheet_name ))
+ m_list->insertItem(text);
+ }
+
+ if ( !m_list->count() )
+ {
+ m_pOk->setEnabled( false );
+ m_pRemove->setEnabled( false );
+ m_pEdit->setEnabled( false );
+ }
+
+ connect( m_pOk, SIGNAL( clicked() ), this, SLOT( slotOk() ) );
+ connect( m_pCancel, SIGNAL( clicked() ), this, SLOT( slotCancel() ) );
+ connect( m_pEdit, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
+ connect( m_pRemove, SIGNAL( clicked() ), this, SLOT( slotRemove() ) );
+ connect( m_list, SIGNAL(doubleClicked(QListBoxItem *)), this,
+ SLOT(slotDoubleClicked(QListBoxItem *)));
+ connect( m_list, SIGNAL(highlighted ( QListBoxItem * ) ), this,
+ SLOT(slotHighlighted(QListBoxItem * )));
+ m_rangeName->setText(i18n("Area: %1").arg(""));
+
+ resize( 250, 200 );
+}
+
+void reference::displayAreaValues(QString const & areaName)
+{
+ QString tmpName;
+ QValueList<Reference>::Iterator it;
+ QValueList<Reference> area( m_pView->doc()->listArea() );
+ for ( it = area.begin(); it != area.end(); ++it )
+ {
+ if ((*it).ref_name == areaName)
+ {
+ if (!m_pView->doc()->map()->findSheet( (*it).sheet_name))
+ kdDebug(36001) << "(*it).table_name '" << (*it).sheet_name
+ << "' not found!*********" << endl;
+ else
+ tmpName = util_rangeName(m_pView->doc()->map()->findSheet( (*it).sheet_name),
+ (*it).rect);
+ break;
+ }
+ }
+
+ tmpName = i18n("Area: %1").arg(tmpName);
+ m_rangeName->setText(tmpName);
+}
+
+void reference::slotHighlighted(QListBoxItem * )
+{
+ QString tmp = m_list->text(m_list->currentItem());
+ displayAreaValues(tmp);
+}
+
+void reference::slotDoubleClicked(QListBoxItem *)
+{
+ slotOk();
+}
+
+void reference::slotRemove()
+{
+ if (m_list->currentItem() == -1)
+ return;
+
+ int ret = KMessageBox::warningContinueCancel( this, i18n("Do you really want to remove this area name?"),i18n("Remove Area"),KStdGuiItem::del());
+ if (ret == KMessageBox::Cancel)
+ return;
+
+ QString textRemove;
+ if ( m_list->currentItem() != -1)
+ {
+ m_pView->doc()->emitBeginOperation( false );
+
+ QString textRemove = m_list->text(m_list->currentItem());
+ m_pView->doc()->removeArea(textRemove );
+ m_pView->doc()->setModified(true);
+ /*
+ m_list->clear();
+ QString text;
+ QValueList<Reference>::Iterator it;
+ QValueList<Reference> area=m_pView->doc()->listArea();
+ for ( it = area.begin(); it != area.end(); ++it )
+ {
+ text=(*it).ref_name;
+ m_list->insertItem(text);
+ }
+ */
+
+ m_list->removeItem(m_list->currentItem());
+
+ Sheet *tbl;
+
+ for ( tbl = m_pView->doc()->map()->firstSheet(); tbl != 0L; tbl = m_pView->doc()->map()->nextSheet() )
+ {
+ tbl->refreshRemoveAreaName(textRemove);
+ }
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ }
+
+ if ( !m_list->count() )
+ {
+ m_pOk->setEnabled( false );
+ m_pRemove->setEnabled( false );
+ m_pEdit->setEnabled( false );
+ }
+}
+
+void reference::slotEdit()
+{
+ QString name(m_list->text(m_list->currentItem()));
+ if ( name.isEmpty() )
+ return;
+ EditAreaName editDlg( m_pView, "EditArea", name );
+ editDlg.exec();
+
+ m_rangeName->setText(i18n("Area: %1").arg(""));
+ QString tmp = m_list->text(m_list->currentItem());
+ if (!tmp.isEmpty())
+ displayAreaValues( tmp );
+}
+
+void reference::slotOk()
+{
+ m_pView->doc()->emitBeginOperation( false );
+
+ QString text;
+ if (m_list->currentItem() != -1)
+ {
+ int index = m_list->currentItem();
+ text = m_list->text(index);
+ QValueList<Reference> area = m_pView->doc()->listArea();
+
+ if (m_pView->activeSheet()->sheetName() != area[ index ].sheet_name)
+ {
+ Sheet *sheet = m_pView->doc()->map()->findSheet(area[ index ].sheet_name);
+ if (sheet)
+ m_pView->setActiveSheet(sheet);
+ }
+
+ Region region(m_pView, Cell::fullName(m_pView->activeSheet(), area[index].rect.left(), area[index].rect.top()));
+ m_pView->selectionInfo()->initialize(region);
+ m_pView->selectionInfo()->initialize(area[ index ].rect);//, m_pView->activeSheet() );
+ }
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+void reference::slotCancel()
+{
+ reject();
+}
+
+
+
+EditAreaName::EditAreaName( View * parent,
+ const char * name,
+ QString const & areaname )
+ : KDialogBase( parent, name ,true,i18n( "Edit Area" ) , Ok|Cancel )
+{
+ m_pView = parent;
+
+ resize( 350, 142 );
+ setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5,
+ (QSizePolicy::SizeType)4, 0, 0,
+ sizePolicy().hasHeightForWidth() ) );
+
+ QWidget * page = new QWidget( this );
+ setMainWidget(page);
+
+ QGridLayout * EditAreaNameLayout
+ = new QGridLayout( page, 1, 1, 11, 6, "EditAreaNameLayout");
+
+ QHBoxLayout * Layout1 = new QHBoxLayout( 0, 0, 6, "Layout1");
+ QSpacerItem * spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding,
+ QSizePolicy::Minimum );
+ Layout1->addItem( spacer );
+
+ EditAreaNameLayout->addMultiCellLayout( Layout1, 3, 3, 0, 1 );
+
+ QLabel * TextLabel4 = new QLabel( page, "TextLabel4" );
+ TextLabel4->setText( i18n( "Cells:" ) );
+
+ EditAreaNameLayout->addWidget( TextLabel4, 2, 0 );
+
+ m_area = new QLineEdit( page, "m_area" );
+
+ EditAreaNameLayout->addWidget( m_area, 2, 1 );
+
+ QLabel * TextLabel1 = new QLabel( page, "TextLabel1" );
+ TextLabel1->setText( i18n( "Sheet:" ) );
+
+ EditAreaNameLayout->addWidget( TextLabel1, 1, 0 );
+
+ m_sheets = new QComboBox( FALSE, page, "m_sheets" );
+
+ EditAreaNameLayout->addWidget( m_sheets, 1, 1 );
+
+ QLabel * TextLabel2 = new QLabel( page, "TextLabel2" );
+ TextLabel2->setText( i18n( "Area name:" ) );
+
+ EditAreaNameLayout->addWidget( TextLabel2, 0, 0 );
+
+ m_areaName = new QLabel( page, "m_areaName" );
+ m_areaName->setText( areaname );
+
+ EditAreaNameLayout->addWidget( m_areaName, 0, 1 );
+
+ QPtrList<Sheet> sheetList = m_pView->doc()->map()->sheetList();
+ for (unsigned int c = 0; c < sheetList.count(); ++c)
+ {
+ Sheet * t = sheetList.at(c);
+ if (!t)
+ continue;
+ m_sheets->insertItem( t->sheetName() );
+ }
+
+ QString tmpName;
+ QValueList<Reference>::Iterator it;
+ QValueList<Reference> area(m_pView->doc()->listArea());
+ for ( it = area.begin(); it != area.end(); ++it )
+ {
+ if ((*it).ref_name == areaname)
+ {
+ if (!m_pView->doc()->map()->findSheet( (*it).sheet_name))
+ kdDebug(36001) << "(*it).table_name '" << (*it).sheet_name
+ << "' not found!*********" << endl;
+ else
+ tmpName = util_rangeName( (*it).rect );
+ break;
+ }
+ }
+
+ m_sheets->setCurrentText( (*it).sheet_name );
+ m_area->setText( tmpName );
+
+}
+
+EditAreaName::~EditAreaName()
+{
+}
+
+void EditAreaName::slotOk()
+{
+ Range range( m_area->text() );
+
+ if ( !range.isValid() )
+ {
+ Point point( m_area->text() );
+ if ( !point.isValid() )
+ return;
+
+ m_area->setText( m_area->text() + ":" + m_area->text() );
+
+ range = Range( m_area->text() );
+ }
+
+ m_pView->doc()->emitBeginOperation( false );
+
+ m_pView->doc()->removeArea( m_areaName->text() );
+ m_pView->doc()->addAreaName(range.range(), m_areaName->text(), m_sheets->currentText() );
+
+ Sheet *sheet;
+
+ for ( sheet = m_pView->doc()->map()->firstSheet(); sheet != 0L;
+ sheet = m_pView->doc()->map()->nextSheet() )
+ {
+ sheet->refreshChangeAreaName( m_areaName->text() );
+ }
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+#include "kspread_dlg_reference.moc"
diff --git a/kspread/dialogs/kspread_dlg_reference.h b/kspread/dialogs/kspread_dlg_reference.h
new file mode 100644
index 00000000..3ba3e761
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_reference.h
@@ -0,0 +1,92 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 Harri Porten <porten@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_reference__
+#define __kspread_dlg_reference__
+
+#include <kdialogbase.h>
+
+class QComboBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QListBox;
+class QListBoxItem;
+
+namespace KSpread
+{
+class View;
+
+class reference: public QDialog
+{
+ Q_OBJECT
+public:
+ reference( View* parent, const char* name );
+
+
+public slots:
+ void slotOk();
+ void slotCancel();
+ void slotDoubleClicked(QListBoxItem *);
+ void slotRemove();
+ void slotEdit();
+ void slotHighlighted(QListBoxItem *);
+protected:
+ View * m_pView;
+
+ QListBox * m_list;
+ QPushButton * m_pOk;
+ QPushButton * m_pCancel;
+ QPushButton * m_pEdit;
+ QPushButton * m_pRemove;
+ QLabel * m_rangeName;
+
+private:
+ void displayAreaValues(QString const & areaName);
+};
+
+class EditAreaName : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ EditAreaName( View * parent, const char * name,
+ QString const & areaname );
+ ~EditAreaName();
+
+public slots:
+ virtual void slotOk();
+
+private:
+ View * m_pView;
+
+ QLineEdit * m_area;
+ QComboBox * m_sheets;
+ QLabel * m_areaName;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_resize2.cc b/kspread/dialogs/kspread_dlg_resize2.cc
new file mode 100644
index 00000000..43e9cd4d
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_resize2.cc
@@ -0,0 +1,183 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2001-2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2000 David Faure <faure@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <float.h>
+
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <knuminput.h>
+
+#include <KoUnit.h>
+#include <KoUnitWidgets.h>
+
+#include <kspread_canvas.h>
+#include <kspread_doc.h>
+#include <kspread_global.h>
+#include <kspread_locale.h>
+#include <kspread_sheet.h>
+#include <kspread_undo.h>
+#include <kspread_view.h>
+#include "manipulator.h"
+#include "selection.h"
+
+#include "kspread_dlg_resize2.h"
+
+using namespace KSpread;
+
+ResizeRow::ResizeRow( View* parent, const char* name )
+ : KDialogBase( parent, name, true, i18n("Resize Row"), Ok|Cancel|Default )
+{
+ m_pView = parent;
+
+ QWidget *page = new QWidget( this );
+ setMainWidget( page );
+
+ QVBoxLayout *vLay = new QVBoxLayout( page, 0, spacingHint() );
+ QHBoxLayout *hLay = new QHBoxLayout( vLay );
+
+ QRect selection( m_pView->selectionInfo()->selection() );
+ RowFormat* rl = m_pView->activeSheet()->rowFormat( selection.top() );
+ rowHeight = rl->dblHeight();
+
+ QLabel * label1 = new QLabel( page, "label1" );
+ label1->setText( i18n( "Height:" ) );
+ hLay->addWidget( label1 );
+
+ m_pHeight = new KoUnitDoubleSpinBox( page );
+ m_pHeight->setValue( rowHeight );
+ m_pHeight->setUnit( m_pView->doc()->unit() );
+
+ hLay->addWidget( m_pHeight );
+
+ QWidget *hSpacer = new QWidget( page );
+ hSpacer->setMinimumSize( spacingHint(), spacingHint() );
+ hLay->addWidget( hSpacer );
+
+ QWidget *vSpacer = new QWidget( page );
+ vSpacer->setMinimumSize( spacingHint(), spacingHint() );
+ vLay->addWidget( vSpacer );
+
+ m_pHeight->setFocus();
+
+ //store the visible value, for later check for changes
+ rowHeight = m_pHeight->value();
+}
+
+void ResizeRow::slotOk()
+{
+ double height = m_pHeight->value();
+
+ //Don't generate a resize, when there isn't a change or the change is only a rounding issue
+ if ( fabs( height - rowHeight ) > DBL_EPSILON )
+ {
+ ResizeRowManipulator* manipulator = new ResizeRowManipulator();
+ manipulator->setSheet(m_pView->activeSheet());
+ manipulator->setSize(height);
+ // TODO Stefan:
+ manipulator->setOldSize(rowHeight);
+ manipulator->add(*m_pView->selectionInfo());
+ manipulator->execute();
+ }
+ accept();
+}
+
+void ResizeRow::slotDefault()
+{
+ Sheet* sheet = m_pView->activeSheet();
+ if (!sheet)
+ return;
+ double points = sheet->rowFormat(0)->dblHeight();
+ m_pHeight->setValue(KoUnit::toUserValue(points, m_pView->doc()->unit()));
+}
+
+ResizeColumn::ResizeColumn( View* parent, const char* name )
+ : KDialogBase( parent, name, true, i18n("Resize Column"), Ok|Cancel|Default )
+{
+ m_pView = parent;
+
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+
+ QVBoxLayout *vLay = new QVBoxLayout( page, 0, spacingHint() );
+ QHBoxLayout *hLay = new QHBoxLayout( vLay );
+
+ QRect selection( m_pView->selectionInfo()->selection() );
+ ColumnFormat* cl = m_pView->activeSheet()->columnFormat( selection.left() );
+ columnWidth = cl->dblWidth();
+
+ QLabel * label1 = new QLabel( page, "label1" );
+ label1->setText( i18n( "Width:" ) );
+ hLay->addWidget( label1 );
+
+ m_pWidth = new KoUnitDoubleSpinBox( page );
+ m_pWidth->setValue( columnWidth );
+ m_pWidth->setUnit( m_pView->doc()->unit() );
+
+ hLay->addWidget( m_pWidth );
+
+ QWidget *hSpacer = new QWidget( page );
+ hSpacer->setMinimumSize( spacingHint(), spacingHint() );
+ hLay->addWidget( hSpacer );
+
+ QWidget *vSpacer = new QWidget( page );
+ vSpacer->setMinimumSize( spacingHint(), spacingHint() );
+ vLay->addWidget( vSpacer );
+
+ m_pWidth->setFocus();
+
+ //store the visible value, for later check for changes
+ columnWidth = m_pWidth->value();
+}
+
+void ResizeColumn::slotOk()
+{
+ double width = m_pWidth->value();
+
+ //Don't generate a resize, when there isn't a change or the change is only a rounding issue
+ if ( fabs( width - columnWidth ) > DBL_EPSILON )
+ {
+ ResizeColumnManipulator* manipulator = new ResizeColumnManipulator();
+ manipulator->setSheet(m_pView->activeSheet());
+ manipulator->setSize(width);
+ // TODO Stefan:
+ manipulator->setOldSize(columnWidth);
+ manipulator->add(*m_pView->selectionInfo());
+ manipulator->execute();
+ }
+ accept();
+}
+
+void ResizeColumn::slotDefault()
+{
+ Sheet* sheet = m_pView->activeSheet();
+ if (!sheet)
+ return;
+ double points = sheet->columnFormat(0)->dblWidth();
+ m_pWidth->setValue(KoUnit::toUserValue(points, m_pView->doc()->unit()));
+}
+
+
+#include "kspread_dlg_resize2.moc"
diff --git a/kspread/dialogs/kspread_dlg_resize2.h b/kspread/dialogs/kspread_dlg_resize2.h
new file mode 100644
index 00000000..395796ac
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_resize2.h
@@ -0,0 +1,74 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2001-2003 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2000 David Faure <faure@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_resize2__
+#define __kspread_dlg_resize2__
+
+#include <kdialogbase.h>
+
+class KDoubleNumInput;
+class KoUnitDoubleSpinBox;
+
+namespace KSpread
+{
+class View;
+
+class ResizeRow: public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ ResizeRow( View* parent, const char* name = 0 );
+ double rowHeight;
+
+protected slots:
+ virtual void slotOk();
+ virtual void slotDefault();
+
+protected:
+ View* m_pView;
+ KoUnitDoubleSpinBox *m_pHeight;
+};
+
+class ResizeColumn: public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ ResizeColumn( View* parent, const char* name = 0 );
+ double columnWidth;
+
+protected slots:
+ virtual void slotOk();
+ virtual void slotDefault();
+
+protected:
+ View* m_pView;
+ KoUnitDoubleSpinBox *m_pWidth;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_series.cc b/kspread/dialogs/kspread_dlg_series.cc
new file mode 100644
index 00000000..666beee6
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_series.cc
@@ -0,0 +1,213 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2000-2001 Werner Trobin <trobin@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+
+#include "kspread_dlg_series.h"
+#include "kspread_doc.h"
+#include "kspread_editors.h"
+#include "kspread_sheet.h"
+#include "kspread_view.h"
+
+#include <qlayout.h>
+#include <klocale.h>
+#include <qlabel.h>
+
+#include <qbuttongroup.h>
+#include <qgroupbox.h>
+#include <kmessagebox.h>
+#include <knumvalidator.h>
+
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+#include <qlineedit.h>
+#include <qwhatsthis.h>
+#include <knuminput.h>
+
+using namespace KSpread;
+
+SeriesDlg::SeriesDlg( View* parent, const char* name,const QPoint &_marker)
+ : KDialogBase( parent, name,TRUE,i18n("Series"),Ok|Cancel )
+{
+ m_pView = parent;
+ marker=_marker;
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+
+ QBoxLayout *grid1 = new QHBoxLayout(page);
+ grid1->setSpacing( spacingHint() );
+
+ QButtonGroup* gb1 = new QButtonGroup( 2, Qt::Vertical,
+ i18n("Insert Values"), page );
+ column = new QRadioButton( i18n("Vertical"), gb1 );
+ QWhatsThis::add(column, i18n("Insert the series vertically, one below the other") );
+ row = new QRadioButton( i18n("Horizontal"), gb1 );
+ QWhatsThis::add(row, i18n("Insert the series horizontally, from left to right") );
+
+ column->setChecked(true);
+
+ QButtonGroup* gb2 = new QButtonGroup( 2, Qt::Vertical,
+ i18n("Type"), page );
+ linear = new QRadioButton( i18n("Linear (2,4,6,...)"), gb2 );
+ QWhatsThis::add(linear, i18n("Generate a series from 'start' to 'end' and for each step add "
+ "the value provided in step. This creates a series where each value "
+ "is 'step' larger than the value before it.") );
+ geometric = new QRadioButton( i18n("Geometric (2,4,8,...)"), gb2 );
+ QWhatsThis::add(geometric, i18n("Generate a series from 'start' to 'end' and for each step multiply "
+ "the value with the value provided in step. Using a step of 5 produces a list like: "
+ "5, 25, 125, 625 since 5 multiplied by 5 (step) equals 25, and that multiplied by 5 equals 125, "
+ "which multiplied by the same step-value of 5 equals 625.") );
+
+ linear->setChecked(true);
+
+ QGroupBox* gb = new QGroupBox( 1, Qt::Vertical, i18n("Parameters"), page );
+ QWidget *params = new QWidget( gb );
+ QGridLayout *params_layout = new QGridLayout( params, 3, 2 );
+ params_layout->setSpacing( spacingHint() );
+ params_layout->setAutoAdd( true );
+
+ new QLabel( i18n( "Start value:" ), params );
+ start=new KDoubleNumInput(-999999.999, 999999.99, 0.0, 1.0, 3, params);
+
+ new QLabel( i18n( "Stop value:" ), params );
+ end=new KDoubleNumInput(-999999.999, 999999.99, 0.0, 1.0, 3, params);
+
+ new QLabel( i18n( "Step value:" ), params );
+ step=new KDoubleNumInput(-999999.999, 999999.99, 0.0, 1.0, 3, params);
+
+ grid1->addWidget(gb);
+
+ grid1->addWidget(gb1);
+ grid1->addWidget(gb2);
+
+ start->setFocus();
+
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+}
+
+
+void SeriesDlg::slotOk()
+{
+
+ Series mode=Column; //same as Vertical
+ Series type=Linear; // same as Horizontal
+ QString tmp;
+ double dstep, dend, dstart;
+ Sheet * m_pSheet;
+ m_pSheet = m_pView->activeSheet();
+
+ if(column->isChecked())
+ mode = Column;
+ else if(row->isChecked())
+ mode = Row;
+
+ if (linear->isChecked())
+ type = Linear;
+ else if (geometric->isChecked())
+ type = Geometric;
+
+ dstart = start->value();
+ dend= end->value();
+ dstep = step->value();
+ if ( type == Geometric )
+ {
+ if ( dstart < 0 || dend < 0 )
+ {
+ KMessageBox::error( this, i18n("End and start value must be positive.") );
+ return;
+ }
+ if ( dstart > dend && dstep >= 1)
+ {
+ KMessageBox::error( this, i18n("End value must be greater than the start value or the step must be less than '1'.") );
+ return;
+ }
+ if ( dstart == 0 || dend == 0 || dstep == 0)
+ {
+ KMessageBox::error( this, i18n("None of the Start, Stop or Step values may be equal to zero.") );
+ return;
+ }
+ if ( dstep == 1)
+ {
+ KMessageBox::error( this, i18n("Step value must be different from 1") );
+ return;
+ }
+ }
+
+ if (dstep >= 0)
+ {
+ if (linear->isChecked() && dstep == 0)
+ {
+ KMessageBox::error( this, i18n("The step value must be greater than zero; "
+ "otherwise, the linear series is infinite.") );
+ step->setFocus();
+ return;
+ }
+ /* else if (geometric->isChecked() && dstep <= 1)
+ {
+ KMessageBox::error( this, i18n("The step value must be greater than one; "
+ "otherwise, the geometric series is infinite.") );
+ step->setFocus();
+ return;
+ }
+ */
+ else if ( type == Linear && dend < dstart )
+ {
+ KMessageBox::error( this,
+ i18n("If the start value is greater than the end value the step must be less than zero.") );
+ return;
+ }
+ }
+ else if (type != Linear)
+ {
+ KMessageBox::error( this, i18n("Step is negative.") );
+ return;
+ }
+ else
+ {
+ if (dstart <= dend)
+ {
+ KMessageBox::error( this,
+ i18n("If the step is negative, the start value must be greater then the end value.") );
+ return;
+ }
+ }
+
+ // double val_end = QMAX(dend, dstart);
+ // double val_start = QMIN(dend, dstart);
+ m_pView->doc()->emitBeginOperation( false );
+
+ m_pSheet->setSeries( marker, dstart, dend, dstep, mode, type );
+
+ Cell * cell = m_pSheet->cellAt( marker.x(), marker.y() );
+ if ( cell->text() != 0L )
+ m_pView->editWidget()->setText( cell->text() );
+ else
+ m_pView->editWidget()->setText( "" );
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+
+#include "kspread_dlg_series.moc"
diff --git a/kspread/dialogs/kspread_dlg_series.h b/kspread/dialogs/kspread_dlg_series.h
new file mode 100644
index 00000000..9d056ead
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_series.h
@@ -0,0 +1,66 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2000-2001 Werner Trobin <trobin@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_series__
+#define __kspread_dlg_series__
+
+#include <kdialogbase.h>
+
+class QRadioButton;
+class QCheckBox;
+class KDoubleNumInput;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class SeriesDlg : public KDialogBase
+{
+ Q_OBJECT
+public:
+
+ SeriesDlg(View* parent, const char* name,const QPoint &_marker);
+
+ Sheet* sheet;
+
+public slots:
+ void slotOk();
+protected:
+ View* m_pView;
+ KDoubleNumInput *start;
+ KDoubleNumInput *end;
+ KDoubleNumInput *step;
+
+ QRadioButton* column;
+ QRadioButton* row;
+ QRadioButton* linear;
+ QRadioButton* geometric;
+ QPoint marker;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_show.cc b/kspread/dialogs/kspread_dlg_show.cc
new file mode 100644
index 00000000..fd4ba801
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_show.cc
@@ -0,0 +1,112 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999-2004 Laurent Montel <montel@kde.org>
+ (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qlayout.h>
+#include <klocale.h>
+#include <qlistbox.h>
+#include <qlabel.h>
+
+#include <kcommand.h>
+
+#include "kspread_view.h"
+#include "kspread_doc.h"
+#include "kspread_map.h"
+#include "commands.h"
+
+#include "kspread_dlg_show.h"
+
+using namespace KSpread;
+
+ShowDialog::ShowDialog( View* parent, const char* name )
+ : KDialogBase( parent, name,TRUE,i18n("Show Sheet"),Ok|Cancel )
+{
+ m_pView = parent;
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+ QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
+
+ QLabel *label = new QLabel( i18n("Select hidden sheets to show:"), page );
+ lay1->addWidget( label );
+
+ list=new QListBox(page);
+ lay1->addWidget( list );
+
+ list->setSelectionMode(QListBox::Multi);
+ QString text;
+ QStringList::Iterator it;
+ QStringList tabsList=m_pView->doc()->map()->hiddenSheets();
+ for ( it = tabsList.begin(); it != tabsList.end(); ++it )
+ {
+ text=*it;
+ list->insertItem(text);
+ }
+ if(!list->count())
+ enableButtonOK(false);
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+ connect( list, SIGNAL(doubleClicked(QListBoxItem *)),this,SLOT(slotDoubleClicked(QListBoxItem *)));
+ resize( 200, 150 );
+ setFocus();
+}
+
+void ShowDialog::slotDoubleClicked(QListBoxItem *)
+{
+ slotOk();
+}
+
+
+
+void ShowDialog::slotOk()
+{
+ m_pView->doc()->emitBeginOperation( false );
+
+ QStringList listSheet;
+
+ for (int i=0; i < list->numRows(); i++)
+ {
+ if (list->isSelected(i))
+ {
+ listSheet.append( list->text(i));
+ }
+ }
+
+ //m_pView->tabBar()->showSheet(listSheet);
+
+ if ( listSheet.count()==0 )
+ return;
+
+ Sheet *sheet;
+ KMacroCommand *macroUndo=new KMacroCommand( i18n("Show Sheet") );
+ for ( QStringList::Iterator it = listSheet.begin(); it != listSheet.end(); ++it )
+ {
+ sheet=m_pView->doc()->map()->findSheet( *it );
+ KCommand* command = new ShowSheetCommand( sheet );
+ macroUndo->addCommand( command );
+ }
+ m_pView->doc()->addCommand( macroUndo );
+ macroUndo->execute();
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+#include "kspread_dlg_show.moc"
diff --git a/kspread/dialogs/kspread_dlg_show.h b/kspread/dialogs/kspread_dlg_show.h
new file mode 100644
index 00000000..f3772aea
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_show.h
@@ -0,0 +1,54 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999-2004 Laurent Montel <montel@kde.org>
+ (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_show__
+#define __kspread_dlg_show__
+
+#include <kdialogbase.h>
+
+class QListBox;
+
+namespace KSpread
+{
+class View;
+
+class ShowDialog: public KDialogBase
+{
+ Q_OBJECT
+public:
+ ShowDialog( View* parent, const char* name );
+
+
+public slots:
+ void slotOk();
+ void slotDoubleClicked(QListBoxItem *);
+protected:
+ View* m_pView;
+
+ QListBox * list;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_showColRow.cc b/kspread/dialogs/kspread_dlg_showColRow.cc
new file mode 100644
index 00000000..908d8bbc
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_showColRow.cc
@@ -0,0 +1,152 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2000-2002 Laurent Montel <montel@kde.org>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <klocale.h>
+
+#include "kspread_doc.h"
+#include "kspread_sheet.h"
+#include "kspread_util.h"
+#include "kspread_view.h"
+#include "region.h"
+
+#include "kspread_dlg_showColRow.h"
+
+using namespace KSpread;
+
+ShowColRow::ShowColRow( View* parent, const char* name, Type _type )
+ : KDialogBase( parent, name,TRUE,"",Ok|Cancel )
+{
+ m_pView = parent;
+ typeShow=_type;
+
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+ QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
+
+ QLabel *label = new QLabel( page );
+
+ if(_type==Column) {
+ setCaption( i18n("Show Columns") );
+ label->setText(i18n("Select hidden columns to show:"));
+ }
+ else if(_type==Row) {
+ setCaption( i18n("Show Rows") );
+ label->setText(i18n("Select hidden rows to show:"));
+ }
+
+ list=new QListBox(page);
+
+ lay1->addWidget( label );
+ lay1->addWidget( list );
+
+ bool showColNumber=m_pView->activeSheet()->getShowColumnNumber();
+ if(_type==Column)
+ {
+ ColumnFormat *col=m_pView->activeSheet()->firstCol();
+
+ QString text;
+ QStringList listCol;
+ for( ; col; col = col->next() )
+ {
+ if(col->isHide())
+ listInt.append(col->column());
+ }
+ qHeapSort(listInt);
+ QValueList<int>::Iterator it;
+ for( it = listInt.begin(); it != listInt.end(); ++it )
+ {
+ if(!showColNumber)
+ listCol+=i18n("Column: %1").arg(Cell::columnName(*it));
+ else
+ listCol+=i18n("Column: %1").arg(text.setNum(*it));
+ }
+ list->insertStringList(listCol);
+ }
+ else if(_type==Row)
+ {
+ RowFormat *row=m_pView->activeSheet()->firstRow();
+
+ QString text;
+ QStringList listRow;
+ for( ; row; row = row->next() )
+ {
+ if(row->isHide())
+ listInt.append(row->row());
+ }
+ qHeapSort(listInt);
+ QValueList<int>::Iterator it;
+ for( it = listInt.begin(); it != listInt.end(); ++it )
+ listRow+=i18n("Row: %1").arg(text.setNum(*it));
+
+ list->insertStringList(listRow);
+ }
+
+ if(!list->count())
+ enableButtonOK(false);
+
+ //selection multiple
+ list->setSelectionMode(QListBox::Multi);
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+ connect( list, SIGNAL(doubleClicked(QListBoxItem *)),this,SLOT(slotDoubleClicked(QListBoxItem *)));
+ resize( 200, 150 );
+ setFocus();
+}
+
+void ShowColRow::slotDoubleClicked(QListBoxItem *)
+{
+ slotOk();
+}
+
+void ShowColRow::slotOk()
+{
+ Region region;
+ for(unsigned int i=0; i < list->count(); i++)
+ {
+ if (list->isSelected(i))
+ {
+ if (typeShow == Column)
+ {
+ region.add(QRect(*listInt.at(i), 1, 1, KS_rowMax));
+ }
+ if (typeShow == Row)
+ {
+ region.add(QRect(1, *listInt.at(i), KS_colMax, 1));
+ }
+ }
+ }
+
+ if (typeShow == Column)
+ {
+ m_pView->activeSheet()->showColumn(region);
+ }
+ if (typeShow == Row)
+ {
+ m_pView->activeSheet()->showRow(region);
+ }
+
+ accept();
+}
+
+#include "kspread_dlg_showColRow.moc"
diff --git a/kspread/dialogs/kspread_dlg_showColRow.h b/kspread/dialogs/kspread_dlg_showColRow.h
new file mode 100644
index 00000000..572f98b2
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_showColRow.h
@@ -0,0 +1,56 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2000-2002 Laurent Montel <montel@kde.org>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_showColRow__
+#define __kspread_dlg_showColRow__
+
+#include <qvaluelist.h>
+
+#include <kdialogbase.h>
+
+class QListBox;
+
+namespace KSpread
+{
+class View;
+
+class ShowColRow: public KDialogBase
+{
+ Q_OBJECT
+public:
+ enum Type { Column, Row };
+ ShowColRow( View* parent, const char* name, Type _type );
+
+public slots:
+ void slotOk();
+ void slotDoubleClicked(QListBoxItem *);
+
+protected:
+ View* m_pView;
+ QListBox * list;
+ Type typeShow;
+ QValueList<int> listInt;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_sort.cc b/kspread/dialogs/kspread_dlg_sort.cc
new file mode 100644
index 00000000..6539d149
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_sort.cc
@@ -0,0 +1,748 @@
+/* This file is part of the KDE project
+ Copyright (C) 2006 Robert Knight <robertknight@gmail.com>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2002 Werner Trobin <trobin@kde.org>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 2000 David Faure <faure@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+
+#include <qbuttongroup.h>
+#include <qhbuttongroup.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qrect.h>
+#include <qtabwidget.h>
+#include <qwidget.h>
+#include <qvbox.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "kspread_dlg_sort.h"
+#include "kspread_doc.h"
+#include "kspread_map.h"
+#include "kspread_sheet.h"
+#include "kspread_view.h"
+#include "kspread_util.h"
+#include "selection.h"
+
+using namespace KSpread;
+
+SortDialog::SortDialog( View * parent, const char * name,
+ bool modal )
+ : KDialogBase( parent, name, modal,"Sort",Ok|Cancel ),
+ m_pView( parent )
+{
+ if ( !name )
+ setName( "SortDialog" );
+
+ resize( 528, 316 );
+ setCaption( i18n( "Sorting" ) );
+ //setSizeGripEnabled( true );
+
+ QVBox *page = makeVBoxMainWidget();
+
+ m_tabWidget = new QTabWidget( page, "m_tabWidget" );
+
+ m_page1 = new QWidget( m_tabWidget, "m_page1" );
+ QGridLayout * page1Layout
+ = new QGridLayout( m_page1, 1, 1, 11, 6, "page1Layout");
+
+//---------------- Sort Layout & Header Row/Column Toggle
+
+ //Sort orientation selector (for selecting Left-To-Right or Top-To-Bottom sorting of the selection)
+ QGroupBox* layoutGroup = new QGroupBox(2 , Qt::Vertical, m_page1, "layoutGroup");
+ layoutGroup->setTitle( i18n("Layout") );
+
+ QHButtonGroup * orientationGroup = new QHButtonGroup( layoutGroup, "orientationGroup" );
+ orientationGroup->setLineWidth(0);
+ orientationGroup->setMargin(0);
+ orientationGroup->layout()->setMargin(0);
+
+ m_sortColumn = new QRadioButton( orientationGroup, "m_sortColumn" );
+ m_sortColumn->setText( i18n( "Sort &Rows" ) );
+
+ m_sortRow = new QRadioButton( orientationGroup, "m_sortRow" );
+ m_sortRow->setText( i18n( "Sort &Columns" ) );
+
+ //First row / column contains header toggle
+ m_firstRowOrColHeader = new QCheckBox( layoutGroup, "m_copyLayout" );
+ //m_firstRowOrColHeader->setText( i18n( "&First row contains headers" ) );
+ m_firstRowOrColHeader->setChecked(true);
+ page1Layout->addWidget(layoutGroup,0,0);
+
+//----------------
+
+ page1Layout->addRowSpacing(2,10);
+
+
+ QGroupBox * sort1Box = new QGroupBox( m_page1, "sort1Box" );
+ sort1Box->setTitle( i18n( "Sort By" ) );
+ sort1Box->setFlat(true);
+ sort1Box->setColumnLayout(0, Qt::Vertical );
+ sort1Box->layout()->setSpacing( KDialog::spacingHint() );
+ sort1Box->layout()->setMargin( KDialog::marginHint() );
+ QHBoxLayout * sort1BoxLayout = new QHBoxLayout( sort1Box->layout() );
+ sort1BoxLayout->setAlignment( Qt::AlignTop );
+
+ m_sortKey1 = new QComboBox( false, sort1Box, "m_sortKey1" );
+ sort1BoxLayout->addWidget( m_sortKey1 );
+
+ m_sortOrder1 = new QComboBox( false, sort1Box, "m_sortOrder1" );
+ m_sortOrder1->insertItem( i18n( "Ascending" ) );
+ m_sortOrder1->insertItem( i18n( "Descending" ) );
+ sort1BoxLayout->addWidget( m_sortOrder1 );
+
+ page1Layout->addWidget( sort1Box, 3, 0 );
+
+ QGroupBox * sort2Box = new QGroupBox( m_page1, "sort2Box" );
+ sort2Box->setTitle( i18n( "Then By" ) );
+ sort2Box->setFlat(true);
+ sort2Box->setColumnLayout(0, Qt::Vertical );
+ sort2Box->layout()->setSpacing( KDialog::spacingHint() );
+ sort2Box->layout()->setMargin( KDialog::marginHint() );
+ QHBoxLayout * sort2BoxLayout = new QHBoxLayout( sort2Box->layout() );
+ sort2BoxLayout->setAlignment( Qt::AlignTop );
+
+ m_sortKey2 = new QComboBox( false, sort2Box, "m_sortKey2" );
+ m_sortKey2->insertItem( i18n( "None" ) );
+ sort2BoxLayout->addWidget( m_sortKey2 );
+
+ m_sortOrder2 = new QComboBox( false, sort2Box, "m_sortOrder2" );
+ m_sortOrder2->insertItem( i18n( "Ascending" ) );
+ m_sortOrder2->insertItem( i18n( "Descending" ) );
+ sort2BoxLayout->addWidget( m_sortOrder2 );
+
+ page1Layout->addWidget( sort2Box, 4, 0 );
+
+ QGroupBox * sort3Box = new QGroupBox( m_page1, "sort3Box" );
+ sort3Box->setTitle( i18n( "Then By" ) );
+ sort3Box->setFlat(true);
+ sort3Box->setColumnLayout(0, Qt::Vertical );
+ sort3Box->layout()->setSpacing( KDialog::spacingHint() );
+ sort3Box->layout()->setMargin( KDialog::marginHint() );
+ QHBoxLayout * sort3BoxLayout = new QHBoxLayout( sort3Box->layout() );
+ sort3BoxLayout->setAlignment( Qt::AlignTop );
+
+ m_sortKey3 = new QComboBox( false, sort3Box, "m_sortKey3" );
+ m_sortKey3->insertItem( i18n( "None" ) );
+ m_sortKey3->setEnabled( false );
+ sort3BoxLayout->addWidget( m_sortKey3 );
+
+ m_sortOrder3 = new QComboBox( false, sort3Box, "m_sortOrder3" );
+ m_sortOrder3->insertItem( i18n( "Ascending" ) );
+ m_sortOrder3->insertItem( i18n( "Descending" ) );
+ m_sortOrder3->setEnabled( false );
+ sort3BoxLayout->addWidget( m_sortOrder3 );
+
+ page1Layout->addWidget( sort3Box, 5, 0 );
+ m_tabWidget->insertTab( m_page1, i18n( "Sort Criteria" ) );
+
+
+ //---------------- options page
+
+ m_page2 = new QWidget( m_tabWidget, "m_page2" );
+ QGridLayout * page2Layout = new QGridLayout( m_page2, 1, 1, 11, 6, "page2Layout");
+ page2Layout->setAlignment(Qt::AlignTop);
+
+ QGroupBox * firstKeyBox = new QGroupBox( m_page2, "firstKeyBox" );
+ firstKeyBox->setTitle( i18n( "First Key" ) );
+ firstKeyBox->setColumnLayout(0, Qt::Vertical );
+ firstKeyBox->layout()->setSpacing( KDialog::spacingHint() );
+ firstKeyBox->layout()->setMargin( KDialog::marginHint() );
+ QVBoxLayout * firstKeyBoxLayout = new QVBoxLayout( firstKeyBox->layout() );
+ firstKeyBoxLayout->setAlignment( Qt::AlignTop );
+
+ m_useCustomLists = new QCheckBox( firstKeyBox, "m_useCustomLists_2" );
+ m_useCustomLists->setText( i18n( "&Use custom list" ) );
+ firstKeyBoxLayout->addWidget( m_useCustomLists );
+
+ m_customList = new QComboBox( false, firstKeyBox, "m_customList" );
+ m_customList->setEnabled( false );
+ m_customList->setMaximumSize( 230, 30 );
+ firstKeyBoxLayout->addWidget( m_customList );
+
+ page2Layout->addWidget( firstKeyBox, 0, 0 );
+
+
+ /*
+ This doesn't work properly, and as a bug report pointed out, it isn't that useful since it is easy
+ to just copy and paste the data and then sort the newly pasted data in place.
+ -- Robert Knight
+
+ QGroupBox * resultToBox = new QGroupBox( m_page2, "resultToBox" );
+ resultToBox->setTitle( i18n( "Location to Store Sort Results" ) );
+ resultToBox->setColumnLayout(0, Qt::Vertical );
+ resultToBox->layout()->setSpacing( KDialog::spacingHint() );
+ resultToBox->layout()->setMargin( KDialog::marginHint() );
+
+
+ QHBoxLayout * resultToBoxLayout = new QHBoxLayout( resultToBox->layout() );
+ resultToBoxLayout->setAlignment( Qt::AlignTop );
+
+ QLabel * destinationSheet=new QLabel(resultToBox,"destinationSheet");
+ destinationSheet->setText("Destination Sheet:");
+ resultToBoxLayout->addWidget(destinationSheet);
+
+ m_outputSheet = new QComboBox( false, resultToBox, "m_outputSheet" );
+ resultToBoxLayout->addWidget( m_outputSheet );
+ QSpacerItem * spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ resultToBoxLayout->addItem( spacer );
+
+ QLabel * startingCellLabel = new QLabel( resultToBox, "destinationCellLabel" );
+ startingCellLabel->setText( i18n( "Destination Cell:" ) );
+ resultToBoxLayout->addWidget( startingCellLabel );
+
+ m_outputCell = new QLineEdit( resultToBox, "m_outputCell" );
+ m_outputCell->setMaximumSize( QSize( 60, 32767 ) );
+ resultToBoxLayout->addWidget( m_outputCell );
+
+ page2Layout->addWidget( resultToBox, 1,0 );*/
+
+
+ m_tabWidget->insertTab( m_page2, i18n( "Options" ) );
+
+ QHBoxLayout * Layout1 = new QHBoxLayout( 0, 0, 6, "Layout1");
+ QSpacerItem * spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding,
+ QSizePolicy::Minimum );
+ Layout1->addItem( spacer_2 );
+
+
+ m_copyLayout = new QCheckBox( m_page2, "m_copyLayout" );
+ m_copyLayout->setText( i18n( "Copy cell &formatting (Borders, Colours, Text Style)" ) );
+
+ page2Layout->addWidget( m_copyLayout, 1, 0 );
+
+ m_respectCase = new QCheckBox( m_page2, "m_copyLayout" );
+ m_respectCase->setText( i18n( "Case sensitive sort" ) );
+ m_respectCase->setChecked( true );
+
+ page2Layout->addWidget( m_respectCase, 2,0 );
+
+ connect( m_sortKey2, SIGNAL( activated( int ) ), this,
+ SLOT( sortKey2textChanged( int ) ) );
+ connect( m_useCustomLists, SIGNAL( stateChanged(int) ), this,
+ SLOT( useCustomListsStateChanged(int) ) );
+ connect( m_firstRowOrColHeader, SIGNAL( stateChanged(int) ), this,
+ SLOT( firstRowHeaderChanged(int) ) );
+ connect( orientationGroup, SIGNAL( pressed(int) ), this,
+ SLOT( slotOrientationChanged(int) ) );
+
+ init();
+}
+
+QRect SortDialog::sourceArea()
+{
+ return m_pView->selectionInfo()->selection();
+}
+
+SortDialog::Orientation SortDialog::guessDataOrientation()
+{
+ const QRect selection=sourceArea();
+
+ if (selection.width() >= selection.height())
+ return SortColumns;
+ else
+ return SortRows;
+}
+
+SortDialog::~SortDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void SortDialog::init()
+{
+ QStringList lst;
+ lst<<i18n("January");
+ lst<<i18n("February");
+ lst<<i18n("March");
+ lst<<i18n("April");
+ lst<<i18n("May");
+ lst<<i18n("June");
+ lst<<i18n("July");
+ lst<<i18n("August");
+ lst<<i18n("September");
+ lst<<i18n("October");
+ lst<<i18n("November");
+ lst<<i18n("December");
+
+ lst<<i18n("Monday");
+ lst<<i18n("Tuesday");
+ lst<<i18n("Wednesday");
+ lst<<i18n("Thursday");
+ lst<<i18n("Friday");
+ lst<<i18n("Saturday");
+ lst<<i18n("Sunday");
+
+ KConfig * config = Factory::global()->config();
+ config->setGroup( "Parameters" );
+ QStringList other = config->readListEntry("Other list");
+ QString tmp;
+ for ( QStringList::Iterator it = other.begin(); it != other.end(); ++it )
+ {
+ if((*it) != "\\")
+ tmp += (*it) + ", ";
+ else if( it != other.begin())
+ {
+ tmp = tmp.left(tmp.length() - 2);
+ lst.append(tmp);
+ tmp = "";
+ }
+ }
+ m_customList->insertStringList(lst);
+
+ /*QPtrList<Sheet> sheetList = m_pView->doc()->map()->sheetList();
+ for (unsigned int c = 0; c < sheetList.count(); ++c)
+ {
+ Sheet * t = sheetList.at(c);
+ if (!t)
+ continue;
+ m_outputSheet->insertItem( t->sheetName() );
+ }
+ m_outputSheet->setCurrentText( m_pView->activeSheet()->sheetName() );*/
+
+ QRect r = sourceArea();
+ /*QString cellArea;
+ cellArea += Cell::columnName(r.left());
+ cellArea += QString::number( r.top() );
+ m_outputCell->setText( cellArea );*/
+
+ //If the top-most row or left-most column all contain text items (as opposed to numbers, dates etc.)
+ //then the dialog will guess that the top row (or left column) is a header.
+ //The user can always change this if we get this wrong.
+ bool selectionMayHaveHeader = true;
+
+ // Entire columns selected ?
+ if ( util_isColumnSelected(r) )
+ {
+ m_sortRow->setEnabled(false);
+ m_sortColumn->setChecked(true);
+
+ int right = r.right();
+ for (int i = r.left(); i <= right; ++i)
+ {
+ QString guessName=m_pView->activeSheet()->guessColumnTitle(r,i);
+ QString colName=i18n(" (Column %1)").arg(Cell::columnName(i));
+
+ if (!guessName.isEmpty())
+ {
+ m_listColumn += guessName + colName;
+ }
+ else
+ {
+ m_listColumn += i18n("Column %1").arg(Cell::columnName(i));
+
+ if ( i == r.left() )
+ selectionMayHaveHeader=false;
+ }
+ }
+ // m_listColumn += i18n("Column %1").arg(Cell::columnName(i));
+ }
+ // Entire rows selected ?
+ else if ( util_isRowSelected(r) )
+ {
+ m_sortColumn->setEnabled(false);
+ m_sortRow->setChecked(true);
+
+ int bottom = r.bottom();
+ for (int i = r.top(); i <= bottom; ++i)
+ {
+ QString guessName=m_pView->activeSheet()->guessRowTitle(r,i);
+ QString rowName=i18n(" (Row %1)").arg(i);
+
+ if (!guessName.isEmpty())
+ {
+ m_listRow += guessName + rowName;
+ }
+ else
+ {
+ m_listRow += i18n("Row %1").arg(i);
+
+ if ( i == r.top() )
+ selectionMayHaveHeader=false;
+ }
+ }
+ }
+ else
+ {
+ // Selection is only one row
+ if ( r.top() == r.bottom() )
+ {
+ m_sortColumn->setEnabled(false);
+ m_sortRow->setChecked(true);
+ }
+ // only one column
+ else if (r.left() == r.right())
+ {
+ m_sortRow->setEnabled(false);
+ m_sortColumn->setChecked(true);
+ }
+ else
+ {
+ if (guessDataOrientation() == SortColumns)
+ m_sortRow->setChecked(true);
+ else
+ m_sortColumn->setChecked(true);
+ }
+
+ int right = r.right();
+ int bottom = r.bottom();
+ for (int i = r.left(); i <= right; ++i)
+ {
+ QString guessName=m_pView->activeSheet()->guessColumnTitle(r,i);
+ QString colName=i18n(" (Column %1)").arg(Cell::columnName(i));
+
+ if (!guessName.isEmpty())
+ m_listColumn += guessName + colName;
+ else
+ {
+ m_listColumn += i18n("Column %1").arg(Cell::columnName(i));
+
+ if (i == r.left())
+ selectionMayHaveHeader=false;
+ }
+ }
+
+ for (int i = r.top(); i <= bottom; ++i)
+ {
+ QString guessName=m_pView->activeSheet()->guessRowTitle(r,i);
+ QString rowName=i18n(" (Row %1)").arg(i);
+
+ if (!guessName.isEmpty())
+ m_listRow += guessName + rowName;
+ else
+ {
+ m_listRow += i18n("Row %1").arg(i);
+
+ if (i == r.top())
+ selectionMayHaveHeader=false;
+ }
+ }
+ }
+
+ if ( selectionMayHaveHeader )
+ m_firstRowOrColHeader->setChecked( true );
+ else
+ m_firstRowOrColHeader->setChecked( false );
+
+ // Initialize the combo box
+ if ( m_sortRow->isChecked() )
+ {
+ slotOrientationChanged( SortRows );
+ }
+ else
+ {
+ slotOrientationChanged( SortColumns );
+ }
+}
+
+void SortDialog::slotOrientationChanged(int id)
+{
+ switch( id )
+ {
+ case SortColumns :
+ m_sortKey1->clear();
+ m_sortKey2->clear();
+ m_sortKey3->clear();
+ m_sortKey1->insertStringList(m_listColumn);
+ m_sortKey2->insertItem( i18n("None") );
+ m_sortKey2->insertStringList(m_listColumn);
+ m_sortKey3->insertItem( i18n("None") );
+ m_sortKey3->insertStringList(m_listColumn);
+ m_firstRowOrColHeader->setText( i18n( "&First row contains headers" ) );
+ break;
+
+ case SortRows :
+ m_sortKey1->clear();
+ m_sortKey2->clear();
+ m_sortKey3->clear();
+ m_sortKey1->insertStringList(m_listRow);
+ m_sortKey2->insertItem( i18n("None") );
+ m_sortKey2->insertStringList(m_listRow);
+ m_sortKey3->insertItem( i18n("None") );
+ m_sortKey3->insertStringList(m_listRow);
+ m_firstRowOrColHeader->setText( i18n( "&First column contains headers" ) );
+
+ /*if (m_firstRowOrColHeader->isChecked())
+ {
+ int k1 = m_sortKey1->currentItem();
+ int k2 = m_sortKey2->currentItem();
+ int k3 = m_sortKey3->currentItem();
+ m_sortKey1->removeItem( 0 );
+ m_sortKey2->removeItem( 1 ); // because there is "None" in there
+ m_sortKey3->removeItem( 1 );
+ if (k1 > 0)
+ m_sortKey1->setCurrentItem(--k1);
+ else
+ m_sortKey1->setCurrentItem( 0 );
+ if (k2 > 0)
+ m_sortKey2->setCurrentItem(--k2);
+ if (k3 > 0)
+ m_sortKey3->setCurrentItem(--k3);
+ }*/
+
+ break;
+
+ default :
+ kdDebug(36001) << "Error in signal : pressed(int id)" << endl;
+ break;
+ }
+}
+
+void SortDialog::slotOk()
+{
+ m_pView->doc()->emitBeginOperation( false );
+
+ Orientation sortOrientation;
+ if (m_sortRow->isChecked())
+ sortOrientation=SortColumns;
+ else
+ sortOrientation=SortRows;
+
+ Sheet * sheet = m_pView->activeSheet();
+ /*m_pView->doc()->map()->findSheet( m_outputSheet->currentText() );
+ if ( !sheet )
+ {
+ KMessageBox::error( this, i18n("The destination sheet does not exist.") );
+ m_outputSheet->setFocus();
+ m_tabWidget->setTabEnabled(m_page2, true);
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ return;
+ } */
+
+ /*if ( !outputPoint.isValid() || outputPoint.isSheetKnown() )
+ {
+ KMessageBox::error( this, i18n("The destination cell does not exist.") );
+ m_outputCell->setFocus();
+ m_tabWidget->setTabEnabled(m_page2, true);
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ return;
+ }*/
+ //outputPoint.setSheet(sheet);
+
+ QRect sortArea = sourceArea();
+ Point outputPoint;
+ outputPoint.setPos(sortArea.topLeft());
+ outputPoint.setSheet(sheet);
+ bool hasHeader=m_firstRowOrColHeader->isChecked();
+
+ if ( hasHeader )
+ {
+ if (sortOrientation == SortColumns)
+ {
+ sortArea.setLeft( sortArea.left()+1 );
+ outputPoint.setColumn( outputPoint.column()+1 );
+ }
+ else
+ {
+ sortArea.setTop( sortArea.top()+1 );
+ outputPoint.setRow( outputPoint.row()+1 );
+ }
+ }
+
+ /*if ( sortArea.topLeft() != outputPoint.pos() )
+ {
+ int h = outputPoint.pos().y() + sortArea.height();
+ int w = outputPoint.pos().x() + sortArea.width();
+
+ if ( sortArea.contains(outputPoint.pos())
+ || ( w >= sortArea.left() && w <= sortArea.right() )
+ || ( h >= sortArea.top() && h <= sortArea.bottom() ) )
+ {
+ KMessageBox::error( this, i18n("If the destination and source regions are different, they must not overlap.") );
+ m_outputCell->setFocus();
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ // TODO: set right tab
+ return;
+ }
+ }*/
+
+ int key1 = 1;
+ int key2 = 0;
+ int key3 = 0;
+ QStringList * firstKey = 0L;
+ Sheet::SortingOrder order1;
+ Sheet::SortingOrder order2;
+ Sheet::SortingOrder order3;
+
+ order1 = ( m_sortOrder1->currentItem() == 0 ? Sheet::Increase
+ : Sheet::Decrease );
+ order2 = ( m_sortOrder2->currentItem() == 0 ? Sheet::Increase
+ : Sheet::Decrease );
+ order3 = ( m_sortOrder3->currentItem() == 0 ? Sheet::Increase
+ : Sheet::Decrease );
+
+ if ( m_sortRow->isChecked() )
+ {
+ key1 = m_sortKey1->currentItem() + sortArea.top();
+ if (m_sortKey2->currentItem() > 0)
+ key2 = m_sortKey2->currentItem() + sortArea.top() - 1; // cause there is "None"
+ if (m_sortKey3->currentItem() > 0)
+ key3 = m_sortKey3->currentItem() + sortArea.top() - 1; // cause there is "None"
+ }
+ else
+ {
+ key1 = m_sortKey1->currentItem() + sortArea.left();
+ if (m_sortKey2->currentItem() > 0)
+ key2 = m_sortKey2->currentItem() + sortArea.left() - 1; // cause there is "None"
+ if (m_sortKey3->currentItem() > 0)
+ key3 = m_sortKey3->currentItem() + sortArea.left() - 1; // cause there is "None"
+
+ }
+ /*
+ if (m_firstRowOrColHeader->isChecked())
+ {
+ if (key1 >= 0)
+ ++key1;
+ if (key2 > 0)
+ ++key2;
+ if (key3 > 0)
+ ++key3;
+ }*/
+
+ if ( m_useCustomLists->isChecked() )
+ {
+ firstKey = new QStringList();
+ QString list = m_customList->currentText();
+ QString tmp;
+ int l = list.length();
+ for ( int i = 0; i < l; ++i )
+ {
+ if ( list[i] == ',' )
+ {
+ firstKey->append( tmp.stripWhiteSpace() );
+ tmp = "";
+ }
+ else
+ tmp += list[i];
+ }
+ }
+
+
+
+ if (key1 == key2)
+ key2 = 0;
+
+ if (key1 == key3)
+ key3 = 0;
+
+ if (key2 == 0 && key3 > 0)
+ {
+ key2 = key3;
+ key3 = 0;
+ }
+
+
+
+ if ( m_sortRow->isChecked() )
+ {
+ m_pView->activeSheet()->sortByRow( sortArea/*sourceArea*/, key1, key2, key3,
+ order1, order2, order3,
+ firstKey, m_copyLayout->isChecked(),
+ false /*m_firstRowOrColHeader->isChecked()*/,
+ outputPoint, m_respectCase->isChecked() );
+ }
+ else if (m_sortColumn->isChecked())
+ {
+ m_pView->activeSheet()->sortByColumn( sortArea /*sourceArea*/, key1, key2, key3,
+ order1, order2, order3,
+ firstKey, m_copyLayout->isChecked(),
+ false/*m_firstRowOrColHeader->isChecked()*/,
+ outputPoint, m_respectCase->isChecked() );
+ }
+ else
+ {
+ kdDebug(36001) << "Err in radiobutton" << endl;
+ }
+
+ delete firstKey;
+ firstKey = 0L;
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+void SortDialog::sortKey2textChanged( int i )
+{
+ m_sortKey3->setEnabled( ( i!=0 ) );
+ m_sortOrder3->setEnabled( ( i!=0 ) );
+}
+
+void SortDialog::useCustomListsStateChanged( int state )
+{
+ if (state == 0)
+ m_customList->setEnabled(false);
+ else if (state == 2)
+ m_customList->setEnabled(true);
+}
+
+void SortDialog::firstRowHeaderChanged( int /*state*/ )
+{
+ /* if (m_sortColumn->isChecked())
+ return;
+
+ if (state == 0) // off
+ {
+ int k1 = m_sortKey1->currentItem();
+ int k2 = m_sortKey2->currentItem();
+ int k3 = m_sortKey3->currentItem();
+ m_sortKey1->clear();
+ m_sortKey2->clear();
+ m_sortKey3->clear();
+ m_sortKey1->insertStringList( m_listRow );
+ m_sortKey2->insertItem( i18n("None") );
+ m_sortKey2->insertStringList( m_listRow );
+ m_sortKey3->insertItem( i18n("None") );
+ m_sortKey3->insertStringList( m_listRow );
+
+ m_sortKey1->setCurrentItem(++k1);
+ m_sortKey2->setCurrentItem(++k2);
+ m_sortKey3->setCurrentItem(++k3);
+ }
+ else if (state == 2) // on
+ {
+ int k1 = m_sortKey1->currentItem();
+ int k2 = m_sortKey2->currentItem();
+ int k3 = m_sortKey3->currentItem();
+ m_sortKey1->removeItem( 0 );
+ m_sortKey2->removeItem( 1 ); // because there is "None" in there
+ m_sortKey3->removeItem( 1 );
+ if (k1 > 0)
+ m_sortKey1->setCurrentItem(--k1);
+ if (k2 > 0)
+ m_sortKey2->setCurrentItem(--k2);
+ if (k3 > 0)
+ m_sortKey3->setCurrentItem(--k3);
+ }*/
+}
+
+#include "kspread_dlg_sort.moc"
diff --git a/kspread/dialogs/kspread_dlg_sort.h b/kspread/dialogs/kspread_dlg_sort.h
new file mode 100644
index 00000000..3ac29512
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_sort.h
@@ -0,0 +1,111 @@
+/* This file is part of the KDE project
+ Copyright (C) 2006 Robert Knight <robertknight@gmail.com>
+ (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Ariya Hidayat <ariya@kde.org>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2002 Werner Trobin <trobin@kde.org>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 2000 David Faure <faure@kde.org>
+ (C) 1998-2000 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_sort__
+#define __kspread_dlg_sort__
+
+
+#include <kdialogbase.h>
+#include <qstringlist.h>
+
+class QCheckBox;
+class QComboBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+class QTabWidget;
+class QWidget;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class SortDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ enum Orientation
+ {
+ SortColumns=0,
+ SortRows=1
+ };
+
+ SortDialog( View * parent, const char * name = 0,
+ bool modal = false );
+ ~SortDialog();
+
+ protected:
+ Orientation guessDataOrientation();
+ QRect sourceArea();
+
+ private slots:
+ void sortKey2textChanged( int );
+ void useCustomListsStateChanged( int );
+ void firstRowHeaderChanged( int );
+ virtual void slotOk();
+ void slotOrientationChanged(int id);
+
+ private:
+ void init();
+
+ View * m_pView;
+
+ QStringList m_listColumn;
+ QStringList m_listRow;
+
+ QWidget * m_page1;
+ QWidget * m_page2;
+
+ QTabWidget * m_tabWidget;
+
+ QComboBox * m_sortKey1;
+ QComboBox * m_sortOrder1;
+ QComboBox * m_sortKey2;
+ QComboBox * m_sortOrder2;
+ QComboBox * m_sortKey3;
+ QComboBox * m_sortOrder3;
+
+ QCheckBox * m_useCustomLists;
+ QComboBox * m_customList;
+
+ QRadioButton * m_sortColumn;
+ QRadioButton * m_sortRow;
+
+ QCheckBox * m_copyLayout;
+ QCheckBox * m_firstRowOrColHeader;
+ QCheckBox * m_respectCase;
+
+ /*QComboBox * m_outputSheet;
+ QLineEdit * m_outputCell;*/
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_special.cc b/kspread/dialogs/kspread_dlg_special.cc
new file mode 100644
index 00000000..3c9426c7
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_special.cc
@@ -0,0 +1,135 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999-2004 Laurent Montel <montel@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qlayout.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+
+#include <klocale.h>
+
+#include "kspread_canvas.h"
+#include "kspread_doc.h"
+#include "kspread_sheet.h"
+#include "kspread_view.h"
+#include "selection.h"
+
+#include "kspread_dlg_special.h"
+
+using namespace KSpread;
+
+SpecialDialog::SpecialDialog( View* parent, const char* name )
+ : KDialogBase( parent, name, TRUE,i18n("Special Paste"),Ok|Cancel )
+{
+ m_pView = parent;
+ QWidget *page = new QWidget( this );
+ setMainWidget(page);
+ QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
+
+ QButtonGroup *grp = new QButtonGroup( 1, QGroupBox::Horizontal, i18n( "Paste What" ),page );
+ grp->setRadioButtonExclusive( TRUE );
+ grp->layout();
+ lay1->addWidget(grp);
+ rb1 = new QRadioButton( i18n("Everything"), grp );
+ rb2 = new QRadioButton( i18n("Text"), grp );
+ rb3 = new QRadioButton( i18n("Format"), grp );
+ rb10 = new QRadioButton( i18n("Comment"), grp );
+ rb11 = new QRadioButton( i18n("Result"), grp );
+
+ rb4 = new QRadioButton( i18n("Everything without border"), grp );
+ rb1->setChecked(true);
+
+ grp = new QButtonGroup( 1, QGroupBox::Horizontal, i18n("Operation"),page);
+ grp->setRadioButtonExclusive( TRUE );
+ grp->layout();
+ lay1->addWidget(grp);
+
+
+ rb5 = new QRadioButton( i18n("Overwrite"), grp );
+ rb6 = new QRadioButton( i18n("Addition"), grp );
+ rb7 = new QRadioButton( i18n("Subtraction"), grp );
+ rb8 = new QRadioButton( i18n("Multiplication"), grp );
+ rb9 = new QRadioButton( i18n("Division"), grp );
+ rb5->setChecked(true);
+
+ // cb = new QCheckBox(i18n("Transpose"),this);
+ // cb->layout();
+ // lay1->addWidget(cb);
+
+ connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
+ connect( rb3, SIGNAL( toggled( bool ) ), this, SLOT( slotToggled( bool ) ) );
+ connect( rb10, SIGNAL( toggled( bool ) ), this, SLOT( slotToggled( bool ) ) );
+}
+
+void SpecialDialog::slotOk()
+{
+ Paste::Mode sp = Paste::Normal;
+ Paste::Operation op = Paste::OverWrite;
+
+ /* if( rb1->isChecked() )
+ sp = cb->isChecked() ? NormalAndTranspose : Normal;
+ else if( rb2->isChecked() )
+ sp = cb->isChecked() ? TextAndTranspose : Text;
+ else if( rb3->isChecked() )
+ sp = cb->isChecked() ? FormatAndTranspose : Format;
+ else if( rb4->isChecked() )
+ sp = cb->isChecked() ? NoBorderAndTranspose : NoBorder; */
+
+ if( rb1->isChecked() )
+ sp = Paste::Normal;
+ else if( rb2->isChecked() )
+ sp = Paste::Text;
+ else if( rb3->isChecked() )
+ sp = Paste::Format;
+ else if( rb4->isChecked() )
+ sp = Paste::NoBorder;
+ else if( rb10->isChecked() )
+ sp = Paste::Comment;
+ else if( rb11->isChecked() )
+ sp = Paste::Result;
+
+ if( rb5->isChecked() )
+ op = Paste::OverWrite;
+ if( rb6->isChecked() )
+ op = Paste::Add;
+ if( rb7->isChecked() )
+ op = Paste::Sub;
+ if( rb8->isChecked() )
+ op = Paste::Mul;
+ if( rb9->isChecked() )
+ op = Paste::Div;
+
+ m_pView->doc()->emitBeginOperation( false );
+ m_pView->activeSheet()->paste( m_pView->selectionInfo()->lastRange(), true, sp, op );
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+void SpecialDialog::slotToggled( bool b )
+{
+ rb5->setEnabled( !b );
+ rb6->setEnabled( !b );
+ rb7->setEnabled( !b );
+ rb8->setEnabled( !b );
+ rb9->setEnabled( !b );
+}
+
+#include "kspread_dlg_special.moc"
diff --git a/kspread/dialogs/kspread_dlg_special.h b/kspread/dialogs/kspread_dlg_special.h
new file mode 100644
index 00000000..00491387
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_special.h
@@ -0,0 +1,55 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999-2004 Laurent Montel <montel@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_special__
+#define __kspread_dlg_special__
+
+#include <kdialogbase.h>
+
+class QRadioButton;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class SpecialDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ SpecialDialog( View* parent, const char* name );
+
+public slots:
+ void slotOk();
+ void slotToggled( bool );
+
+private:
+ View* m_pView;
+ QRadioButton *rb1, *rb2, *rb3, *rb4, *rb5;
+ QRadioButton *rb6, *rb7, *rb8;
+ QRadioButton *rb9, *rb10, *rb11;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_styles.cc b/kspread/dialogs/kspread_dlg_styles.cc
new file mode 100644
index 00000000..088c82f3
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_styles.cc
@@ -0,0 +1,332 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Laurent Montel <montel@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qheader.h>
+#include <qlayout.h>
+#include <qmap.h>
+
+#include <kcombobox.h>
+#include <kdebug.h>
+#include <klistview.h>
+#include <klocale.h>
+
+#include "kspread_canvas.h"
+#include "kspread_cell.h"
+#include "kspread_dlg_layout.h"
+#include "kspread_sheet.h"
+#include "kspread_style.h"
+#include "kspread_style_manager.h"
+#include "kspread_view.h"
+
+#include "kspread_dlg_styles.h"
+
+using namespace KSpread;
+
+StyleWidget::StyleWidget( QWidget * parent, const char * name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ QVBoxLayout * layout = new QVBoxLayout( this, 11, 6, "layout");
+
+ m_styleList = new KListView( this, "m_styleList" );
+ m_styleList->addColumn( i18n( "Styles" ) );
+ m_styleList->setResizeMode( KListView::AllColumns );
+ layout->addWidget( m_styleList );
+
+ m_displayBox = new KComboBox( FALSE, this, "m_displayBox" );
+ layout->addWidget( m_displayBox );
+
+ m_styleList->header()->setLabel( 0, i18n( "Styles" ) );
+ m_displayBox->clear();
+ m_displayBox->insertItem( i18n( "All Styles" ) );
+ m_displayBox->insertItem( i18n( "Applied Styles" ) );
+ m_displayBox->insertItem( i18n( "Custom Styles" ) );
+ m_displayBox->insertItem( i18n( "Hierarchical" ) );
+ connect( m_styleList, SIGNAL(doubleClicked ( QListViewItem *)),this, SIGNAL( modifyStyle()));
+ resize( QSize(446, 384).expandedTo(minimumSizeHint()) );
+}
+
+StyleWidget::~StyleWidget()
+{
+}
+
+
+
+StyleDlg::StyleDlg( View * parent, StyleManager * manager,
+ const char * name )
+ : KDialogBase( parent, name, true, "",
+ KDialogBase::Ok | KDialogBase::User1 | KDialogBase::User2 | KDialogBase::User3 | KDialogBase::Close,
+ KDialogBase::Ok, false, KGuiItem( i18n( "&New..." ) ), KGuiItem( i18n( "&Modify..." ) ), KGuiItem( i18n( "&Delete" ) ) ),
+ m_view( parent ),
+ m_styleManager( manager ),
+ m_dlg( new StyleWidget( this ) )
+{
+ setCaption( i18n( "Style Manager" ) );
+ setButtonBoxOrientation( Vertical );
+ setMainWidget( m_dlg );
+
+ slotDisplayMode( 0 );
+ enableButton( KDialogBase::User1, true );
+ enableButton( KDialogBase::User2, true );
+ enableButton( KDialogBase::User3, false );
+
+ connect( m_dlg->m_styleList, SIGNAL( selectionChanged( QListViewItem * ) ),
+ this, SLOT( slotSelectionChanged( QListViewItem * ) ) );
+ connect( m_dlg->m_displayBox, SIGNAL( activated( int ) ), this, SLOT( slotDisplayMode( int ) ) );
+ connect( this, SIGNAL( user3Clicked() ), this, SLOT( slotUser3() ) );
+ connect( m_dlg, SIGNAL( modifyStyle() ), this, SLOT( slotUser2()));
+}
+
+StyleDlg::~StyleDlg()
+{
+}
+
+void StyleDlg::fillComboBox()
+{
+ class Map : public QMap<CustomStyle *, KListViewItem *> {};
+ Map entries;
+
+ entries.clear();
+ entries[m_styleManager->defaultStyle()] = new KListViewItem( m_dlg->m_styleList, i18n( "Default" ) );
+
+ StyleManager::Styles::const_iterator iter = m_styleManager->m_styles.begin();
+ StyleManager::Styles::const_iterator end = m_styleManager->m_styles.end();
+ uint count = m_styleManager->m_styles.count() + 1;
+
+ while ( entries.count() != count )
+ {
+ if ( entries.find( iter.data() ) == entries.end() )
+ {
+ if ( iter.data()->parent() == 0 )
+ entries[iter.data()] = new KListViewItem( m_dlg->m_styleList, iter.data()->name() );
+ else
+ {
+ Map::const_iterator i = entries.find( iter.data()->parent() );
+ if ( i != entries.end() )
+ entries[iter.data()] = new KListViewItem( i.data(), iter.data()->name() );
+ }
+ }
+
+ ++iter;
+ if ( iter == end )
+ iter = m_styleManager->m_styles.begin();
+ }
+ entries.clear();
+}
+
+void StyleDlg::slotDisplayMode( int mode )
+{
+ m_dlg->m_styleList->clear();
+
+ if ( mode != 3 )
+ m_dlg->m_styleList->setRootIsDecorated( false );
+ else
+ {
+ m_dlg->m_styleList->setRootIsDecorated( true );
+ fillComboBox();
+ return;
+ }
+
+ if ( mode != 2 )
+ new KListViewItem( m_dlg->m_styleList, i18n( "Default" ) );
+
+ StyleManager::Styles::iterator iter = m_styleManager->m_styles.begin();
+ StyleManager::Styles::iterator end = m_styleManager->m_styles.end();
+
+ while ( iter != end )
+ {
+ CustomStyle * styleData = iter.data();
+ if ( !styleData || styleData->name().isEmpty() )
+ {
+ ++iter;
+ continue;
+ }
+
+ if ( mode == 2 )
+ {
+ if ( styleData->type() == Style::CUSTOM )
+ new KListViewItem( m_dlg->m_styleList, styleData->name() );
+ }
+ else if ( mode == 1 )
+ {
+ if ( styleData->usage() > 0 )
+ new KListViewItem( m_dlg->m_styleList, styleData->name() );
+ }
+ else
+ new KListViewItem( m_dlg->m_styleList, styleData->name() );
+
+ ++iter;
+ }
+}
+
+void StyleDlg::slotOk()
+{
+ KListViewItem * item = (KListViewItem *) m_dlg->m_styleList->currentItem();
+
+ if ( !item )
+ {
+ accept();
+ return;
+ }
+
+ CustomStyle * s = 0;
+
+ QString name( item->text( 0 ) );
+ if ( name == i18n( "Default" ) )
+ s = m_styleManager->defaultStyle();
+ else
+ s = m_styleManager->style( name );
+
+ if ( !s )
+ {
+ accept();
+ return;
+ }
+
+ if ( m_view )
+ {
+ Sheet * sheet = m_view->activeSheet();
+
+ if ( sheet )
+ {
+ m_view->doc()->emitBeginOperation( false );
+ sheet->setSelectionStyle( m_view->selectionInfo(), s );
+ }
+
+ m_view->slotUpdateView( m_view->activeSheet() );
+ }
+ accept();
+}
+
+void StyleDlg::slotUser1()
+{
+ CustomStyle * s = 0;
+
+ KListViewItem * item = (KListViewItem *) m_dlg->m_styleList->currentItem();
+
+ if ( item )
+ {
+ QString name( item->text( 0 ) );
+ if ( name == i18n( "Default" ) )
+ s = m_styleManager->defaultStyle();
+ else
+ s = m_styleManager->style( name );
+ }
+ else
+ s = m_styleManager->defaultStyle();
+
+ int i = 1;
+ QString newName( i18n( "style%1" ).arg( m_styleManager->count() + i ) );
+ while ( m_styleManager->style( newName ) != 0 )
+ {
+ ++i;
+ newName = i18n( "style%1" ).arg( m_styleManager->count() + i );
+ }
+
+ CustomStyle * style = new CustomStyle( newName, s );
+ style->setType( Style::TENTATIVE );
+
+ CellFormatDialog dlg( m_view, style, m_styleManager, m_view->doc() );
+
+ if ( style->type() == Style::TENTATIVE )
+ {
+ delete style;
+ return;
+ }
+
+ m_styleManager->m_styles[ style->name() ] = style;
+
+ slotDisplayMode( m_dlg->m_displayBox->currentItem() );
+}
+
+void StyleDlg::slotUser2()
+{
+ KListViewItem * item = (KListViewItem *) m_dlg->m_styleList->currentItem();
+
+ if ( !item )
+ return;
+
+ CustomStyle * s = 0;
+
+ QString name( item->text( 0 ) );
+ if ( name == i18n( "Default" ) )
+ s = m_styleManager->defaultStyle();
+ else
+ s = m_styleManager->style( name );
+
+ if ( !s )
+ return;
+
+ CellFormatDialog dlg( m_view, s, m_styleManager, m_view->doc() );
+ slotDisplayMode( m_dlg->m_displayBox->currentItem() );
+}
+
+void StyleDlg::slotUser3()
+{
+ KListViewItem * item = (KListViewItem *) m_dlg->m_styleList->currentItem();
+
+ if ( !item )
+ return;
+
+ CustomStyle * s = 0;
+
+ QString name( item->text( 0 ) );
+ if ( name == i18n( "Default" ) )
+ s = m_styleManager->defaultStyle();
+ else
+ s = m_styleManager->style( name );
+
+ if ( !s )
+ return;
+
+ if ( s->type() != Style::CUSTOM )
+ return;
+
+ s->setType( Style::AUTO );
+ m_styleManager->takeStyle( s );
+
+ slotDisplayMode( m_dlg->m_displayBox->currentItem() );
+}
+
+void StyleDlg::slotSelectionChanged( QListViewItem * item )
+{
+ if ( !item )
+ return;
+
+ CustomStyle* style = 0;
+ QString name( item->text( 0 ) );
+ if ( name == i18n( "Default" ) )
+ style = m_styleManager->defaultStyle();
+ else
+ style = m_styleManager->style( name );
+ if ( !style )
+ {
+ enableButton( KDialogBase::User3, false );
+ return;
+ }
+
+ if ( style->type() == Style::BUILTIN )
+ enableButton( KDialogBase::User3, false );
+ else
+ enableButton( KDialogBase::User3, true );
+}
+
+
+#include "kspread_dlg_styles.moc"
+
diff --git a/kspread/dialogs/kspread_dlg_styles.h b/kspread/dialogs/kspread_dlg_styles.h
new file mode 100644
index 00000000..15ff4d4b
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_styles.h
@@ -0,0 +1,77 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Laurent Montel <montel@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_styles__
+#define __kspread_dlg_styles__
+
+#include <kdialogbase.h>
+#include <qwidget.h>
+
+class KComboBox;
+class KListView;
+
+class QListViewItem;
+
+namespace KSpread
+{
+class StyleManager;
+class View;
+
+class StyleWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ StyleWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~StyleWidget();
+
+ KListView * m_styleList;
+ KComboBox * m_displayBox;
+signals:
+ void modifyStyle();
+};
+
+class StyleDlg : public KDialogBase
+{
+ Q_OBJECT
+ public:
+ StyleDlg( View * parent, StyleManager * manager,
+ const char * name = "StyleDlg" );
+ ~StyleDlg();
+
+ protected slots:
+ void slotOk();
+ void slotUser1();
+ void slotUser2();
+ void slotUser3();
+ void slotDisplayMode( int mode );
+ void slotSelectionChanged( QListViewItem * );
+
+ private:
+ View * m_view;
+ StyleManager * m_styleManager;
+ StyleWidget * m_dlg;
+
+ void fillComboBox();
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspread_dlg_subtotal.cc b/kspread/dialogs/kspread_dlg_subtotal.cc
new file mode 100644
index 00000000..f64664b5
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_subtotal.cc
@@ -0,0 +1,321 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlistview.h>
+#include <qmemarray.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "kspreadsubtotal.h"
+#include "kspread_sheet.h"
+#include "kspread_view.h"
+#include "kspread_doc.h"
+#include "kspread_util.h"
+
+#include "kspread_dlg_subtotal.h"
+
+using namespace KSpread;
+
+SubtotalDialog::SubtotalDialog( View * parent, QRect const & selection, const char * name )
+ : KDialogBase(parent, name, true, i18n( "Subtotals" ), Ok | Cancel | User1, Ok, true, KGuiItem(i18n( "Remove All" )) ),
+ m_pView( parent ),
+ m_pSheet( m_pView->activeSheet() ),
+ m_selection( selection ),
+ m_dialog( new Subtotal( this ) )
+{
+ setButtonBoxOrientation( Vertical );
+ setMainWidget( m_dialog );
+
+ fillColumnBoxes();
+ fillFunctionBox();
+}
+
+SubtotalDialog::~SubtotalDialog()
+{
+}
+
+void SubtotalDialog::slotOk()
+{
+ int numOfCols = m_selection.width();
+ QMemArray<int> columns( numOfCols );
+
+ int n = 0;
+ bool empty = true;
+ int left = m_selection.left();
+ for ( QListViewItem * item = m_dialog->m_columnList->firstChild(); item; item = item->nextSibling() )
+ {
+ if ( ((QCheckListItem * ) item)->isOn() )
+ {
+ columns[n] = left + n;
+ empty = false;
+ }
+ else
+ columns[n] = -1;
+ ++n;
+ }
+
+ if ( empty )
+ {
+ KMessageBox::sorry( this, i18n("You need to select at least one column for adding subtotals.") );
+ return;
+ }
+
+ if ( m_dialog->m_replaceSubtotals->isChecked() )
+ removeSubtotalLines();
+
+ int mainCol = left + m_dialog->m_columnBox->currentItem();
+ int bottom = m_selection.bottom();
+ int top = m_selection.top();
+ left = m_selection.left();
+ QString oldText = m_pSheet->cellAt( mainCol, top )->strOutText();
+ QString newText;
+ QString result( " " + i18n("Result") );
+ int lastChangedRow = top;
+
+ m_pView->doc()->emitBeginOperation( false );
+ bool ignoreEmptyCells = m_dialog->m_IgnoreBox->isChecked();
+ bool addRow;
+ if ( !m_dialog->m_summaryOnly->isChecked() )
+ {
+ int y = top + 1;
+ kdDebug() << "Starting in row " << y << endl;
+ while ( y <= bottom )
+ {
+ addRow = true;
+ newText = m_pSheet->cellAt( mainCol, y )->strOutText();
+
+ if ( ignoreEmptyCells && (newText.length() == 0) )
+ {
+ ++y;
+ kdDebug() << "Still the same -> " << y << endl;
+ continue;
+ }
+
+ if (newText != oldText)
+ {
+ int saveY = y;
+ for (int x = 0; x < numOfCols; ++x)
+ {
+ kdDebug() << "Column: " << x << ", " << columns[x] << endl;
+ if (columns[x] != -1)
+ {
+ if (!addSubtotal( mainCol, columns[x], y - 1, lastChangedRow, addRow, oldText + result))
+ reject();
+
+ if ( addRow )
+ {
+ ++saveY;
+ ++bottom;
+ }
+
+ addRow = false;
+ }
+ }
+ y = saveY;
+ lastChangedRow = y;
+ }
+ oldText = newText;
+ ++y;
+ }
+
+ addRow = true;
+ for ( int x = 0; x < numOfCols; ++x )
+ {
+ if ( columns[x] != -1 )
+ {
+ if ( !addSubtotal( mainCol, columns[x], y - 1, lastChangedRow, addRow, oldText + result ) )
+ reject();
+ addRow = false;
+ }
+ }
+ ++y;
+ }
+
+ if ( m_dialog->m_summaryBelow->isChecked() )
+ {
+ addRow = true;
+ int bottom = m_selection.bottom();
+ for (int x = 0; x < numOfCols; ++x)
+ {
+ if (columns[x] != -1)
+ {
+ addSubtotal( mainCol, columns[x], bottom, top, addRow, i18n("Grand Total") );
+ addRow = false;
+ }
+ }
+ }
+
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+void SubtotalDialog::slotCancel()
+{
+ reject();
+}
+
+void SubtotalDialog::slotUser1()
+{
+ m_pView->doc()->emitBeginOperation( false );
+ removeSubtotalLines();
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+void SubtotalDialog::removeSubtotalLines()
+{
+ kdDebug() << "Removing subtotal lines" << endl;
+
+ int r = m_selection.right();
+ int l = m_selection.left();
+ int t = m_selection.top();
+
+ Cell * cell;
+ QString text;
+
+ for ( int y = m_selection.bottom(); y >= t; --y )
+ {
+ kdDebug() << "Checking row: " << y << endl;
+ bool containsSubtotal = false;
+ for (int x = l; x <= r; ++x )
+ {
+ cell = m_pSheet->cellAt( x, y );
+ if ( cell->isDefault() || !cell->isFormula() )
+ continue;
+
+ text = cell->text();
+ if ( text.find( "SUBTOTAL" ) != -1 )
+ {
+ containsSubtotal = true;
+ break;
+ }
+ }
+
+ if ( containsSubtotal )
+ {
+ kdDebug() << "Line " << y << " contains a subtotal " << endl;
+ QRect rect( l, y, m_selection.width(), 1 );
+
+ m_pSheet->unshiftColumn( rect );
+ m_selection.setHeight( m_selection.height() - 1 );
+ }
+ }
+ kdDebug() << "Done removing subtotals" << endl;
+}
+
+void SubtotalDialog::fillColumnBoxes()
+{
+ int r = m_selection.right();
+ int row = m_selection.top();
+
+ Cell * cell;
+ QCheckListItem * item;
+
+ QString text;
+ QString col( i18n( "Column '%1' ") );
+
+ for ( int i = m_selection.left(); i <= r; ++i )
+ {
+ cell = m_pSheet->cellAt( i, row );
+ text = cell->strOutText();
+
+ if ( text.length() > 0 )
+ {
+ text = col.arg( Cell::columnName( i ) );
+ }
+
+ m_dialog->m_columnBox->insertItem( text );
+
+ item = new QCheckListItem( m_dialog->m_columnList,
+ text,
+ QCheckListItem::CheckBox );
+ item->setOn(false);
+ m_dialog->m_columnList->insertItem( item );
+ }
+}
+
+void SubtotalDialog::fillFunctionBox()
+{
+ QStringList lst;
+ lst << i18n( "Average" );
+ lst << i18n( "Count" );
+ lst << i18n( "CountA" );
+ lst << i18n( "Max" );
+ lst << i18n( "Min" );
+ lst << i18n( "Product" );
+ lst << i18n( "StDev" );
+ lst << i18n( "StDevP" );
+ lst << i18n( "Sum" );
+ lst << i18n( "Var" );
+ lst << i18n( "VarP" );
+ m_dialog->m_functionBox->insertStringList(lst);
+}
+
+bool SubtotalDialog::addSubtotal( int mainCol, int column, int row, int topRow,
+ bool addRow, QString const & text )
+{
+ kdDebug() << "Adding subtotal: " << mainCol << ", " << column << ", Rows: " << row << ", " << topRow
+ << ": addRow: " << addRow << ", Text: " << text << endl;
+ if ( addRow )
+ {
+ QRect rect(m_selection.left(), row + 1, m_selection.width(), 1);
+ if ( !m_pSheet->shiftColumn( rect ) )
+ return false;
+
+ m_selection.setHeight( m_selection.height() + 1 );
+
+ Cell * cell = m_pSheet->nonDefaultCell( mainCol, row + 1 );
+ cell->setCellText( text );
+ cell->format()->setTextFontBold( true );
+ cell->format()->setTextFontItalic( true );
+ cell->format()->setTextFontUnderline( true );
+ }
+
+ QString colName = Cell::columnName( column );
+
+ QString formula("=SUBTOTAL(");
+ formula += QString::number( m_dialog->m_functionBox->currentItem() + 1 );
+ formula += "; ";
+ formula += colName;
+ formula += QString::number( topRow );
+ // if ( topRow != row )
+ {
+ formula += ":";
+ formula += colName;
+ formula += QString::number( row );
+ }
+ formula += ")";
+
+ Cell * cell = m_pSheet->nonDefaultCell( column, row + 1 );
+ cell->setCellText( formula );
+ cell->format()->setTextFontBold( true );
+ cell->format()->setTextFontItalic( true );
+ cell->format()->setTextFontUnderline( true );
+
+ return true;
+}
+
+#include "kspread_dlg_subtotal.moc"
+
diff --git a/kspread/dialogs/kspread_dlg_subtotal.h b/kspread/dialogs/kspread_dlg_subtotal.h
new file mode 100644
index 00000000..8bb2f3fb
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_subtotal.h
@@ -0,0 +1,72 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 2002 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+
+#ifndef __kspread_dlg_subtotal__
+#define __kspread_dlg_subtotal__
+
+#include <kdialogbase.h>
+
+#include <qpoint.h>
+#include <qrect.h>
+
+class QLineEdit;
+
+namespace KSpread
+{
+class Sheet;
+class Subtotal;
+class View;
+
+class SubtotalDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ SubtotalDialog( View * parent, QRect const & selection,
+ const char * name );
+ ~SubtotalDialog();
+
+ QRect const & selection() const { return m_selection; }
+ Sheet * sheet() const { return m_pSheet; }
+
+ private slots:
+ void slotOk();
+ void slotCancel();
+ void slotUser1();
+
+ private:
+ View * m_pView;
+ Sheet * m_pSheet;
+ QRect m_selection;
+ Subtotal * m_dialog;
+
+ void fillColumnBoxes();
+ void fillFunctionBox();
+ void removeSubtotalLines();
+ bool addSubtotal( int mainCol, int column, int row, int topRow,
+ bool addRow, QString const & text );
+};
+
+} // namespace KSpread
+
+#endif
+
diff --git a/kspread/dialogs/kspread_dlg_validity.cc b/kspread/dialogs/kspread_dlg_validity.cc
new file mode 100644
index 00000000..f40b6caa
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_validity.cc
@@ -0,0 +1,814 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1999-2005 Laurent Montel <montel@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+
+#include "kspread_dlg_validity.h"
+#include "kspread_canvas.h"
+#include "kspread_doc.h"
+#include "kspread_locale.h"
+#include "kspread_sheet.h"
+#include "kspread_view.h"
+
+#include <qlayout.h>
+#include <qbuttongroup.h>
+#include <knumvalidator.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+
+#include <qcombobox.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qtextedit.h>
+#include <qcheckbox.h>
+
+using namespace KSpread;
+
+DlgValidity::DlgValidity(View* parent,const char* name , const QRect &_marker )
+ :KDialogBase(KDialogBase::Tabbed, i18n("Validity"),User2|User1|Cancel, User1, parent, name,true,false,KStdGuiItem::ok(),i18n("Clear &All"))
+
+{
+ m_pView=parent;
+ marker=_marker;
+ QFrame *page1 = addPage(i18n("&Values"));
+ QVBoxLayout *lay1 = new QVBoxLayout( page1, KDialogBase::marginHint(), KDialogBase::spacingHint() );
+
+ QGroupBox* tmpQButtonGroup;
+ tmpQButtonGroup = new QGroupBox( 0, Qt::Vertical, i18n("Validity Criteria"), page1, "ButtonGroup_1" );
+ tmpQButtonGroup->layout()->setSpacing(KDialog::spacingHint());
+ tmpQButtonGroup->layout()->setMargin(KDialog::marginHint());
+ QGridLayout *grid1 = new QGridLayout(tmpQButtonGroup->layout(),4,2);
+
+ QLabel *tmpQLabel = new QLabel( tmpQButtonGroup, "Label_1" );
+ tmpQLabel->setText(i18n("Allow:" ));
+ grid1->addWidget(tmpQLabel,0,0);
+
+ chooseType=new QComboBox(tmpQButtonGroup);
+ grid1->addWidget(chooseType,0,1);
+ QStringList listType;
+ listType+=i18n("All");
+ listType+=i18n("Number");
+ listType+=i18n("Integer");
+ listType+=i18n("Text");
+ listType+=i18n("Date");
+ listType+=i18n("Time");
+ listType+=i18n("Text Length");
+ listType+=i18n("List");
+ chooseType->insertStringList(listType);
+ chooseType->setCurrentItem(0);
+
+ allowEmptyCell = new QCheckBox( i18n( "Allow blanks" ), tmpQButtonGroup );
+ grid1->addWidget(allowEmptyCell,1,0);
+
+ tmpQLabel = new QLabel( tmpQButtonGroup, "Label_2" );
+ tmpQLabel->setText(i18n("Data:" ));
+ grid1->addWidget(tmpQLabel,2,0);
+
+ choose=new QComboBox(tmpQButtonGroup);
+ grid1->addWidget(choose,2,1);
+ QStringList list;
+ list+=i18n("equal to");
+ list+=i18n("greater than");
+ list+=i18n("less than");
+ list+=i18n("equal to or greater than");
+ list+=i18n("equal to or less than");
+ list+=i18n("between");
+ list+=i18n("different from");
+ list+=i18n("different to");
+ choose->insertStringList(list);
+ choose->setCurrentItem(0);
+
+ edit1 = new QLabel( tmpQButtonGroup, "Label_3" );
+ edit1->setText(i18n("Minimum:" ));
+ grid1->addWidget(edit1,3,0);
+
+ val_min=new QLineEdit(tmpQButtonGroup);
+ grid1->addWidget(val_min,3,1);
+ val_min->setValidator( new KFloatValidator( val_min ) );
+
+ edit2 = new QLabel( tmpQButtonGroup, "Label_4" );
+ edit2->setText(i18n("Maximum:" ));
+ grid1->addWidget(edit2,4,0);
+
+ val_max=new QLineEdit(tmpQButtonGroup);
+ grid1->addWidget(val_max,4,1);
+ val_max->setValidator( new KFloatValidator( val_max ) );
+ lay1->addWidget(tmpQButtonGroup);
+
+ //Apply minimum width of column1 to avoid horizontal move when changing option
+ //A bit ugly to apply text always, but I couldn't get a label->QFontMetrix.boundingRect("text").width()
+ //to give mew the correct results - Philipp
+ edit2->setText( i18n( "Date:" ) );
+ grid1->addColSpacing( 0, edit2->width() );
+ edit2->setText( i18n( "Date minimum:" ) );
+ grid1->addColSpacing( 0, edit2->width() );
+ edit2->setText( i18n( "Date maximum:" ) );
+ grid1->addColSpacing( 0, edit2->width() );
+ edit2->setText( i18n( "Time:" ) );
+ grid1->addColSpacing( 0, edit2->width() );
+ edit2->setText( i18n( "Time minimum:" ) );
+ grid1->addColSpacing( 0, edit2->width() );
+ edit2->setText( i18n( "Time maximum:" ) );
+ grid1->addColSpacing( 0, edit2->width() );
+ edit2->setText( i18n( "Minimum:" ) );
+ grid1->addColSpacing( 0, edit2->width() );
+ edit2->setText( i18n( "Maximum:" ) );
+ grid1->addColSpacing( 0, edit2->width() );
+ edit2->setText( i18n( "Number:" ) );
+ grid1->addColSpacing( 0, edit2->width() );
+
+ validityList = new QTextEdit( tmpQButtonGroup );
+ grid1->addMultiCellWidget(validityList,2, 4,1, 1);
+
+ validityLabelList = new QLabel( tmpQButtonGroup, "Label_Label_List" );
+ validityLabelList->setText(i18n("Entries:" ));
+ grid1->addWidget(validityLabelList,2,0);
+
+ QFrame *page2 = addPage(i18n("&Error Alert"));
+
+ lay1 = new QVBoxLayout( page2, KDialogBase::marginHint(), KDialogBase::spacingHint() );
+
+ tmpQButtonGroup = new QButtonGroup( 0, Qt::Vertical, i18n("Contents"), page2, "ButtonGroup_2" );
+ tmpQButtonGroup->layout()->setSpacing(KDialog::spacingHint());
+ tmpQButtonGroup->layout()->setMargin(KDialog::marginHint());
+ QGridLayout *grid2 = new QGridLayout(tmpQButtonGroup->layout(),5,2);
+
+ displayMessage = new QCheckBox(i18n( "Show error message when invalid values are entered" ),tmpQButtonGroup );
+ displayMessage->setChecked( true );
+ grid2->addMultiCellWidget(displayMessage,0, 0,0, 1);
+
+ tmpQLabel = new QLabel( tmpQButtonGroup, "Label_5" );
+ tmpQLabel->setText(i18n("Action:" ));
+ grid2->addWidget(tmpQLabel,1,0);
+
+ chooseAction=new QComboBox(tmpQButtonGroup);
+ grid2->addWidget(chooseAction,1,1);
+ QStringList list2;
+ list2+=i18n("Stop");
+ list2+=i18n("Warning");
+ list2+=i18n("Information");
+ chooseAction->insertStringList(list2);
+ chooseAction->setCurrentItem(0);
+ tmpQLabel = new QLabel( tmpQButtonGroup, "Label_6" );
+ tmpQLabel->setText(i18n("Title:" ));
+ grid2->addWidget(tmpQLabel,2,0);
+
+ title=new QLineEdit( tmpQButtonGroup);
+ grid2->addWidget(title,2,1);
+
+ tmpQLabel = new QLabel( tmpQButtonGroup, "Label_7" );
+ tmpQLabel->setText(i18n("Message:" ));
+ grid2->addWidget(tmpQLabel,3,0);
+
+ message =new QTextEdit( tmpQButtonGroup);
+ grid2->addMultiCellWidget(message,3, 4,1, 1);
+ lay1->addWidget(tmpQButtonGroup);
+ message->setTextFormat( Qt::PlainText );
+
+ QFrame *page3 = addPage(i18n("Input Help"));
+ lay1 = new QVBoxLayout( page3, KDialogBase::marginHint(), KDialogBase::spacingHint() );
+
+ tmpQButtonGroup = new QButtonGroup( 0, Qt::Vertical, i18n("Contents"), page3, "ButtonGroup_2" );
+ tmpQButtonGroup->layout()->setSpacing(KDialog::spacingHint());
+ tmpQButtonGroup->layout()->setMargin(KDialog::marginHint());
+
+ QGridLayout *grid3 = new QGridLayout(tmpQButtonGroup->layout(),5,2);
+
+ displayHelp = new QCheckBox(i18n( "Show input help when cell is selected" ),tmpQButtonGroup );
+ displayMessage->setChecked( false );
+ grid3->addMultiCellWidget(displayHelp,0, 0,0, 1);
+
+ tmpQLabel = new QLabel( tmpQButtonGroup, "Label_6" );
+ tmpQLabel->setText(i18n("Title:" ));
+ grid3->addWidget(tmpQLabel,2,0);
+
+ titleHelp=new QLineEdit( tmpQButtonGroup);
+ grid3->addWidget(titleHelp,2,1);
+
+ tmpQLabel = new QLabel( tmpQButtonGroup, "Label_7" );
+ tmpQLabel->setText(i18n("Message:" ));
+ grid3->addWidget(tmpQLabel,3,0);
+
+ messageHelp =new QTextEdit( tmpQButtonGroup);
+ grid3->addMultiCellWidget(messageHelp,3, 4,1, 1);
+ lay1->addWidget(tmpQButtonGroup);
+ messageHelp->setTextFormat( Qt::PlainText );
+
+
+ connect(choose,SIGNAL(activated(int )),this,SLOT(changeIndexCond(int)));
+ connect(chooseType,SIGNAL(activated(int )),this,SLOT(changeIndexType(int)));
+ connect( this, SIGNAL(user1Clicked()), SLOT(OkPressed()) );
+ connect( this, SIGNAL(user2Clicked()), SLOT(clearAllPressed()) );
+ init();
+}
+
+void DlgValidity::displayOrNotListOfValidity( bool _displayList)
+{
+ if ( _displayList )
+ {
+ validityList->show();
+ validityLabelList->show();
+ edit1->hide();
+ val_min->hide();
+ edit2->hide();
+ val_max->hide();
+ }
+ else
+ {
+ validityList->hide();
+ validityLabelList->hide();
+ edit1->show();
+ val_min->show();
+ edit2->show();
+ val_max->show();
+ }
+}
+
+void DlgValidity::changeIndexType(int _index)
+{
+ bool activate = ( _index!=0 );
+ message->setEnabled(activate);
+ title->setEnabled(activate);
+ chooseAction->setEnabled( activate );
+ displayHelp->setEnabled(activate);
+ messageHelp->setEnabled(activate);
+ titleHelp->setEnabled(activate);
+ if ( _index == 7 )
+ displayOrNotListOfValidity( true );
+ else
+ displayOrNotListOfValidity( false );
+
+ switch(_index)
+ {
+ case 0:
+ edit1->setText("");
+ edit2->setText("");
+ val_max->setEnabled(false);
+ val_min->setEnabled(false);
+ edit1->setEnabled(false);
+ edit2->setEnabled(false);
+ choose->setEnabled(false);
+ break;
+ case 1:
+ val_min->setEnabled(true);
+ edit1->setEnabled(true);
+ choose->setEnabled(true);
+ val_min->setValidator( new KFloatValidator( val_min ) );
+ val_max->setValidator( new KFloatValidator( val_max ) );
+ if( choose->currentItem()<=4)
+ {
+ edit1->setText(i18n("Number:"));
+ edit2->setText("");
+ edit2->setEnabled(false);
+ val_max->setEnabled(false);
+ }
+ else
+ {
+ edit1->setText(i18n("Minimum:" ));
+ edit2->setText(i18n("Maximum:" ));
+ edit2->setEnabled(true);
+ val_max->setEnabled(true);
+ }
+ break;
+ case 2:
+ case 6:
+ val_min->setEnabled(true);
+ edit1->setEnabled(true);
+ choose->setEnabled(true);
+ val_min->setValidator( new KIntValidator( val_min ) );
+ val_max->setValidator( new KIntValidator( val_max ) );
+ if( choose->currentItem()<=4)
+ {
+ edit1->setText(i18n("Number:"));
+ edit2->setText("");
+ edit2->setEnabled(false);
+ val_max->setEnabled(false);
+ }
+ else
+ {
+ edit1->setText(i18n("Minimum:" ));
+ edit2->setText(i18n("Maximum:" ));
+ edit2->setEnabled(true);
+ val_max->setEnabled(true);
+ }
+ break;
+
+ case 3:
+ edit1->setText("");
+ edit2->setText("");
+ val_max->setEnabled(false);
+ val_min->setEnabled(false);
+ choose->setEnabled(false);
+ edit1->setEnabled(false);
+ edit2->setEnabled(false);
+ break;
+ case 4:
+ edit1->setText(i18n("Date:"));
+ edit2->setText("");
+ val_min->setEnabled(true);
+ edit1->setEnabled(true);
+ choose->setEnabled(true);
+
+ val_min->clearValidator();
+ val_max->clearValidator();
+ if( choose->currentItem()<=4)
+ {
+ edit1->setText(i18n("Date:"));
+ edit2->setText("");
+ edit2->setEnabled(false);
+ val_max->setEnabled(false);
+ }
+ else
+ {
+ edit1->setText(i18n("Date minimum:"));
+ edit2->setText(i18n("Date maximum:"));
+ edit2->setEnabled(true);
+ val_max->setEnabled(true);
+ }
+ break;
+ case 5:
+ val_min->setEnabled(true);
+ edit1->setEnabled(true);
+ choose->setEnabled(true);
+ val_min->clearValidator();
+ val_max->clearValidator();
+ if( choose->currentItem()<=4)
+ {
+ edit1->setText(i18n("Time:"));
+ edit2->setText("");
+ edit2->setEnabled(false);
+ val_max->setEnabled(false);
+ }
+ else
+ {
+ edit1->setText(i18n("Time minimum:"));
+ edit2->setText(i18n("Time maximum:"));
+ edit2->setEnabled(true);
+ val_max->setEnabled(true);
+ }
+ break;
+ }
+ if ( width() < sizeHint().width() )
+ resize( sizeHint() );
+}
+
+void DlgValidity::changeIndexCond(int _index)
+{
+ switch(_index)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ val_max->setEnabled(false);
+ if(chooseType->currentItem()==1 ||chooseType->currentItem()==2
+ ||chooseType->currentItem()==6)
+ edit1->setText(i18n("Number:"));
+ else if( chooseType->currentItem()==3)
+ edit1->setText("");
+ else if( chooseType->currentItem()==4)
+ edit1->setText(i18n("Date:"));
+ else if( chooseType->currentItem()==5)
+ edit1->setText(i18n("Time:"));
+ edit2->setText("");
+ edit2->setEnabled(false);
+ break;
+ case 5:
+ case 6:
+ val_max->setEnabled(true);
+ edit2->setEnabled(true);
+ edit1->setEnabled(true);
+ if(chooseType->currentItem()==1 || chooseType->currentItem()==2
+ || chooseType->currentItem()==6)
+ {
+ edit1->setText(i18n("Minimum:" ));
+ edit2->setText(i18n("Maximum:" ));
+ }
+ else if(chooseType->currentItem()==3)
+ {
+ edit1->setText("");
+ edit2->setText("");
+ }
+ else if(chooseType->currentItem()==4)
+ {
+ edit1->setText(i18n("Date minimum:"));
+ edit2->setText(i18n("Date maximum:"));
+ }
+ else if(chooseType->currentItem()==5)
+ {
+ edit1->setText(i18n("Time minimum:"));
+ edit2->setText(i18n("Time maximum:"));
+ }
+ break;
+ }
+}
+
+void DlgValidity::init()
+{
+ Cell *c = m_pView->activeSheet()->cellAt( marker.left(), marker.top() );
+ Validity * tmpValidity=c->getValidity(0);
+ if(tmpValidity!=0)
+ {
+ message->setText(tmpValidity->message);
+ title->setText(tmpValidity->title);
+ QString tmp;
+ switch( tmpValidity->m_restriction)
+ {
+ case Restriction::None:
+ chooseType->setCurrentItem(0);
+ break;
+ case Restriction::Number:
+ chooseType->setCurrentItem(1);
+ if(tmpValidity->m_cond >=5 )
+ val_max->setText(tmp.setNum(tmpValidity->valMax));
+ val_min->setText(tmp.setNum(tmpValidity->valMin));
+ break;
+ case Restriction::Integer:
+ chooseType->setCurrentItem(2);
+ if(tmpValidity->m_cond >=5 )
+ val_max->setText(tmp.setNum(tmpValidity->valMax));
+ val_min->setText(tmp.setNum(tmpValidity->valMin));
+ break;
+ case Restriction::TextLength:
+ chooseType->setCurrentItem(6);
+ if(tmpValidity->m_cond >=5 )
+ val_max->setText(tmp.setNum(tmpValidity->valMax));
+ val_min->setText(tmp.setNum(tmpValidity->valMin));
+ break;
+ case Restriction::Text:
+ chooseType->setCurrentItem(3);
+ break;
+ case Restriction::Date:
+ chooseType->setCurrentItem(4);
+ val_min->setText(m_pView->doc()->locale()->formatDate(tmpValidity->dateMin,true));
+ if(tmpValidity->m_cond >=5 )
+ val_max->setText(m_pView->doc()->locale()->formatDate(tmpValidity->dateMax,true));
+ break;
+ case Restriction::Time:
+ chooseType->setCurrentItem(5);
+ val_min->setText(m_pView->doc()->locale()->formatTime(tmpValidity->timeMin,true));
+ if(tmpValidity->m_cond >=5 )
+ val_max->setText(m_pView->doc()->locale()->formatTime(tmpValidity->timeMax,true));
+ break;
+ case Restriction::List:
+ {
+ chooseType->setCurrentItem(7);
+ QStringList lst =tmpValidity->listValidity;
+ QString tmp;
+ for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
+ tmp +=( *it )+"\n";
+ }
+ validityList->setText( tmp );
+ }
+ break;
+ default :
+ chooseType->setCurrentItem(0);
+ break;
+ }
+ switch (tmpValidity->m_action)
+ {
+ case Action::Stop:
+ chooseAction->setCurrentItem(0);
+ break;
+ case Action::Warning:
+ chooseAction->setCurrentItem(1);
+ break;
+ case Action::Information:
+ chooseAction->setCurrentItem(2);
+ break;
+ default :
+ chooseAction->setCurrentItem(0);
+ break;
+ }
+ switch ( tmpValidity->m_cond )
+ {
+ case Conditional::Equal:
+ choose->setCurrentItem(0);
+ break;
+ case Conditional::Superior:
+ choose->setCurrentItem(1);
+ break;
+ case Conditional::Inferior:
+ choose->setCurrentItem(2);
+ break;
+ case Conditional::SuperiorEqual:
+ choose->setCurrentItem(3);
+ break;
+ case Conditional::InferiorEqual:
+ choose->setCurrentItem(4);
+ break;
+ case Conditional::Between:
+ choose->setCurrentItem(5);
+ break;
+ case Conditional::Different:
+ choose->setCurrentItem(6);
+ break;
+ case Conditional::DifferentTo:
+ choose->setCurrentItem(7);
+ break;
+ default :
+ choose->setCurrentItem(0);
+ break;
+ }
+ displayMessage->setChecked( tmpValidity->displayMessage );
+ allowEmptyCell->setChecked( tmpValidity->allowEmptyCell );
+ titleHelp->setText( tmpValidity->titleInfo );
+ messageHelp->setText( tmpValidity->messageInfo );
+ displayHelp->setChecked( tmpValidity->displayValidationInformation );
+ }
+ changeIndexType(chooseType->currentItem()) ;
+ changeIndexCond(choose->currentItem()) ;
+}
+
+void DlgValidity::clearAllPressed()
+{
+ val_min->setText("");
+ val_max->setText("");
+ message->setText("");
+ title->setText("");
+ displayMessage->setChecked( true );
+ allowEmptyCell->setChecked( false );
+ choose->setCurrentItem(0);
+ chooseType->setCurrentItem(0);
+ chooseAction->setCurrentItem(0);
+ changeIndexType(0);
+ changeIndexCond(0);
+ messageHelp->setText("" );
+ titleHelp->setText( "" );
+ validityList->setText( "" );
+ displayHelp->setChecked( false );
+}
+
+void DlgValidity::OkPressed()
+{
+ if( chooseType->currentItem()==1)
+ {
+ bool ok;
+ val_min->text().toDouble(&ok);
+ if(! ok)
+ {
+ KMessageBox::error( this , i18n("This is not a valid value."),i18n("Error"));
+ val_min->setText("");
+ return;
+ }
+ val_max->text().toDouble(&ok);
+ if(! ok && choose->currentItem() >=5 && choose->currentItem()< 7)
+ {
+ KMessageBox::error( this , i18n("This is not a valid value."),i18n("Error"));
+ val_max->setText("");
+ return;
+ }
+ }
+ else if( chooseType->currentItem()==2 || chooseType->currentItem()==6)
+ {
+ bool ok;
+ val_min->text().toInt(&ok);
+ if(! ok)
+ {
+ KMessageBox::error( this , i18n("This is not a valid value."),i18n("Error"));
+ val_min->setText("");
+ return;
+ }
+ val_max->text().toInt(&ok);
+ if(! ok && choose->currentItem() >=5 && choose->currentItem()< 7)
+ {
+ KMessageBox::error( this , i18n("This is not a valid value."),i18n("Error"));
+ val_max->setText("");
+ return;
+ }
+ }
+ else if( chooseType->currentItem()==5)
+ {
+ if(! m_pView->doc()->locale()->readTime(val_min->text()).isValid())
+ {
+ KMessageBox::error( this , i18n("This is not a valid time."),i18n("Error"));
+ val_min->setText("");
+ return;
+ }
+ if(! m_pView->doc()->locale()->readTime(val_max->text()).isValid() && choose->currentItem() >=5)
+ {
+ KMessageBox::error( this , i18n("This is not a valid time."),i18n("Error"));
+ val_max->setText("");
+ return;
+ }
+ }
+ else if( chooseType->currentItem()==4)
+ {
+ if(! m_pView->doc()->locale()->readDate(val_min->text()).isValid())
+ {
+ KMessageBox::error( this , i18n("This is not a valid date."),i18n("Error"));
+ val_min->setText("");
+ return;
+ }
+ if(! m_pView->doc()->locale()->readDate(val_max->text()).isValid() && choose->currentItem() >=5 )
+ {
+ KMessageBox::error( this , i18n("This is not a valid date."),i18n("Error"));
+ val_max->setText("");
+ return;
+ }
+ }
+ else if ( chooseType->currentItem()==7 )
+ {
+ //Nothing
+ }
+
+ if( chooseType->currentItem()==0)
+ {//no validity
+ result.m_restriction=Restriction::None;
+ result.m_action=Action::Stop;
+ result.m_cond=Conditional::Equal;
+ result.message=message->text();
+ result.title=title->text();
+ result.valMin=0;
+ result.valMax=0;
+ result.timeMin=QTime(0,0,0);
+ result.timeMax=QTime(0,0,0);
+ result.dateMin=QDate(0,0,0);
+ result.dateMax=QDate(0,0,0);
+ }
+ else
+ {
+ switch( chooseType->currentItem())
+ {
+ case 0:
+ result.m_restriction=Restriction::None;
+ break;
+ case 1:
+ result.m_restriction=Restriction::Number;
+ break;
+ case 2:
+ result.m_restriction=Restriction::Integer;
+ break;
+ case 3:
+ result.m_restriction=Restriction::Text;
+ break;
+ case 4:
+ result.m_restriction=Restriction::Date;
+ break;
+ case 5:
+ result.m_restriction=Restriction::Time;
+ break;
+ case 6:
+ result.m_restriction=Restriction::TextLength;
+ break;
+ case 7:
+ result.m_restriction=Restriction::List;
+ break;
+
+ default :
+ break;
+ }
+ switch (chooseAction->currentItem())
+ {
+ case 0:
+ result.m_action=Action::Stop;
+ break;
+ case 1:
+ result.m_action=Action::Warning;
+ break;
+ case 2:
+ result.m_action=Action::Information;
+ break;
+ default :
+ break;
+ }
+ switch ( choose->currentItem())
+ {
+ case 0:
+ result.m_cond=Conditional::Equal;
+ break;
+ case 1:
+ result.m_cond=Conditional::Superior;
+ break;
+ case 2:
+ result.m_cond=Conditional::Inferior;
+ break;
+ case 3:
+ result.m_cond=Conditional::SuperiorEqual;
+ break;
+ case 4:
+ result.m_cond=Conditional::InferiorEqual;
+ break;
+ case 5:
+ result.m_cond=Conditional::Between;
+ break;
+ case 6:
+ result.m_cond=Conditional::Different;
+ break;
+ case 7:
+ result.m_cond=Conditional::DifferentTo;
+ break;
+ default :
+ break;
+ }
+ result.message=message->text();
+ result.title=title->text();
+ result.valMin=0;
+ result.valMax=0;
+ result.timeMin=QTime(0,0,0);
+ result.timeMax=QTime(0,0,0);
+ result.dateMin=QDate(0,0,0);
+ result.dateMax=QDate(0,0,0);
+
+ if( chooseType->currentItem()==1)
+ {
+ if(choose->currentItem() <5)
+ {
+ result.valMin=val_min->text().toDouble();
+ }
+ else
+ {
+ result.valMin=QMIN(val_min->text().toDouble(),val_max->text().toDouble());
+ result.valMax=QMAX(val_max->text().toDouble(),val_min->text().toDouble());
+ }
+ }
+ else if( chooseType->currentItem()==2 || chooseType->currentItem()==6)
+ {
+ if(choose->currentItem() <5)
+ {
+ result.valMin=val_min->text().toInt();
+ }
+ else
+ {
+ result.valMin=QMIN(val_min->text().toInt(),val_max->text().toInt());
+ result.valMax=QMAX(val_max->text().toInt(),val_min->text().toInt());
+ }
+ }
+ else if( chooseType->currentItem()==4)
+ {
+ if(choose->currentItem() <5)
+ {
+ result.dateMin=m_pView->doc()->locale()->readDate(val_min->text());
+ }
+ else
+ {
+ if(m_pView->doc()->locale()->readDate(val_min->text())<m_pView->doc()->locale()->readDate(val_max->text()))
+ {
+ result.dateMin=m_pView->doc()->locale()->readDate(val_min->text());
+ result.dateMax=m_pView->doc()->locale()->readDate(val_max->text());
+ }
+ else
+ {
+ result.dateMin=m_pView->doc()->locale()->readDate(val_max->text());
+ result.dateMax=m_pView->doc()->locale()->readDate(val_min->text());
+ }
+ }
+ }
+ else if( chooseType->currentItem()==5)
+ {
+ if(choose->currentItem() <5)
+ {
+ result.timeMin=m_pView->doc()->locale()->readTime(val_min->text());
+ }
+ else
+ {
+ if(m_pView->doc()->locale()->readTime(val_min->text())<m_pView->doc()->locale()->readTime(val_max->text()))
+ {
+ result.timeMax=m_pView->doc()->locale()->readTime(val_max->text());
+ result.timeMin=m_pView->doc()->locale()->readTime(val_min->text());
+ }
+ else
+ {
+ result.timeMax=m_pView->doc()->locale()->readTime(val_min->text());
+ result.timeMin=m_pView->doc()->locale()->readTime(val_max->text());
+ }
+ }
+ }
+ else if ( chooseType->currentItem()==7 )
+ {
+ result.listValidity=QStringList::split( "\n", validityList->text() );
+ }
+ }
+ result.displayMessage = displayMessage->isChecked();
+ result.allowEmptyCell = allowEmptyCell->isChecked();
+ result.displayValidationInformation = displayHelp->isChecked();
+ result.messageInfo= messageHelp->text();
+ result.titleInfo = titleHelp->text();
+
+ m_pView->doc()->emitBeginOperation( false );
+ m_pView->activeSheet()->setValidity( m_pView->selectionInfo(), result);
+ m_pView->slotUpdateView( m_pView->activeSheet() );
+ accept();
+}
+
+#include "kspread_dlg_validity.moc"
diff --git a/kspread/dialogs/kspread_dlg_validity.h b/kspread/dialogs/kspread_dlg_validity.h
new file mode 100644
index 00000000..4bf96bbe
--- /dev/null
+++ b/kspread/dialogs/kspread_dlg_validity.h
@@ -0,0 +1,81 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
+ (C) 2002 John Dailey <dailey@vt.edu>
+ (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1999-2005 Laurent Montel <montel@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kspread_dlg_validity__
+#define __kspread_dlg_validity__
+
+#include <kdialogbase.h>
+
+#include "kspread_cell.h"
+
+class QLabel;
+class QLineEdit;
+class QTextEdit;
+class QComboBox;
+class QPushButton;
+class QCheckBox;
+
+namespace KSpread
+{
+class Sheet;
+class View;
+
+class DlgValidity : public KDialogBase
+{
+ Q_OBJECT
+public:
+DlgValidity(View* parent, const char* name ,const QRect &_marker );
+void init();
+
+public slots:
+ void OkPressed();
+ void clearAllPressed();
+ void changeIndexCond(int);
+ void changeIndexType(int);
+protected:
+ void displayOrNotListOfValidity( bool _displayList);
+
+ View* m_pView;
+ QRect marker;
+ QLineEdit *val_max;
+ QLineEdit *val_min;
+ QLabel *edit1;
+ QLabel *edit2;
+ QComboBox *choose;
+ QComboBox *chooseAction;
+ QComboBox *chooseType;
+ QLineEdit * title;
+ QTextEdit *message;
+ Validity result;
+ QCheckBox *displayMessage;
+ QCheckBox *allowEmptyCell;
+ QCheckBox *displayHelp;
+ QTextEdit *messageHelp;
+ QLineEdit *titleHelp;
+ QTextEdit *validityList;
+ QLabel *validityLabelList;
+};
+
+} // namespace KSpread
+
+#endif
diff --git a/kspread/dialogs/kspreadsubtotal.ui b/kspread/dialogs/kspreadsubtotal.ui
new file mode 100644
index 00000000..a5da5c42
--- /dev/null
+++ b/kspread/dialogs/kspreadsubtotal.ui
@@ -0,0 +1,222 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>KSpread::Subtotal</class>
+<comment>This file is part of the KDE project
+Copyright (C) 2002 Norbert Andres &lt;nandres@web.de&gt;
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this library; see the file COPYING.LIB. If not,
+write to the Free Software Foundation, Inc., 51 Franklin Street,
+Fifth Floor, Boston, MA 02110-1301, USA.</comment>
+<author>Norbert Andres &lt;nandres@web.de&gt;</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KSpreadSubtotal</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>446</width>
+ <height>381</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Subtotal</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QTabWidget" row="0" column="0">
+ <property name="name">
+ <cstring>TabWidget2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Subtotal</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QComboBox" row="3" column="0">
+ <property name="name">
+ <cstring>m_functionBox</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>m_addSubtotalToLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Add Subtotal to:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>m_useFunctionLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Use function:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="1" column="0">
+ <property name="name">
+ <cstring>m_columnBox</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>m_eachChangeLabel</cstring>
+ </property>
+ <property name="text">
+ <string>At each change in:</string>
+ </property>
+ </widget>
+ <widget class="QListView" row="5" column="0">
+ <column>
+ <property name="text">
+ <string>Columns</string>
+ </property>
+ <property name="clickable">
+ <bool>false</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_columnList</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Options</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>m_replaceSubtotals</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Replace current Subtotals</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>m_pageBreak</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Page break between groups</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>m_summaryBelow</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Summary below data</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>m_summaryOnly</cstring>
+ </property>
+ <property name="text">
+ <string>Summary &amp;only</string>
+ </property>
+ </widget>
+ <spacer row="5" column="0">
+ <property name="name">
+ <cstring>Spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>0</width>
+ <height>152</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox" row="4" column="0">
+ <property name="name">
+ <cstring>m_IgnoreBox</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Ignore empty cells when looking for changes</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kspread/dialogs/link.cc b/kspread/dialogs/link.cc
new file mode 100644
index 00000000..7704eee5
--- /dev/null
+++ b/kspread/dialogs/link.cc
@@ -0,0 +1,288 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Ariya Hidayat <ariya@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 1999 Stephan Kulow <coolo@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "link.h"
+
+#include <qcombobox.h>
+#include <qframe.h>
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <kdesktopfile.h>
+#include <kdialogbase.h>
+#include <kiconloader.h>
+#include <klineedit.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <krecentdocument.h>
+#include <kurlrequester.h>
+
+using namespace KSpread;
+
+class LinkDialog::Private
+{
+public:
+ QString text;
+ QFrame* internetPage;
+ KLineEdit* internetText;
+ KLineEdit* internetLink;
+ QFrame* mailPage;
+ KLineEdit* mailText;
+ KLineEdit* mailLink;
+ QFrame* filePage;
+ KLineEdit* fileText;
+ KURLRequester* fileLink;
+ QFrame* cellPage;
+ KLineEdit* cellText;
+ KLineEdit* cellLink;
+};
+
+LinkDialog::LinkDialog( QWidget*, const char* )
+ : KDialogBase( KDialogBase::IconList,i18n( "Insert Link") ,
+ KDialogBase::Ok | KDialogBase::Cancel,
+ KDialogBase::Ok )
+{
+ d = new Private;
+
+ // link for web or ftp
+ d->internetPage = addPage( i18n( "Internet" ), QString::null,
+ BarIcon( "html",KIcon::SizeMedium ) );
+ QVBoxLayout* iLayout = new QVBoxLayout( d->internetPage, marginHint(), spacingHint() );
+ iLayout->add( new QLabel( i18n("Text to display:" ), d->internetPage ) );
+ d->internetText = new KLineEdit( d->internetPage );
+ iLayout->add( d->internetText );
+ iLayout->add( new QLabel( i18n("Internet address:" ), d->internetPage ) );
+ d->internetLink = new KLineEdit( d->internetPage );
+ iLayout->add( d->internetLink );
+ iLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
+ connect( d->internetText, SIGNAL( textChanged( const QString& ) ), this,
+ SLOT( setText( const QString& ) ) );
+
+ // link for e-mail
+ d->mailPage = addPage( i18n( "Mail" ), QString::null,
+ BarIcon( "mail_generic",KIcon::SizeMedium ) );
+ QVBoxLayout* mLayout = new QVBoxLayout( d->mailPage, marginHint(), spacingHint() );
+ mLayout->add( new QLabel( i18n("Text to display:" ), d->mailPage ) );
+ d->mailText = new KLineEdit( d->mailPage );
+ mLayout->add( d->mailText );
+ mLayout->add( new QLabel( i18n("Email:" ), d->mailPage ) );
+ d->mailLink = new KLineEdit( d->mailPage );
+ mLayout->add( d->mailLink );
+ mLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
+ connect( d->mailText, SIGNAL( textChanged( const QString& ) ), this,
+ SLOT( setText( const QString& ) ) );
+
+ // link for external file
+ d->filePage = addPage( i18n( "File" ), QString::null,
+ BarIcon( "filenew",KIcon::SizeMedium ) );
+ QVBoxLayout* fLayout = new QVBoxLayout( d->filePage, marginHint(), spacingHint() );
+ fLayout->add( new QLabel( i18n("Text to display:" ), d->filePage ) );
+ d->fileText = new KLineEdit( d->filePage );
+ fLayout->add( d->fileText );
+ fLayout->add( new QLabel( i18n("File location:" ), d->filePage ) );
+ d->fileLink = new KURLRequester( d->filePage );
+ fLayout->add( d->fileLink );
+ fLayout->add( new QLabel( i18n("Recent file:" ), d->filePage ) );
+ QComboBox* recentFile = new QComboBox( d->filePage );
+ recentFile->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+ fLayout->add( recentFile );
+ fLayout->addItem( new QSpacerItem( 0, 40, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ) );
+ connect( d->fileText, SIGNAL( textChanged( const QString& ) ), this,
+ SLOT( setText( const QString& ) ) );
+ QObject::connect( recentFile, SIGNAL( highlighted ( const QString &) ),
+ d->fileLink->lineEdit(), SLOT( setText( const QString & ) ) );
+
+
+ // populate recent files
+ QStringList fileList = KRecentDocument::recentDocuments();
+ for( QStringList::ConstIterator it = fileList.begin();it != fileList.end(); ++it )
+ {
+ KDesktopFile f(*it, true /* read only */);
+ if ( !f.readURL().isEmpty() )
+ recentFile->insertItem( f.readURL() );
+ }
+ if( recentFile->count()==0 )
+ {
+ recentFile->insertItem( i18n("No Entries") );
+ recentFile->setEnabled( false );
+ }
+
+ // link to another cell
+ d->cellPage = addPage( i18n( "Cell" ), QString::null,
+ BarIcon( "misc",KIcon::SizeMedium ) );
+ QVBoxLayout* cLayout = new QVBoxLayout( d->cellPage, marginHint(), spacingHint() );
+ cLayout->add( new QLabel( i18n("Text to display:" ), d->cellPage ) );
+ d->cellText = new KLineEdit( d->cellPage );
+ cLayout->add( d->cellText );
+ cLayout->add( new QLabel( i18n("Cell:" ), d->cellPage ) );
+ d->cellLink = new KLineEdit( d->cellPage );
+ cLayout->add( d->cellLink );
+ cLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
+ connect( d->cellText, SIGNAL( textChanged( const QString& ) ), this,
+ SLOT( setText( const QString& ) ) );
+
+ enableButtonSeparator( true );
+ d->internetText->setFocus();
+ resize( 400,300 );
+}
+
+LinkDialog::~LinkDialog()
+{
+ delete d;
+}
+
+QString LinkDialog::text() const
+{
+ return d->text;
+}
+
+QString LinkDialog::link() const
+{
+ QString str;
+ switch( activePageIndex() )
+ {
+ case 0:
+ str = d->internetLink->text();
+ if( !str.isEmpty() )
+ if( str.find( "http://" )==-1 )
+ if( str.find( "https://" )==-1 )
+ if( str.find( "ftp://" )==-1 )
+ str.prepend( "http://" );
+ break;
+
+ case 1:
+ str = d->mailLink->text();
+ if( !str.isEmpty() )
+ if( str.find( "mailto:" )==-1 )
+ str.prepend( "mailto:" );
+ break;
+
+ case 2:
+ str = d->fileLink->lineEdit()->text();
+ if( !str.isEmpty() )
+ if( str.find( "file:/" )==-1 )
+ str.prepend( "file://" );
+ break;
+
+ case 3:
+ str = d->cellLink->text();
+ break;
+
+ break;
+ }
+ return str;
+}
+
+void LinkDialog::setText( const QString& text )
+{
+ d->text = text;
+
+ d->internetText->blockSignals( true );
+ d->internetText->setText( text );
+ d->internetText->blockSignals( false );
+
+ d->mailText->blockSignals( true );
+ d->mailText->setText( text );
+ d->mailText->blockSignals( false );
+
+ d->fileText->blockSignals( true );
+ d->fileText->setText( text );
+ d->fileText->blockSignals( false );
+
+ d->cellText->blockSignals( true );
+ d->cellText->setText( text );
+ d->cellText->blockSignals( false );
+}
+
+// link must be complete, e.g. "http://www.koffice.org" instead of
+// "www.koffice.org" only, since protocol is used to decide which page to show
+void LinkDialog::setLink( const QString& link )
+{
+ if( link.startsWith( "https://" ) )
+ {
+ d->internetLink->setText( link.mid( QString("https://").length() ) );
+ showPage( 0 );
+ return;
+ }
+
+ if( link.startsWith( "http://" ) )
+ {
+ d->internetLink->setText( link.mid( QString("http://").length() ) );
+ showPage( 0 );
+ return;
+ }
+
+ if( link.startsWith( "ftp://" ) )
+ {
+ d->internetLink->setText( link.mid( QString("ftp://").length() ) );
+ showPage( 0 );
+ return;
+ }
+
+ if( link.startsWith( "mailto:" ) )
+ {
+ d->mailLink->setText( link.mid( QString("mailto:").length() ) );
+ showPage( 1 );
+ return;
+ }
+
+ if( link.startsWith( "file:/" ) )
+ {
+ QString s = link.mid( QString("file:/").length() );
+ while(s.startsWith("//")) s.remove(0,1);
+ d->fileLink->lineEdit()->setText(s);
+ showPage( 2 );
+ return;
+ }
+
+ // assume cell reference
+ d->cellLink->setText( link );
+ showPage( 3 );
+}
+
+void LinkDialog::slotOk()
+{
+ QString str;
+ switch( activePageIndex() )
+ {
+ case 0: str = i18n( "Internet address is empty" ); break;
+ case 1: str = i18n( "Mail address is empty" ); break;
+ case 2: str = i18n( "File name is empty" ); break;
+ case 3: str = i18n( "Destination cell is empty" ); break;
+ break;
+ }
+
+ if( link().isEmpty() )
+ {
+ KMessageBox::error( this, str );
+ return;
+ }
+
+ if( d->text.isEmpty() )
+ d->text = link();
+
+ accept();
+}
+
+#include "link.moc"
diff --git a/kspread/dialogs/link.h b/kspread/dialogs/link.h
new file mode 100644
index 00000000..12d00973
--- /dev/null
+++ b/kspread/dialogs/link.h
@@ -0,0 +1,57 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Ariya Hidayat <ariya@kde.org>
+ (C) 2003 Norbert Andres <nandres@web.de>
+ (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
+ (C) 1999-2002 Laurent Montel <montel@kde.org>
+ (C) 1999 Stephan Kulow <coolo@kde.org>
+ (C) 1998-1999 Torben Weis <weis@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef LINK_DIALOG
+#define LINK_DIALOG
+
+#include <kdialogbase.h>
+
+namespace KSpread
+{
+
+class LinkDialog : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ LinkDialog( QWidget* parent, const char* name = 0 );
+ ~LinkDialog();
+ QString text() const;
+ QString link() const;
+
+public slots:
+ void setText( const QString& text );
+ void setLink( const QString& link );
+
+protected slots:
+ void slotOk();
+
+private:
+ class Private;
+ Private* d;
+};
+
+} // namepsace KSpread
+
+#endif /* LINK_DIALOG */
diff --git a/kspread/dialogs/position_cell_format.ui b/kspread/dialogs/position_cell_format.ui
new file mode 100644
index 00000000..eb3fb840
--- /dev/null
+++ b/kspread/dialogs/position_cell_format.ui
@@ -0,0 +1,411 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>PositionTab</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>PositionTab</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>349</width>
+ <height>337</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>7</number>
+ </property>
+ <widget class="QButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>horizontalGroup</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Horizontal</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;Set the content position horizontally in the cell.
+&lt;b&gt;Standard&lt;/b&gt; is default and is set from the format you choose.
+&lt;b&gt;Left&lt;/b&gt; means the content will be displayed on the left of the cell.
+&lt;b&gt;Center&lt;/b&gt; means the content will be in the center horizontally in the cell.
+&lt;b&gt;Right&lt;/b&gt; means the content of the cell will be displayed on the right of the cell.&lt;/qt&gt;</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>standard</cstring>
+ </property>
+ <property name="text">
+ <string>Standard</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>left</cstring>
+ </property>
+ <property name="text">
+ <string>Left</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>center</cstring>
+ </property>
+ <property name="text">
+ <string>Center</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>right</cstring>
+ </property>
+ <property name="text">
+ <string>Right</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QButtonGroup" row="0" column="1">
+ <property name="name">
+ <cstring>buttonGroup2</cstring>
+ </property>
+ <property name="title">
+ <string>Vertical</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;Set the content position vertically in the cell.
+&lt;b&gt;Top&lt;/b&gt; means the content will be displayed on top of the cell.
+&lt;b&gt;Middle&lt;/b&gt; means the content will be in the middle vertically in the cell.
+&lt;b&gt;Bottom&lt;/b&gt; means the content of the cell will be displayed at the bottom of the cell.&lt;/qt&gt;</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>top</cstring>
+ </property>
+ <property name="text">
+ <string>Top</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>middle</cstring>
+ </property>
+ <property name="text">
+ <string>Middle</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>bottom</cstring>
+ </property>
+ <property name="text">
+ <string>Bottom</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox" row="1" column="1">
+ <property name="name">
+ <cstring>groupBox4</cstring>
+ </property>
+ <property name="title">
+ <string>Rotation</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Your text will appear oriented in the angle you set here. Positive values will move it counter-clockwise and negative values will move it clockwise.</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QSlider">
+ <property name="name">
+ <cstring>angleRotation</cstring>
+ </property>
+ <property name="minValue">
+ <number>-90</number>
+ </property>
+ <property name="maxValue">
+ <number>90</number>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Below</enum>
+ </property>
+ <property name="tickInterval">
+ <number>15</number>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>spinBox3</cstring>
+ </property>
+ <property name="suffix">
+ <string>°</string>
+ </property>
+ <property name="maxValue">
+ <number>90</number>
+ </property>
+ <property name="minValue">
+ <number>-90</number>
+ </property>
+ <property name="lineStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>Text Option</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This is only available when the rotation is 0°.
+Wrap text wraps the text so it fits in the previous cell size. If this is not checked, the text will stay on one line and the cell size will be adjusted to contain the text.
+Vertical text puts your text vertically.</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>multi</cstring>
+ </property>
+ <property name="text">
+ <string>Wrap text</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>vertical</cstring>
+ </property>
+ <property name="text">
+ <string>Vertical text</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox" row="2" column="1">
+ <property name="name">
+ <cstring>indentGroup</cstring>
+ </property>
+ <property name="title">
+ <string>Indent</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Set the amount of indent that will be used in the cell when you choose the Format -&gt; Increase Indent or Format -&gt; Decrease Indent menus.</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="2" column="0">
+ <property name="name">
+ <cstring>groupBox5</cstring>
+ </property>
+ <property name="title">
+ <string>Merge Cells</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>When checked, this has the same effect as Data -&gt;Merge Cells. You need to have at least two consecutive cells selected. Those consecutive cells are then merged into a bigger one.
+When a merged cell is selected and when you uncheck this, then all cells come back to their original size as before the merging. It has the same effect as Data -&gt; Dissociate Cells.</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>mergeCell</cstring>
+ </property>
+ <property name="text">
+ <string>Merge cells</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox" row="3" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>sizeCellGroup</cstring>
+ </property>
+ <property name="title">
+ <string>Size of Cell</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The unit used here is the one set in Format -&gt; Page Layout.. dialog.</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="1">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>defaultHeight</cstring>
+ </property>
+ <property name="text">
+ <string>Default height (%1)</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If checked, the default height will be used for the cell instead of the value above.</string>
+ </property>
+ </widget>
+ <spacer row="0" column="2">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>10</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Height:</string>
+ </property>
+ </widget>
+ <widget class="QFrame" row="0" column="1">
+ <property name="name">
+ <cstring>m_heightPanel</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Set the height of the cell.</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>defaultWidth</cstring>
+ </property>
+ <property name="text">
+ <string>Default width (%1)</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If checked, the default width will be used for the cell instead of the value above.</string>
+ </property>
+ </widget>
+ <spacer row="0" column="2">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QFrame" row="0" column="1">
+ <property name="name">
+ <cstring>m_widthPanel</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ <property name="lineWidth">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Width:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>angleRotation</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>spinBox3</receiver>
+ <slot>setValue(int)</slot>
+ </connection>
+ <connection>
+ <sender>spinBox3</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>angleRotation</receiver>
+ <slot>setValue(int)</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kspread/dialogs/protection_cell_format.ui b/kspread/dialogs/protection_cell_format.ui
new file mode 100644
index 00000000..56b7352f
--- /dev/null
+++ b/kspread/dialogs/protection_cell_format.ui
@@ -0,0 +1,180 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>ProtectionTab</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ProtectionTab</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>250</width>
+ <height>187</height>
+ </rect>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This tab enables you to set Cell Protection. All cells are protected by default (that means cell content cannot be changed) and for the cell protection to be active you also need to protect the sheet using the Tools -&gt; Protect Document -&gt; Protect Sheet... menu and to provide a password.
+You can also hide the cell formula in order to protect the way you calculate the formula. This also needs to enable shet protection to work.
+You can hide the cell content with Hide all and again this needs sheet protection.
+You can learn more about all these settings in the User Manual in the Advanced KSpread chapter.</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Printing</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>m_bDontPrint</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Do not print text</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If checked, the content of the cell will not be printed. If this is not checked (default), the cell content will be printed.
+Note that you can print it even if the cell is protected</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Protection</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout12</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_bHideAll</cstring>
+ </property>
+ <property name="text">
+ <string>Hide &amp;all</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This hides the cell content and works only when the sheet is protected. Whether the cell itself is protected or not does not matter.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>30</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_bIsProtected</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Protected</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If checked, the cell content will be protected. This is the default behaviour. You need to protect the whole sheet using theTools-&gt;Protect document-&gt;Protect Sheet... menu for this individual cell protection to work. See the manual for more details in the Advanced KSpread chapter. When a cell is protected, its content cannot be changed.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout10</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>30</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_bHideFormula</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Hide formula</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>When this is checked, the cell is still visible. However, its contents do not appear in the Formula bar. Hiding formula is only working for cells that contain formulae so the user cannot view the formula. And the sheet must be protected for this to work.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>m_bHideAll</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_bIsProtected</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>m_bHideAll</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_bHideFormula</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kspread/dialogs/sheet_properties.cc b/kspread/dialogs/sheet_properties.cc
new file mode 100644
index 00000000..e7854935
--- /dev/null
+++ b/kspread/dialogs/sheet_properties.cc
@@ -0,0 +1,192 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Ariya Hidayat <ariya@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <qvbox.h>
+#include <qcheckbox.h>
+
+#include <kcombobox.h>
+#include <kdialogbase.h>
+#include <klocale.h>
+
+#include "kspread_sheet.h"
+#include "sheet_properties_base.h"
+
+#include "sheet_properties.h"
+
+using namespace KSpread;
+
+SheetPropertiesDialog::SheetPropertiesDialog( QWidget* parent ):
+ KDialogBase( parent, "sheetPropertiesDialog", true,
+ i18n("Sheet Properties"),
+ KDialogBase::Ok|KDialogBase::Cancel|KDialogBase::Default )
+{
+ QVBox* mainWidget = makeVBoxMainWidget();
+ d = new SheetPropertiesBase( mainWidget );
+ QWidget* spacer = new QWidget( mainWidget );
+ spacer->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
+ enableButtonSeparator( true );
+}
+
+SheetPropertiesDialog::~SheetPropertiesDialog()
+{
+ delete d;
+}
+
+void SheetPropertiesDialog::slotDefault()
+{
+ setLayoutDirection( Sheet::LeftToRight );
+ setAutoCalc( true );
+ setShowGrid( true );
+ setShowFormula( false );
+ setHideZero( false );
+ setShowFormulaIndicator( true );
+ setShowCommentIndicator( true );
+ setShowPageBorders( false );
+ setColumnAsNumber( false );
+ setLcMode( false );
+ setCapitalizeFirstLetter( false );
+}
+
+Sheet::LayoutDirection SheetPropertiesDialog::layoutDirection() const
+{
+ if( d->directionComboBox->currentText() == i18n( "Left to Right" ) )
+ return Sheet::LeftToRight;
+
+ if( d->directionComboBox->currentText() == i18n( "Right to Left" ) )
+ return Sheet::RightToLeft;
+
+ // fallback
+ return Sheet::LeftToRight;
+}
+
+void SheetPropertiesDialog::setLayoutDirection( Sheet::LayoutDirection dir )
+{
+ switch( dir )
+ {
+ case Sheet::LeftToRight:
+ d->directionComboBox->setCurrentText( i18n( "Left to Right" ) );
+ break;
+ case Sheet::RightToLeft:
+ d->directionComboBox->setCurrentText( i18n( "Right to Left" ) );
+ break;
+ default: break;
+ };
+}
+
+bool SheetPropertiesDialog::autoCalc() const
+{
+ return d->autoCalcCheckBox->isChecked();
+}
+
+void SheetPropertiesDialog::setAutoCalc( bool b )
+{
+ d->autoCalcCheckBox->setChecked( b );
+}
+
+bool SheetPropertiesDialog::showGrid() const
+{
+ return d->showGridCheckBox->isChecked();
+}
+
+void SheetPropertiesDialog::setShowGrid( bool b )
+{
+ d->showGridCheckBox->setChecked( b );
+}
+
+bool SheetPropertiesDialog::showPageBorders() const
+{
+ return d->showPageBordersCheckBox->isChecked();
+}
+
+void SheetPropertiesDialog::setShowPageBorders( bool b )
+{
+ d->showPageBordersCheckBox->setChecked( b );
+}
+
+bool SheetPropertiesDialog::showFormula() const
+{
+ return d->showFormulaCheckBox->isChecked();
+}
+
+void SheetPropertiesDialog::setShowFormula( bool b )
+{
+ d->showFormulaCheckBox->setChecked( b );
+}
+
+bool SheetPropertiesDialog::hideZero() const
+{
+ return d->hideZeroCheckBox->isChecked();
+}
+
+void SheetPropertiesDialog::setHideZero( bool b )
+{
+ d->hideZeroCheckBox->setChecked( b );
+}
+
+bool SheetPropertiesDialog::showFormulaIndicator() const
+{
+ return d->showFormulaIndicatorCheckBox->isChecked();
+}
+
+void SheetPropertiesDialog::setShowFormulaIndicator( bool b )
+{
+ d->showFormulaIndicatorCheckBox->setChecked( b );
+}
+
+bool SheetPropertiesDialog::showCommentIndicator() const
+{
+ return d->showCommentIndicatorCheckBox->isChecked();
+}
+
+void SheetPropertiesDialog::setShowCommentIndicator( bool b )
+{
+ d->showCommentIndicatorCheckBox->setChecked( b );
+}
+
+bool SheetPropertiesDialog::columnAsNumber() const
+{
+ return d->showColumnAsNumbersCheckBox->isChecked();
+}
+
+void SheetPropertiesDialog::setColumnAsNumber( bool b )
+{
+ d->showColumnAsNumbersCheckBox->setChecked( b );
+}
+
+bool SheetPropertiesDialog::lcMode() const
+{
+ return d->useLCModeCheckBox->isChecked();
+}
+
+void SheetPropertiesDialog::setLcMode( bool b )
+{
+ d->useLCModeCheckBox->setChecked( b );
+}
+
+bool SheetPropertiesDialog::capitalizeFirstLetter() const
+{
+ return d->capitalizeFirstLetterCheckBox->isChecked();
+}
+
+void SheetPropertiesDialog::setCapitalizeFirstLetter( bool b )
+{
+ d->capitalizeFirstLetterCheckBox->setChecked( b );
+}
+
+#include "sheet_properties.moc"
diff --git a/kspread/dialogs/sheet_properties.h b/kspread/dialogs/sheet_properties.h
new file mode 100644
index 00000000..ef20d75c
--- /dev/null
+++ b/kspread/dialogs/sheet_properties.h
@@ -0,0 +1,93 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Ariya Hidayat <ariya@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SHEET_PROPERTIES_DIALOG
+#define SHEET_PROPERTIES_DIALOG
+
+#include <qwidget.h>
+#include <kdialogbase.h>
+#include "kspread_sheet.h"
+
+namespace KSpread
+{
+class SheetPropertiesBase;
+
+class SheetPropertiesDialog : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+
+ SheetPropertiesDialog( QWidget* parent = 0 );
+
+ ~SheetPropertiesDialog();
+
+ virtual void slotDefault();
+
+ Sheet::LayoutDirection layoutDirection() const;
+
+ void setLayoutDirection( Sheet::LayoutDirection dir );
+
+ bool autoCalc() const;
+
+ void setAutoCalc( bool b );
+
+ bool showGrid() const;
+
+ void setShowGrid( bool b );
+
+ bool showPageBorders() const;
+
+ void setShowPageBorders( bool b );
+
+ bool showFormula() const;
+
+ void setShowFormula( bool b );
+
+ bool hideZero() const;
+
+ void setHideZero( bool b );
+
+ bool showFormulaIndicator() const;
+
+ void setShowFormulaIndicator( bool b );
+
+ bool showCommentIndicator() const;
+
+ void setShowCommentIndicator( bool b );
+
+ bool columnAsNumber() const;
+
+ void setColumnAsNumber( bool b );
+
+ bool lcMode() const;
+
+ void setLcMode( bool b );
+
+ bool capitalizeFirstLetter() const;
+
+ void setCapitalizeFirstLetter( bool b );
+
+private:
+ SheetPropertiesBase* d;
+};
+
+} // namespace
+
+#endif /* SHEET_PROPERTIES_DIALOG */
diff --git a/kspread/dialogs/sheet_properties_base.ui b/kspread/dialogs/sheet_properties_base.ui
new file mode 100644
index 00000000..588895fd
--- /dev/null
+++ b/kspread/dialogs/sheet_properties_base.ui
@@ -0,0 +1,258 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KSpread::SheetPropertiesBase</class>
+<comment>This file is part of the KDE project
+Copyright (C) 2004 Ariya Hidayat &lt;ariya@kde.org&gt;
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this library; see the file COPYING.LIB. If not,
+write to the Free Software Foundation, Inc., 51 Franklin Street,
+Fifth Floor, Boston, MA 02110-1301, USA.</comment>
+<author>Ariya Hidayat &lt;ariya@kde.org&gt;</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SheetPropertiesBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>408</width>
+ <height>206</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>SheetPropertiesBase</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Layout direction:</string>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <item>
+ <property name="text">
+ <string>Left to Right</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Right to Left</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>directionComboBox</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Defaut is that the first column of the sheet is on the left. If you choose Right to Left, then the first column will be on the right and the others added from right to left.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="4" column="1">
+ <property name="name">
+ <cstring>showCommentIndicatorCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Show c&amp;omment indicator</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If this box is checked cells containing comments will be marked by a small red triangle at the top right corner.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>useLCModeCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Use &amp;LC mode</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If this box is checked the cell reference shown at the left end of the Formula Bar will be displayed in LC mode (i.e. L2C3) rather than in its normal form B3. This does not seem to be of much use at the moment.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="1">
+ <property name="name">
+ <cstring>showPageBordersCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Show page &amp;borders</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If you check this option, the page borders will be drawn on your current sheet. Per default the page borders are not displayed. It is useful to see the page borders if you want to print your sheet.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="4" column="0">
+ <property name="name">
+ <cstring>capitalizeFirstLetterCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Convert first letter to uppercase</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Check this box and the first letter of any text you type in will automatically be converted to uppercase.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>hideZeroCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Hide zero</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If this box is checked any cell containing the value zero will appear blank.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="1">
+ <property name="name">
+ <cstring>showFormulaCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Show &amp;formula</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If this box is checked KSpread will display the actual formulae in cells rather than the results.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>showColumnAsNumbersCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Show column as &amp;numbers</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If this box is checked the column headings will show as numbers rather than as letters. Letters are default.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="1">
+ <property name="name">
+ <cstring>showFormulaIndicatorCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Show formula &amp;indicator</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If this box is checked KSpread will display a small blue triangle at the bottom left corner of cells containing formulae. This is useful if you want to protect cells with formulae.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="0" column="1">
+ <property name="name">
+ <cstring>showGridCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Show &amp;grid</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>If checked the grid (the cell limits) will be shown. This is default. If you uncheck it, the grid willl be hidden.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>autoCalcCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Automatic recalculation</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This setting controls whether formulae are recalculated automatically when the value of any cell they refer to changes.</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<includes>
+ <include location="global" impldecl="in implementation">kdialog.h</include>
+</includes>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>kcombobox.h</includehint>
+</includehints>
+</UI>