From a60a1a222ea3c46a9acd81fde4cf9404b948153e Mon Sep 17 00:00:00 2001 From: Uwe Fischer Date: Fri, 6 Nov 2009 16:56:13 +0100 Subject: hcshared25: #i105983#: changed help image --- default_images/res/helpimg/smzb8.png | Bin 1303 -> 1303 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/default_images/res/helpimg/smzb8.png b/default_images/res/helpimg/smzb8.png index 079697fd2a5b..eaf125a63f2b 100644 Binary files a/default_images/res/helpimg/smzb8.png and b/default_images/res/helpimg/smzb8.png differ -- cgit From c0ca967646933abbe6603810e52140a26f6caa2a Mon Sep 17 00:00:00 2001 From: Uwe Fischer Date: Fri, 20 Nov 2009 16:11:07 +0100 Subject: hcshared25: #i107086# removed one autocorr trigger ID --- .../registry/data/org/openoffice/Office/SFX.xcu | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/officecfg/registry/data/org/openoffice/Office/SFX.xcu b/officecfg/registry/data/org/openoffice/Office/SFX.xcu index 52b322c750a3..0c3027993498 100644 --- a/officecfg/registry/data/org/openoffice/Office/SFX.xcu +++ b/officecfg/registry/data/org/openoffice/Office/SFX.xcu @@ -33,27 +33,27 @@ - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 - 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34119,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 + 956368385,956368385,26220,26235,2567291937,2567291938,26272,26273,26063,957028378,26153,26312,958170133,958186547,958202951,26320,26321,956419588,956433419,26323,26324,20309,20308,20226,10371,27015,10087,10156,10350,27002,700810288,700810324,700730881,703778354,700777567,701124116,701124158,541248011,541249030,541249032,700763681,34023,957235721,3388501505,3388501506,3388501507,3388501508,3388501509,3388501510,10416,10297,5573,5573,5573,34099,34100,34101,34102,34104,34106,34107,34108,34109,34110,34112,34114,34115,34116,34117,34118,34120,33368,10296,54946 -- cgit From d9c5d33b37f86ec8a91afcb87a3628f7e0bfcba7 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 12 Feb 2010 16:51:46 +0100 Subject: recent changes for grid control --- offapi/com/sun/star/awt/grid/GridDataEvent.idl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/offapi/com/sun/star/awt/grid/GridDataEvent.idl b/offapi/com/sun/star/awt/grid/GridDataEvent.idl index a4ff1a58d5c7..c280f30e0ba6 100644 --- a/offapi/com/sun/star/awt/grid/GridDataEvent.idl +++ b/offapi/com/sun/star/awt/grid/GridDataEvent.idl @@ -30,10 +30,7 @@ #ifndef __com_sun_star_awt_grid_GridDataEvent_idl__ #define __com_sun_star_awt_grid_GridDataEvent_idl__ -#ifndef __com_sun_star_lang_EventObject_idl__ #include -#endif - //============================================================================= @@ -70,7 +67,7 @@ struct GridDataEvent: com::sun::star::lang::EventObject string headerName; /** Contains the changed row**/ - sequence rowData; + sequence rowData; }; -- cgit From 052bc00a2ed9efd87a0176e19c369629472060af Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 12 Feb 2010 16:52:56 +0100 Subject: recent changes for grid control --- .../sun/star/awt/grid/GridInvalidDataException.idl | 56 +++++++++++++++++++ .../star/awt/grid/GridInvalidModelException.idl | 56 +++++++++++++++++++ .../com/sun/star/awt/grid/UnoControlGridModel.idl | 62 ++++++++++++++++++++++ offapi/com/sun/star/awt/grid/XGridColumn.idl | 23 ++++++-- offapi/com/sun/star/awt/grid/XGridColumnModel.idl | 12 ++++- offapi/com/sun/star/awt/grid/XGridControl.idl | 19 +++---- offapi/com/sun/star/awt/grid/XGridDataModel.idl | 10 ++-- offapi/com/sun/star/awt/grid/makefile.mk | 4 +- 8 files changed, 223 insertions(+), 19 deletions(-) create mode 100644 offapi/com/sun/star/awt/grid/GridInvalidDataException.idl create mode 100644 offapi/com/sun/star/awt/grid/GridInvalidModelException.idl diff --git a/offapi/com/sun/star/awt/grid/GridInvalidDataException.idl b/offapi/com/sun/star/awt/grid/GridInvalidDataException.idl new file mode 100644 index 000000000000..499da967c3f1 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/GridInvalidDataException.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ExpandVetoException.idl,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_GridInvalidDataException_idl__ +#define __com_sun_star_awt_grid_GridInvalidDataException_idl__ + +#ifndef __com_sun_star_uno_RuntimeException_idl__ +#include +#endif + + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** Exception is thrown to indicate that set data is invalid, e.g. type of data is unknown + or data count doesn't match with column count. + */ +exception GridInvalidDataException : com::sun::star::uno::RuntimeException +{ + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/GridInvalidModelException.idl b/offapi/com/sun/star/awt/grid/GridInvalidModelException.idl new file mode 100644 index 000000000000..2f0d36bdb495 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/GridInvalidModelException.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ExpandVetoException.idl,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_GridInvalidModelException_idl__ +#define __com_sun_star_awt_grid_GridInvalidModelException_idl__ + +#ifndef __com_sun_star_uno_RuntimeException_idl__ +#include +#endif + + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** Exception is thrown when data or column model isn't set. + */ +exception GridInvalidModelException : com::sun::star::uno::RuntimeException +{ + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif + \ No newline at end of file diff --git a/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl b/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl index eabe7515fb5c..97238f8a163b 100644 --- a/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl +++ b/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl @@ -40,6 +40,12 @@ #include +#include + +#include + +#include + //============================================================================= module com { module sun { module star { module awt { module grid { @@ -87,10 +93,66 @@ service UnoControlGridModel */ [property] boolean VScroll; + /** Specifies that the control can be reached with the TAB key. + */ + [property] boolean Tabstop; + /** Specifies the selection mode that is enabled for this grid control.

The default value is SelectionType::SINGLE

*/ [property] ::com::sun::star::view::SelectionType SelectionModel; + /** Specifies the background color of odd rows. If color for even rows isn't set, then specifies + the color of all rows. Default value is white. + */ + [property] ::com::sun::star::util::Color BackgroundColor; + + /** Specifies the background color of even rows. Default value is white. + */ + [property] ::com::sun::star::util::Color EvenRowBackgroundColor; + + /** Specifies the background color of header. Default value is white. + */ + [property] ::com::sun::star::util::Color HeaderBackgroundColor; + + /** Specifies the text color. Default value is black. + */ + [property] ::com::sun::star::util::Color TextColor; + + /** Specifies the line color. Default value is white. + */ + [property] ::com::sun::star::util::Color LineColor; + + /** specifies the vertical alignment of the content in the control. + +
+            TOP
+            MIDDLE
+            BOTTOM
+        
+ */ + [property] com::sun::star::style::VerticalAlignment VerticalAlign; + + /** specifies the font attributes of the text in the control. + */ + [property] com::sun::star::awt::FontDescriptor FontDescriptor; + + /** specifies the FontEmphasis + value of the text in the control. + */ + [property] short FontEmphasisMark; + + /** specifies the FontRelief + value of the text in the control. + */ + [property] short FontRelief; + + /** specifies the help text of the control. + */ + [property] string HelpText; + + /** specifies the help URL of the control. + */ + [property] string HelpURL; }; diff --git a/offapi/com/sun/star/awt/grid/XGridColumn.idl b/offapi/com/sun/star/awt/grid/XGridColumn.idl index 741af231ed03..45dcc258fb08 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumn.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumn.idl @@ -33,6 +33,8 @@ #ifndef __com_sun_star_uno_XInterface_idl__ #include #endif +#include + //============================================================================= @@ -49,20 +51,31 @@ interface XGridColumn: com::sun::star::uno::XInterface /** Specifies the default column witdth. **/ [attribute] long ColumnWidth; - /* + + /** Specifies the preferred column witdth. **/ [attribute] long PreferredWidth; + /** Specifies the min column witdth. **/ [attribute] long MinWidth; + /** Specifies the max column witdth. **/ [attribute] long MaxWidth; - [attribute] boolean Resizable; - */ + /** Specifies whether column has fixed size or not. **/ + [attribute] boolean Resizeable; - /** A title is displayed in the colum header row if UnoControlGridModel::ShowRowHeader is set to **/ - [attribute] string Title; + /** Specifies the horizontal alignment of the content in the control. +
+            LEFT
+            CENTER
+            RIGHT
+        
+ */ + [attribute] ::com::sun::star::style::HorizontalAlignment HorizontalAlign; + /** A title is displayed in the colum header row if UnoControlGridModel::ShowRowHeader is set to **/ + [attribute] string Title; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/XGridColumnModel.idl b/offapi/com/sun/star/awt/grid/XGridColumnModel.idl index f4cf2a7a3694..fad0ce190d69 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumnModel.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumnModel.idl @@ -52,6 +52,10 @@ interface XGridColumnModel: com::sun::star::uno::XInterface */ [attribute] boolean ColumnSelectionAllowed; + /**Specifies the height of column header. + */ + [attribute] long ColumnHeaderHeight; + /** Returns the number of columns. @returns the number of columns. @@ -84,12 +88,18 @@ interface XGridColumnModel: com::sun::star::uno::XInterface /** Returns a specific column. @param index - the position of the reuquested column. + the position of the requested column. @returns the requested column. */ XGridColumn getColumn( [in] long index); + /** Sets default columns to the column model. + @param elements + the number of default columns that should be set. + */ + void setDefaultColumns([in] long elements); + /* long getTotalColumnWidth(); */ diff --git a/offapi/com/sun/star/awt/grid/XGridControl.idl b/offapi/com/sun/star/awt/grid/XGridControl.idl index fc7c23c720a1..7fe015925213 100644 --- a/offapi/com/sun/star/awt/grid/XGridControl.idl +++ b/offapi/com/sun/star/awt/grid/XGridControl.idl @@ -47,20 +47,21 @@ module com { module sun { module star { module awt { module grid { */ interface XGridControl: XGridSelection { - /** Specifies the XGridColumnModel of the control. - */ - [attribute] XGridColumnModel ColumnModel; - - /** Specifies the XGridDataModel of the control. - */ - [attribute] XGridDataModel DataModel; - - /** Converting */ long getItemIndexAtPoint( [in] long x, [in] long y); + /** Sets tooltip for row + @param textForTooltip + text, which will be shown as tooltip. + If only cell content should be displayed, leave sequence empty. + @param columnsForTooltip + column numbers, which define the cell content that should be shown in the tooltip. + If only text should be shown, leave this sequence empty. + */ + void setToolTip( [in] sequence< string > textForTooltip, [in] sequence< long > columnsForTooltip); + /** registers a listener for mouse events. */ //[oneway] void addMouseListener( [in] com::sun::star::awt::XMouseListener listener ); diff --git a/offapi/com/sun/star/awt/grid/XGridDataModel.idl b/offapi/com/sun/star/awt/grid/XGridDataModel.idl index 17e224fa6b41..ba00552db37b 100644 --- a/offapi/com/sun/star/awt/grid/XGridDataModel.idl +++ b/offapi/com/sun/star/awt/grid/XGridDataModel.idl @@ -1,5 +1,6 @@ /************************************************************************* * + * $Revision: 1.8 $ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2008 by Sun Microsystems, Inc. @@ -7,7 +8,6 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: XListBox.idl,v $ - * $Revision: 1.8 $ * * This file is part of OpenOffice.org. * @@ -57,7 +57,11 @@ interface XGridDataModel: ::com::sun::star::lang::XComponent /** Returns the content of each row. */ - [attribute,readonly] sequence< sequence< string > > Data; + [attribute,readonly] sequence< sequence< any > > Data; + + /**Specifies the width of row header. + */ + [attribute] long RowHeaderWidth; /** Returns the number of rows in in the model. @returns @@ -72,7 +76,7 @@ interface XGridDataModel: ::com::sun::star::lang::XComponent @param data the content of the row. */ - void addRow( [in] string headername, [in] sequence< string > data ); + void addRow( [in] string headername, [in] sequence< any > data ); /** Removes a row from the model. diff --git a/offapi/com/sun/star/awt/grid/makefile.mk b/offapi/com/sun/star/awt/grid/makefile.mk index 124ca44edd09..9f6e5f25291c 100644 --- a/offapi/com/sun/star/awt/grid/makefile.mk +++ b/offapi/com/sun/star/awt/grid/makefile.mk @@ -61,7 +61,9 @@ IDLFILES=\ ScrollBarMode.idl\ XGridControl.idl\ UnoControlGrid.idl\ - UnoControlGridModel.idl + UnoControlGridModel.idl\ + GridInvalidDataException.idl\ + GridInvalidModelException.idl # ------------------------------------------------------------------ .INCLUDE : target.mk -- cgit From f3f5684a87eec71e31151d0c17e73a16a593d71c Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 12 Feb 2010 17:05:02 +0100 Subject: recent changes for grid control --- toolkit/inc/toolkit/helper/property.hxx | 3 + .../controls/grid/defaultgridcolumnmodel.cxx | 35 ++++++++-- .../controls/grid/defaultgridcolumnmodel.hxx | 17 +++-- .../source/controls/grid/defaultgriddatamodel.cxx | 80 +++++++++++++++------- .../source/controls/grid/defaultgriddatamodel.hxx | 21 +++--- toolkit/source/controls/grid/gridcolumn.cxx | 67 ++++++++++++++++++ toolkit/source/controls/grid/gridcolumn.hxx | 17 ++++- toolkit/source/controls/grid/gridcontrol.cxx | 53 ++++++-------- toolkit/source/controls/grid/gridcontrol.hxx | 9 ++- toolkit/source/helper/property.cxx | 5 +- 10 files changed, 222 insertions(+), 85 deletions(-) diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index f82df1f5b53f..6fa223cc7b26 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -198,6 +198,9 @@ namespace rtl { #define BASEPROPERTY_GRID_SELECTIONMODE 144 #define BASEPROPERTY_ENABLEVISIBLE 145 // sal_Bool #define BASEPROPERTY_REFERENCE_DEVICE 146 +#define BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND 147 +#define BASEPROPERTY_GRID_HEADER_BACKGROUND 148 +#define BASEPROPERTY_GRID_LINE_COLOR 149 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen. diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index bdd7fb475afe..337076bdfaa9 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -41,7 +41,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; - +using namespace ::com::sun::star::style; #define COLUMNSELECTIONALLOWED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnSelectionAllowed" )) namespace toolkit @@ -51,8 +51,10 @@ namespace toolkit // class DefaultGridColumnModel /////////////////////////////////////////////////////////////////////// -DefaultGridColumnModel::DefaultGridColumnModel() +DefaultGridColumnModel::DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory) : columns(std::vector< Reference< XGridColumn > >()) + ,m_nColumnHeaderHeight(10) + ,m_xFactory(xFactory) { } @@ -107,7 +109,7 @@ void DefaultGridColumnModel::broadcast_remove( sal_Int32 index, const ::com::sun { Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn ); - broadcast( column_changed, aEvent); + broadcast( column_removed, aEvent); } //--------------------------------------------------------------------- @@ -141,7 +143,6 @@ void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); columns.push_back(column); - sal_Int32 index = columns.size() - 1; broadcast_add(index, column ); return index; @@ -163,7 +164,7 @@ void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value else return Reference< XGridColumn >(); } - +//--------------------------------------------------------------------- void SAL_CALL DefaultGridColumnModel::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) { BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener ); @@ -176,6 +177,26 @@ void SAL_CALL DefaultGridColumnModel::removeColumnListener( const Reference< XGr BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener ); } +//--------------------------------------------------------------------- +void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) +{ + m_nColumnHeaderHeight = _value; +} +//--------------------------------------------------------------------- +sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnHeaderHeight() throw (::com::sun::star::uno::RuntimeException) +{ + return m_nColumnHeaderHeight; +} + +//--------------------------------------------------------------------- +void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + Reference xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY ); + for(sal_Int32 i=0;i SAL_CALL DefaultGridColumnModel_CreateInstance( const Reference< XMultiServiceFactory >& ) +Reference< XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const Reference< XMultiServiceFactory >& _rFactory) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel ); + return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel( _rFactory ) ); } diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx index b230188f9107..d700a6b07b5d 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx @@ -41,6 +41,8 @@ #include #include #include +#include +#include using ::rtl::OUString; using namespace ::com::sun::star; @@ -58,7 +60,7 @@ class DefaultGridColumnModel : public ::cppu::WeakImplHelper2< XGridColumnModel, public MutexAndBroadcastHelper { public: - DefaultGridColumnModel(); + DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory); virtual ~DefaultGridColumnModel(); // XGridColumnModel @@ -71,17 +73,18 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); - + virtual void SAL_CALL setColumnHeaderHeight( sal_Int32 _value) throw (com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnHeaderHeight() throw (com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException); // XComponent virtual void SAL_CALL dispose( ) throw (RuntimeException); virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException); // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); - virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); - + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); private: void broadcast( broadcast_type eType, const GridColumnEvent& aEvent ); @@ -91,6 +94,8 @@ private: std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > columns; sal_Bool selectionAllowed; + sal_Int32 m_nColumnHeaderHeight; + Reference< XMultiServiceFactory > m_xFactory; }; } diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 865be80f55a7..c564618336af 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -6,7 +6,7 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: treedatamodel.cxx,v $ + * $RCSfile: defaultgriddatamodel.cxx,v $ * $Revision: 1.4 $ * * This file is part of OpenOffice.org. @@ -30,17 +30,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" -#include "defaultgriddatamodel.hxx" +#include "DefaultGridDataModel.hxx" #include #include #include +#include +#include + using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; +//using namespace ::com::sun::star::style; #define ROWHEIGHT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeight" )) #define ROWHEADERS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaders" )) @@ -53,8 +57,9 @@ namespace toolkit /////////////////////////////////////////////////////////////////////// DefaultGridDataModel::DefaultGridDataModel() -: rowHeight(0), - rowHeaders(std::vector< ::rtl::OUString >()) +: rowHeight(10), + rowHeaders(std::vector< ::rtl::OUString >()), + m_nRowHeaderWidth(7) { } @@ -64,7 +69,7 @@ DefaultGridDataModel::~DefaultGridDataModel() { } -void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& aEvent ) +void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException) { ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridDataListener::static_type() ); if( pIter ) @@ -85,25 +90,28 @@ void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& //--------------------------------------------------------------------- -void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue ) +void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue ) throw (::com::sun::star::uno::RuntimeException) { Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, name, oldValue, newValue, 0, ::rtl::OUString(), Sequence< ::rtl::OUString>() ); + GridDataEvent aEvent( xSource, name, oldValue, newValue, 0, ::rtl::OUString(), + Sequence< Any >() ); broadcast( data_changed, aEvent); } //--------------------------------------------------------------------- -void DefaultGridDataModel::broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rowData ) +void DefaultGridDataModel::broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, + ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException) { Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, rowData ); + GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, (const ::com::sun::star::uno::Sequence< Any >&)rowData ); broadcast( row_added, aEvent); } //--------------------------------------------------------------------- -void DefaultGridDataModel::broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rowData ) +void DefaultGridDataModel::broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, + ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException) { Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, rowData ); @@ -168,19 +176,33 @@ void SAL_CALL DefaultGridDataModel::setRowHeaders(const ::com::sun::star::uno::S //--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rRowdata) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL DefaultGridDataModel::addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & rRowdata) throw (::com::sun::star::uno::RuntimeException) { // store header name rowHeaders.push_back(headername); - // store row data - std::vector< rtl::OUString > newRow( - comphelper::sequenceToContainer< std::vector >(rRowdata)); + std::vector< Any > newRow; + for ( int i = 0; i < rRowdata.getLength();i++) + { + //OUString title(rRowdata[i]); + + // create and use interal a UnoControlFixedText for text content + //Reference< XFixedText > xFixedText( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.UnoControlFixedText" ) ), UNO_QUERY_THROW ); + //Reference< XControl > xFixedTextControl( xFixedText , UNO_QUERY ); + // + //Reference< XControlModel > xFixedTextModel( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.UnoControlFixedTextModel" ) ), UNO_QUERY ); + //Reference< ::com::sun::star::beans::XPropertySet > xFixedTextModelPropSet( xFixedTextModel, UNO_QUERY ); + //xFixedTextModelPropSet->setPropertyValue( OUString::createFromAscii( "Label"), makeAny( title ) ); + + //xFixedTextControl->setModel( xFixedTextModel ); + + newRow.push_back(rRowdata[i]); + } data.push_back( newRow ); - broadcast_add( data.size()-1, headername, rRowdata); + broadcast_add( data.size()-1, headername, comphelper::containerToSequence(newRow)); } @@ -199,7 +221,7 @@ void SAL_CALL DefaultGridDataModel::removeRow(::sal_Int32 index) throw (::com::s ::rtl::OUString headerName( (::rtl::OUString) rowHeaders[index] ); rowHeaders.erase(rowHeaders.begin() + index); - Sequence< ::rtl::OUString >& rowData ( (Sequence< ::rtl::OUString >&)data[index] ); + Sequence< Any >& rowData ( (Sequence< Any >&)data[index] ); data.erase(data.begin() + index); broadcast_remove( index, headerName, rowData); } @@ -207,19 +229,19 @@ void SAL_CALL DefaultGridDataModel::removeRow(::sal_Int32 index) throw (::com::s return; } //--------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL DefaultGridDataModel::getData() throw (::com::sun::star::uno::RuntimeException) +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL DefaultGridDataModel::getData() throw (::com::sun::star::uno::RuntimeException) { - std::vector< std::vector< ::rtl::OUString > >::iterator iterator; - std::vector< Sequence< ::rtl::OUString > > dummyContainer(0); + std::vector< std::vector< Any > >::iterator iterator; + std::vector< Sequence< Any > > dummyContainer(0); for(iterator = data.begin(); iterator != data.end(); iterator++) { - Sequence< ::rtl::OUString > cols(comphelper::containerToSequence(*iterator)); + Sequence< Any > cols(comphelper::containerToSequence(*iterator)); dummyContainer.push_back( cols ); } - Sequence< Sequence< ::rtl::OUString > > dataSequence(comphelper::containerToSequence(dummyContainer)); + Sequence< Sequence< Any > > dataSequence(comphelper::containerToSequence(dummyContainer)); return dataSequence; } @@ -237,14 +259,23 @@ void SAL_CALL DefaultGridDataModel::removeDataListener( const Reference< XGridDa { BrdcstHelper.removeListener( XGridDataListener::static_type(), xListener ); } - +//--------------------------------------------------------------------- void SAL_CALL DefaultGridDataModel::removeAll() throw (RuntimeException) { rowHeaders.clear(); data.clear(); broadcast_remove( -1, ::rtl::OUString(), 0); } - +//--------------------------------------------------------------------- +void SAL_CALL DefaultGridDataModel::setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) +{ + m_nRowHeaderWidth = _value; +} +//--------------------------------------------------------------------- +sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException) +{ + return m_nRowHeaderWidth; +} //--------------------------------------------------------------------- // XComponent //--------------------------------------------------------------------- @@ -305,6 +336,5 @@ sal_Bool SAL_CALL DefaultGridDataModel::supportsService( const ::rtl::OUString& Reference< XInterface > SAL_CALL DefaultGridDataModel_CreateInstance( const Reference< XMultiServiceFactory >& ) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridDataModel ); + return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridDataModel() ); } - diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index 18000c9f5a71..e2cd50389698 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -6,7 +6,7 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: griddatamodel.hxx,v $ + * $RCSfile: defaultgriddatamodel.hxx,v $ * $Revision: 1.4 $ * * This file is part of OpenOffice.org. @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -67,13 +68,14 @@ public: virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowHeaders() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & value) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getData() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & data) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL getData() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & data) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL removeDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL removeAll() throw (RuntimeException); - + virtual void SAL_CALL setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException); // XComponent virtual void SAL_CALL dispose( ) throw (RuntimeException); virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); @@ -86,14 +88,15 @@ public: private: - void broadcast( broadcast_type eType, const GridDataEvent& aEvent ); - void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue ); - void broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rowData ); - void broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rowData ); + void broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); + void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue ) throw (::com::sun::star::uno::RuntimeException); + void broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); + void broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); sal_Int32 rowHeight; - std::vector< std::vector < ::rtl::OUString > > data; + std::vector< std::vector < Any > > data; std::vector< ::rtl::OUString > rowHeaders; + sal_Int32 m_nRowHeaderWidth; }; } diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 8b398b4aed58..e8dadc527fbd 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -41,6 +41,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::style; namespace toolkit { @@ -51,6 +52,9 @@ namespace toolkit GridColumn::GridColumn() : identifier(Any()) +,horizontalAlign(HorizontalAlignment(0)) +,columnWidth(4) +,bResizeable(true) { } @@ -91,6 +95,45 @@ void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::s { columnWidth = value; } +//-------------------------------------------------------------------- + +::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException) +{ + return preferredWidth; +} + +//-------------------------------------------------------------------- + +void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) +{ + preferredWidth = value; +} +//-------------------------------------------------------------------- + +::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException) +{ + return maxWidth; +} + +//-------------------------------------------------------------------- + +void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) +{ + maxWidth = value; +} +//-------------------------------------------------------------------- + +::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException) +{ + return minWidth; +} + +//-------------------------------------------------------------------- + +void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) +{ + minWidth = value; +} //-------------------------------------------------------------------- @@ -105,6 +148,30 @@ void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com:: { title = value; } +//-------------------------------------------------------------------- + +sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException) +{ + return bResizeable; +} + +//-------------------------------------------------------------------- + +void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) +{ + bResizeable = value; +} +//--------------------------------------------------------------------- +HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() +{ + return horizontalAlign; +} +//--------------------------------------------------------------------- + +void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) +{ + horizontalAlign = align; +} //--------------------------------------------------------------------- // XComponent diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index a451054ce93f..a458a07ffda8 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -39,6 +39,7 @@ #include #include #include +#include using ::rtl::OUString; using namespace ::com::sun::star; @@ -62,9 +63,18 @@ public: virtual void SAL_CALL setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnWidth() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setColumnWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getPreferredWidth() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPreferredWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getMaxWidth() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMaxWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getMinWidth() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMinWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getResizeable() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setResizeable(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); - + virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException); // XComponent virtual void SAL_CALL dispose( ) throw (RuntimeException); virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); @@ -79,7 +89,12 @@ public: private: Any identifier; sal_Int32 columnWidth; + sal_Int32 preferredWidth; + sal_Int32 maxWidth; + sal_Int32 minWidth; + sal_Bool bResizeable; ::rtl::OUString title; + ::com::sun::star::style::HorizontalAlignment horizontalAlign; }; } diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index c642d8a0dcce..fa0c3de3adb3 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -71,11 +72,20 @@ UnoGridModel::UnoGridModel() ImplRegisterProperty( BASEPROPERTY_SIZEABLE ); // resizeable ImplRegisterProperty( BASEPROPERTY_HSCROLL ); ImplRegisterProperty( BASEPROPERTY_VSCROLL ); + ImplRegisterProperty( BASEPROPERTY_TABSTOP ); ImplRegisterProperty( BASEPROPERTY_GRID_SHOWROWHEADER ); ImplRegisterProperty( BASEPROPERTY_GRID_SHOWCOLUMNHEADER ); ImplRegisterProperty( BASEPROPERTY_GRID_DATAMODEL ); ImplRegisterProperty( BASEPROPERTY_GRID_COLUMNMODEL ); ImplRegisterProperty( BASEPROPERTY_GRID_SELECTIONMODE ); + ImplRegisterProperty( BASEPROPERTY_FONTRELIEF ); + ImplRegisterProperty( BASEPROPERTY_FONTEMPHASISMARK ); + ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR ); + ImplRegisterProperty( BASEPROPERTY_TEXTCOLOR ); + ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN ); + ImplRegisterProperty( BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND ); + ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_BACKGROUND ); + ImplRegisterProperty( BASEPROPERTY_GRID_LINE_COLOR ); } @@ -152,50 +162,31 @@ void UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolk Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW ); Reference xListener ( getPeer(), UNO_QUERY_THROW ); + //Reference xColListener ( getPeer(), UNO_QUERY_THROW ); Reference xPropSet ( getModel(), UNO_QUERY_THROW ); Reference xGridDataModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "GridDataModel" )), UNO_QUERY_THROW ); - xGridDataModel->addDataListener(xListener); + if(xGridDataModel != NULL) + xGridDataModel->addDataListener(xListener); + //Reference xGridColumnModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "ColumnModel" )), UNO_QUERY_THROW ); + //if(xGridColumnModel != NULL) + // xGridColumnModel->addColumnListener(xColListener); } // ------------------------------------------------------------------- // XGridControl -// ------------------------------------------------------------------- - -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL UnoGridControl::getColumnModel() throw (::com::sun::star::uno::RuntimeException) -{ - Reference xPropSet ( getModel(), UNO_QUERY_THROW ); - Reference xGridColumnModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "ColumnModel" )), UNO_QUERY_THROW ); - - return xGridColumnModel; -} -void SAL_CALL UnoGridControl::setColumnModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > & model) throw (::com::sun::star::uno::RuntimeException) -{ - Reference xPropSet ( getModel(), UNO_QUERY_THROW ); - xPropSet->setPropertyValue(OUString::createFromAscii( "ColumnModel" ), Any (model)); -} - -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL UnoGridControl::getDataModel() throw (::com::sun::star::uno::RuntimeException) -{ - Reference xPropSet ( getModel(), UNO_QUERY_THROW ); - Reference xGridDataModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "GridDataModel" )), UNO_QUERY_THROW ); - - return xGridDataModel; -} - -void SAL_CALL UnoGridControl::setDataModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > & model) throw (::com::sun::star::uno::RuntimeException) +::sal_Int32 UnoGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { - Reference xPropSet ( getModel(), UNO_QUERY_THROW ); - xPropSet->setPropertyValue(OUString::createFromAscii( "GridDataModel" ), Any(model)); + Reference< XGridControl > xGrid ( getPeer(), UNO_QUERY_THROW ); + return xGrid->getItemIndexAtPoint( x, y ); } -::sal_Int32 UnoGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL UnoGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException) { - return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getItemIndexAtPoint( x, y ); + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->setToolTip( text, columns ); } - /* void SAL_CALL UnoGridControl::addMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException) { @@ -260,7 +251,7 @@ void SAL_CALL UnoGridControl::removeSelectionListener(const ::com::sun::star::un { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->removeSelectionListener( listener ); } -} +}//namespace toolkit Reference< XInterface > SAL_CALL GridControl_CreateInstance( const Reference< XMultiServiceFactory >& ) { diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index 5648c812fbff..8b219e70a0f2 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -33,10 +33,11 @@ #include #include -#include +#include #include #include #include +#include #include @@ -90,11 +91,9 @@ public: void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridControl - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL getColumnModel() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setColumnModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > & model) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL getDataModel() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setDataModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > & model) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException); //virtual void SAL_CALL addMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException); //virtual void SAL_CALL removeMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index a59af95a2e1f..9438cb93541b 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -283,7 +283,10 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_3 ( "ColumnModel", GRID_COLUMNMODEL, Reference< ::com::sun::star::awt::grid::XGridColumnModel >, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_3 ( "SelectionModel", GRID_SELECTIONMODE, ::com::sun::star::view::SelectionType, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_2 ( "EnableVisible", ENABLEVISIBLE, sal_Bool, BOUND, MAYBEDEFAULT ), - DECL_PROP_3 ( "ReferenceDevice", REFERENCE_DEVICE, Reference< XDevice >,BOUND, MAYBEDEFAULT, TRANSIENT ) + DECL_PROP_3 ( "ReferenceDevice", REFERENCE_DEVICE, Reference< XDevice >,BOUND, MAYBEDEFAULT, TRANSIENT ), + DECL_PROP_3 ( "EvenRowBackgroundColor", GRID_EVEN_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "HeaderBackgroundColor", GRID_HEADER_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "LineColor", GRID_LINE_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ) }; pPropertyInfos = aImplPropertyInfos; nElements = sizeof( aImplPropertyInfos ) / sizeof( ImplPropertyInfo ); -- cgit From 32a402c2d5d9519e1bd5c0c33b4a9b2696b8220a Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 12 Feb 2010 17:08:15 +0100 Subject: recent changes for grid control --- svtools/inc/svtools/accessibletable.hxx | 3 +- svtools/inc/svtools/table/abstracttablecontrol.hxx | 12 +- svtools/inc/svtools/table/defaultinputhandler.hxx | 1 + svtools/inc/svtools/table/gridtablerenderer.hxx | 6 +- svtools/inc/svtools/table/tablecontrol.hxx | 8 +- svtools/inc/svtools/table/tabledatawindow.hxx | 3 + svtools/inc/svtools/table/tablemodel.hxx | 65 +- svtools/inc/svtools/table/tablerenderer.hxx | 34 +- svtools/source/table/defaultinputhandler.cxx | 33 +- svtools/source/table/gridtablerenderer.cxx | 306 ++++++++-- svtools/source/table/tablecontrol.cxx | 98 +-- svtools/source/table/tablecontrol_impl.cxx | 658 +++++++++++++++++---- svtools/source/table/tablecontrol_impl.hxx | 19 +- svtools/source/table/tabledatawindow.cxx | 32 +- svtools/source/table/tablegeometry.cxx | 8 +- svtools/source/uno/svtxgridcontrol.cxx | 383 +++++++++--- svtools/source/uno/svtxgridcontrol.hxx | 7 +- svtools/source/uno/unocontroltablemodel.cxx | 250 +++++++- svtools/source/uno/unocontroltablemodel.hxx | 34 +- 19 files changed, 1568 insertions(+), 392 deletions(-) diff --git a/svtools/inc/svtools/accessibletable.hxx b/svtools/inc/svtools/accessibletable.hxx index 0e3f08bfc568..e13a0afe9469 100755 --- a/svtools/inc/svtools/accessibletable.hxx +++ b/svtools/inc/svtools/accessibletable.hxx @@ -34,6 +34,7 @@ #include #include #include +#include // ============================================================================ @@ -125,7 +126,7 @@ public: virtual ::rtl::OUString GetRowName(sal_Int32 _nIndex) const = 0; virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const = 0; virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const = 0; - virtual ::rtl::OUString GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0; + virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0; virtual std::vector& GetSelectedRows() = 0; }; diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx index 03bc0a999f7a..ba25152e34e2 100644 --- a/svtools/inc/svtools/table/abstracttablecontrol.hxx +++ b/svtools/inc/svtools/table/abstracttablecontrol.hxx @@ -29,6 +29,7 @@ #include #include #include +#include "tabletypes.hxx" //........................................................................ namespace svt { namespace table { @@ -111,14 +112,15 @@ namespace svt { namespace table @see TableControlAction */ virtual bool dispatchAction( TableControlAction _eAction ) = 0; - /** to be called on mouse button up/down - @return - if the click was in the visible area of the table control, - otherwise.*/ - virtual bool isClickInVisibleArea( const Point& _rPoint ) = 0; /** returns selection engine*/ virtual SelectionEngine* getSelEngine() = 0; + virtual void setCursorAtCurrentCell(const Point& rPoint) = 0; + virtual void setTooltip(const Point& rPoint ) = 0; + virtual RowPos getCurrentRow(const Point& rPoint ) = 0; + virtual void resizeColumn(const Point& rPoint ) = 0; + virtual bool startResizeColumn(const Point& rPoint) = 0; + virtual bool endResizeColumn(const Point& rPoint) = 0; virtual ~IAbstractTableControl() {}; }; diff --git a/svtools/inc/svtools/table/defaultinputhandler.hxx b/svtools/inc/svtools/table/defaultinputhandler.hxx index eb1c14b43a85..0cd4ba5ea7df 100644 --- a/svtools/inc/svtools/table/defaultinputhandler.hxx +++ b/svtools/inc/svtools/table/defaultinputhandler.hxx @@ -43,6 +43,7 @@ namespace svt { namespace table friend class TableDataWindow; private: DefaultInputHandler_Impl* m_pImpl; + bool m_bResize; public: DefaultInputHandler(); diff --git a/svtools/inc/svtools/table/gridtablerenderer.hxx b/svtools/inc/svtools/table/gridtablerenderer.hxx index a935f6b7386e..1facc75fecb7 100644 --- a/svtools/inc/svtools/table/gridtablerenderer.hxx +++ b/svtools/inc/svtools/table/gridtablerenderer.hxx @@ -89,7 +89,11 @@ namespace svt { namespace table bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText ); - virtual void PaintCell( ColPos _nColumn, + virtual void PaintCellImage( ColPos _nColumn, + bool _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle, Image* _pCellData ); + virtual void PaintCellString( ColPos _nColumn, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText ); diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index e3edd0b681ae..59720cfd0602 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -32,6 +32,7 @@ #include #include #include "svtaccessiblefactory.hxx" +#include //........................................................................ namespace svt { namespace table @@ -70,6 +71,8 @@ namespace svt { namespace table DECL_LINK( ImplMouseButtonUpHdl, MouseEvent* ); TableControl_Impl* m_pImpl; + ::com::sun::star::uno::Sequence< sal_Int32 >& m_nCols; + ::com::sun::star::uno::Sequence< ::rtl::OUString >& m_aText; public: ::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable; @@ -201,12 +204,15 @@ namespace svt { namespace table virtual ::rtl::OUString GetRowName(sal_Int32 _nIndex) const; virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const; virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const; - virtual ::rtl::OUString GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const; + virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const; virtual sal_Bool HasRowHeader(); virtual sal_Bool HasColHeader(); virtual sal_Bool isAccessibleAlive( ) const; virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue ); + ::com::sun::star::uno::Sequence< sal_Int32 >& getColumnsForTooltip(); + ::com::sun::star::uno::Sequence< ::rtl::OUString >& getTextForTooltip(); + void setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols); protected: /// retrieves the XAccessible implementation associated with the GridControl instance diff --git a/svtools/inc/svtools/table/tabledatawindow.hxx b/svtools/inc/svtools/table/tabledatawindow.hxx index fddbfdcd4a3c..564680a39347 100644 --- a/svtools/inc/svtools/table/tabledatawindow.hxx +++ b/svtools/inc/svtools/table/tabledatawindow.hxx @@ -66,6 +66,9 @@ namespace svt { namespace table virtual void MouseMove( const MouseEvent& rMEvt); virtual void MouseButtonDown( const MouseEvent& rMEvt); virtual void MouseButtonUp( const MouseEvent& rMEvt); + virtual void SetPointer( const Pointer& rPointer ); + virtual void CaptureMouse(); + virtual void ReleaseMouse(); }; //........................................................................ diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 6e74d35b8586..18d4db16c123 100644 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -29,10 +29,12 @@ #include #include #include - +#include #include - +#include #include +#include +#include //........................................................................ namespace svt { namespace table @@ -43,21 +45,16 @@ namespace svt { namespace table //==================================================================== //= cell data //==================================================================== - struct CellEntryType + struct TableContentType { - String m_aStr; - //Image m_aImage; - //Control m_aControl; - CellEntryType( const String& _rStr ) : - m_aStr( _rStr ) - {} + ::rtl::OUString sContent; + Image* pImage; + TableContentType() : + sContent(), + pImage( ) + { + } }; - - //typedef ::std::vector CellColumnContent; - //vector, which contains text data for each cell - typedef ::std::vector CellColumnContent; - //vector, which contains data for rows - typedef ::std::vector CellContent; //==================================================================== //= ScrollbarVisibility //==================================================================== @@ -284,7 +281,24 @@ namespace svt { namespace table */ virtual void setMaxWidth( TableMetrics _nMaxWidth ) = 0; + /** returns the preferred width of the column, or 0 if the column + does not have a preferred width. + + @see setMaxWidth + @see getMinWidth + @see getWidth + */ + virtual TableMetrics getPreferredWidth() const = 0; + /** sets the preferred width of the column, to be used when user resizes column + + @see getMaxWidth + @see setMinWidth + @see setWidth + */ + virtual void setPreferredWidth( TableMetrics _nPrefWidth ) = 0; + virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign() = 0; + virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign) = 0; /// deletes the column model instance virtual ~IColumnModel() { } }; @@ -429,19 +443,34 @@ namespace svt { namespace table */ virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const = 0; + virtual bool hasVerticalScrollbar() =0; + virtual bool hasHorizontalScrollbar() = 0; /** fills cells with content */ - virtual void setCellContent(std::vector > cellContent)=0; + virtual void setCellContent(std::vector< std::vector< ::com::sun::star::uno::Any > > cellContent)=0; /** gets the content of the cells */ - virtual std::vector >& getCellContent() = 0; + virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0; /**sets title of header rows */ - virtual void setRowHeaderName(std::vector cellColumnContent)=0; + virtual void setRowHeaderName(std::vector cellColumnContent)=0; /** gets title of header rows */ virtual std::vector& getRowHeaderName() = 0; + virtual ::com::sun::star::util::Color getLineColor() = 0; + virtual void setLineColor(::com::sun::star::util::Color _rColor) = 0; + virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0; + virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor) = 0; + virtual ::com::sun::star::util::Color getTextColor() = 0; + virtual void setTextColor(::com::sun::star::util::Color _rColor) = 0; + virtual ::com::sun::star::util::Color getOddRowBackgroundColor() = 0; + virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0; + virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() = 0; + virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0; + virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() = 0; + virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _xAlign) = 0; + /// destroys the table model instance virtual ~ITableModel() { } }; diff --git a/svtools/inc/svtools/table/tablerenderer.hxx b/svtools/inc/svtools/table/tablerenderer.hxx index eb645ad574c4..6f9e9d0865c6 100644 --- a/svtools/inc/svtools/table/tablerenderer.hxx +++ b/svtools/inc/svtools/table/tablerenderer.hxx @@ -187,6 +187,38 @@ namespace svt { namespace table The row to be painted is denoted by the most recent call to ->PrepareRow. + @param _bSelected + if and only if the cell to be painted is + selected currently. This is the case if either + the row or the column of the cell is currently selected. +
+ Note that this flag is equal to the respective flag in the + previous ->PrepareRow call, it's passed here for convinience + only. + @param _bActive + if the cell is currently active. +
+ Note that this flag is equal to the respective flag in the + previous ->PrepareRow call, it's passed here for convinience + only. + @param _rDevice + denotes the device to paint onto + @param _rArea + the are into which the cell should be painted + @param _rStyle + the style to be used for drawing + @param _pCellData + the content of the cell + */ + virtual void PaintCellImage( ColPos _nColumn, + bool _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle, Image* _pCellData ) = 0; + /** paints a certain cell + + The row to be painted is denoted by the most recent call to + ->PrepareRow. + @param _bSelected if and only if the cell to be painted is selected currently. This is the case if either @@ -210,7 +242,7 @@ namespace svt { namespace table @param _rText the content of the cell */ - virtual void PaintCell( ColPos _nColumn, + virtual void PaintCellString( ColPos _nColumn, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText ) = 0; diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx index 17ee0222857f..d85ab643bdb0 100644 --- a/svtools/source/table/defaultinputhandler.cxx +++ b/svtools/source/table/defaultinputhandler.cxx @@ -49,6 +49,7 @@ namespace svt { namespace table //-------------------------------------------------------------------- DefaultInputHandler::DefaultInputHandler() :m_pImpl( new DefaultInputHandler_Impl ) + ,m_bResize(false) { } @@ -61,8 +62,12 @@ namespace svt { namespace table //-------------------------------------------------------------------- bool DefaultInputHandler::MouseMove( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt ) { - (void)_rControl; - (void)_rMEvt; + Point aPoint = _rMEvt.GetPosPixel(); + if(m_bResize) + { + _rControl.resizeColumn(aPoint); + return true; + } return false; } @@ -71,7 +76,12 @@ namespace svt { namespace table { bool bHandled = false; Point aPoint = _rMEvt.GetPosPixel(); - if(_rControl.isClickInVisibleArea(aPoint)) + if(_rControl.getCurrentRow(aPoint) == -1) + { + m_bResize = _rControl.startResizeColumn(aPoint); + bHandled = true; + } + else if(_rControl.getCurrentRow(aPoint) >= 0) { if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION) { @@ -92,9 +102,14 @@ namespace svt { namespace table { bool bHandled = false; Point aPoint = _rMEvt.GetPosPixel(); - if(_rControl.isClickInVisibleArea(aPoint)) + if(_rControl.getCurrentRow(aPoint) >= 0) { - if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION) + if(m_bResize) + { + m_bResize = _rControl.endResizeColumn(aPoint); + bHandled = true; + } + else if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION) { GetFocus(_rControl); _rControl.setCursorAtCurrentCell(aPoint); @@ -103,6 +118,14 @@ namespace svt { namespace table else bHandled = _rControl.getSelEngine()->SelMouseButtonUp(_rMEvt); } + else + { + if(m_bResize) + { + m_bResize = _rControl.endResizeColumn(aPoint); + bHandled = true; + } + } return bHandled; } diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 2c4fda711009..7e721832c04c 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -30,6 +30,7 @@ #include #include +#include //........................................................................ namespace svt { namespace table @@ -78,14 +79,31 @@ namespace svt { namespace table "GridTableRenderer::PaintHeaderArea: invalid area flags!" ); // fill the rows with alternating background colors - _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR ); - - _rDevice.SetLineColor(); - _rDevice.SetFillColor( _rStyle.GetDialogColor() ); + _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); + //default background and line color is white + //background and lines should have same color, that's means lines aren't visible + //in case line color isn't set and background color is set, this should be changed + Color background = m_pImpl->rModel.getHeaderBackgroundColor(); + //Color background = _rStyle.GetBackgroundColor(); + Color line = m_pImpl->rModel.getLineColor(); + //default background and line color is white + //background and lines should have same color, that's means lines aren't visible + //in case line color isn't set and background color is set, this should be changed + if( background != 0xFFFFFF && line == 0xFFFFFF) + { + _rDevice.SetLineColor(background); + _rDevice.SetFillColor(background); + } + else + { + //if Line color is set, then it was user defined and should be visible + //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible + _rDevice.SetLineColor(line); + _rDevice.SetFillColor(background); + } _rDevice.DrawRect( _rArea ); // delimiter lines at bottom/right - _rDevice.SetLineColor( _rStyle.GetDialogTextColor() ); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); @@ -98,10 +116,19 @@ namespace svt { namespace table void GridTableRenderer::PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) { - _rDevice.Push( PUSH_LINECOLOR ); - - _rDevice.SetLineColor( _rStyle.GetDialogTextColor() ); - _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); + _rDevice.Push( PUSH_LINECOLOR); + //default background and line color is white + //background and lines should have same color, that's means lines aren't visible + //in case line color isn't set and background color is set, this should be changed + Color background = m_pImpl->rModel.getHeaderBackgroundColor(); + Color line = m_pImpl->rModel.getLineColor(); + if(line == 0xFFFFFF) + _rDevice.SetLineColor(_rStyle.GetShadowColor()); + else + // if Line color is set, then it was user defined and should be visible + // if it wasn't set, it'll be the same as the default background color, so lines still won't be visible + _rDevice.SetLineColor(line); + _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight()); String sHeaderText; @@ -109,20 +136,26 @@ namespace svt { namespace table DBG_ASSERT( !!pColumn, "GridTableRenderer::PaintColumnHeader: invalid column model object!" ); if ( !!pColumn ) sHeaderText = pColumn->getName(); - Color aRowBackground = _rStyle.GetFieldColor(); - if ( _bSelected ) - { - aRowBackground = COL_BLUE; - } - _rDevice.DrawText( _rArea, sHeaderText, TEXT_DRAW_LEFT | TEXT_DRAW_TOP ); + _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); + ULONG nHorFlag = TEXT_DRAW_LEFT; + ULONG nVerFlag = TEXT_DRAW_TOP; + if(m_pImpl->rModel.getVerticalAlign() == 1) + nVerFlag = TEXT_DRAW_VCENTER; + else if(m_pImpl->rModel.getVerticalAlign() == 2) + nVerFlag = TEXT_DRAW_BOTTOM; + if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 1) + nHorFlag = TEXT_DRAW_CENTER; + else if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2) + nHorFlag = TEXT_DRAW_RIGHT; + _rDevice.DrawText( _rArea, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); _rDevice.Pop(); (void)_bActive; // no special painting for the active column at the moment - //(void)_bSelected; - // TODO: selection not yet implemented + (void)_bSelected; + //selection for column header not yet implemented } //-------------------------------------------------------------------- @@ -132,86 +165,243 @@ namespace svt { namespace table // remember the row for subsequent calls to the other ->ITableRenderer methods m_pImpl->nCurrentRow = _nRow; - // fill the rows with alternating background colors - _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR ); - - _rDevice.SetLineColor(); + _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); - Color aRowBackground = _rStyle.GetFieldColor(); + Color aRowBackground = m_pImpl->rModel.getOddRowBackgroundColor(); + Color line = m_pImpl->rModel.getLineColor(); + Color aRowBackground2 = m_pImpl->rModel.getEvenRowBackgroundColor(); + //if row is selected background color becomes blue, and lines should be also blue + //if they aren't user defined + if(_bSelected) + { + Color aSelected(_rStyle.GetHighlightColor()); + aRowBackground = aSelected; + if(line == 0xFFFFFF) + _rDevice.SetLineColor(aRowBackground); + else + _rDevice.SetLineColor(line); + } + //if row not selected, check the cases whether user defined backgrounds are set + //and set line color to be the same + else + { + if(aRowBackground2 != 0xFFFFFF && _nRow%2) + { + aRowBackground = aRowBackground2; + if(line == 0xFFFFFF) + _rDevice.SetLineColor(aRowBackground); + else + _rDevice.SetLineColor(line); + } + //fill the rows with alternating background colors if second background color is specified + else if(aRowBackground != 0xFFFFFF && line == 0xFFFFFF) + _rDevice.SetLineColor(aRowBackground); + else + { + //if Line color is set, then it was user defined and should be visible + //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible + _rDevice.SetLineColor(line); + } + } + Rectangle aRect(_rRowArea); + if(m_pImpl->rModel.hasColumnHeaders() || _nRow != 0) + --aRect.Top(); + if(m_pImpl->rModel.hasRowHeaders()) + --aRect.Left(); _rDevice.SetFillColor( aRowBackground ); + _rDevice.DrawRect( aRect ); - _rDevice.DrawRect( _rRowArea ); - - // TODO: active? selected? + // TODO: active? _rDevice.Pop(); - (void) _bSelected; (void)_bActive; - - // no special painting for the active row at the moment - - //(void)_bSelected; - // TODO: selection not yet implemented } //-------------------------------------------------------------------- void GridTableRenderer::PaintRowHeader( bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText ) { - _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR ); - - _rDevice.SetLineColor( _rStyle.GetDialogTextColor() ); + _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); + //default background and line color is white + //background and lines should have same color, that's means lines aren't visible + //in case line color isn't set and background color is set, this should be changed + Color background = m_pImpl->rModel.getHeaderBackgroundColor(); + Color line = m_pImpl->rModel.getLineColor(); + if(background != 0xFFFFFF && line == 0xFFFFFF) + { + _rDevice.SetLineColor(background); + } + else + { + //if Line color is set, then it was user defined and should be visible + //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible + _rDevice.SetLineColor(line); + } _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); - _rDevice.DrawText( _rArea, _rText, TEXT_DRAW_LEFT); + _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); + ULONG nHorFlag = TEXT_DRAW_LEFT; + ULONG nVerFlag = TEXT_DRAW_TOP; + if(m_pImpl->rModel.getVerticalAlign() == 1) + nVerFlag = TEXT_DRAW_VCENTER; + else if(m_pImpl->rModel.getVerticalAlign() == 2) + nVerFlag = TEXT_DRAW_BOTTOM; + if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 1) + nHorFlag = TEXT_DRAW_CENTER; + else if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2) + nHorFlag = TEXT_DRAW_RIGHT; + _rDevice.DrawText( _rArea, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); // TODO: active? selected? (void)_bActive; (void)_bSelected; - + //at the moment no special paint for selected row header _rDevice.Pop(); } //-------------------------------------------------------------------- - void GridTableRenderer::PaintCell( ColPos _nColumn, bool _bSelected, bool _bActive, - OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText ) + void GridTableRenderer::PaintCellImage( ColPos _nColumn, bool _bSelected, bool _bActive, + OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, Image* _pCellData ) { - _rDevice.Push( PUSH_LINECOLOR ); - - // draw the grid - _rDevice.SetLineColor( COL_LIGHTGRAY ); - // TODO: the LIGHTGRAY should probably be a property/setting + _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_CLIPREGION); + _rDevice.IntersectClipRegion( _rArea ); + Color background1 = m_pImpl->rModel.getOddRowBackgroundColor(); + Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor(); + Color line = m_pImpl->rModel.getLineColor(); + //if row is selected and line color isn't user specified, set it blue + if(_bSelected) + { + if(line == 0xFFFFFF) + _rDevice.SetLineColor(_rStyle.GetHighlightColor()); + else + _rDevice.SetLineColor(line); + } + //else set line color to the color of row background + else + { + if(background2 != 0xFFFFFF && m_pImpl->nCurrentRow%2) + { + if(line == 0xFFFFFF) + _rDevice.SetLineColor(background2); + else + _rDevice.SetLineColor(line); + } + else if(background1 != 0xFFFFFF && line == 0xFFFFFF) + _rDevice.SetLineColor(background1); + else + { + //if line color is set, then it was user defined and should be visible + //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible + _rDevice.SetLineColor(line); + } + } _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); - _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); - { // TODO: remove those temporary place holders Rectangle aRect( _rArea ); ++aRect.Left(); --aRect.Right(); - ++aRect.Top(); --aRect.Bottom(); + aRect.Top(); aRect.Bottom(); + Point imagePos(Point(aRect.Left(), aRect.Top())); + Size imageSize = _pCellData->GetSizePixel(); - String sText; - if(_bSelected) + if(aRect.GetWidth() > imageSize.Width()) { - Color aRed(COL_BLUE); - _rDevice.SetFillColor( aRed ); - _rDevice.SetTextColor(COL_WHITE); + if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 1) + imagePos.X() = aRect.Left()+((double)(aRect.GetWidth() - imageSize.Width()))/2; + else if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 2) + imagePos.X() = aRect.Right() - imageSize.Width(); } - _rDevice.DrawRect( _rArea ); - (void)_nColumn; - _rDevice.DrawText( aRect, _rText, TEXT_DRAW_LEFT | TEXT_DRAW_TOP); + else + imageSize.Width() = aRect.GetWidth(); + if(aRect.GetHeight() > imageSize.Height()) + { + if(m_pImpl->rModel.getVerticalAlign() == 1) + imagePos.Y() = aRect.Top()+((double)(aRect.GetHeight() - imageSize.Height()))/2; + else if(m_pImpl->rModel.getVerticalAlign() == 2) + imagePos.Y() = aRect.Bottom() - imageSize.Height(); + } + else + imageSize.Height() = aRect.GetHeight()-1; + Image& image (*_pCellData); + _rDevice.DrawImage(imagePos, imageSize, image, 0); } + + _rDevice.Pop(); + + (void)_bActive; +// // no special painting for the active cell at the moment + (void)_rStyle; +// // TODO: do we need this? + } + + //-------------------------------------------------------------------- + void GridTableRenderer::PaintCellString( ColPos _nColumn, bool _bSelected, bool _bActive, + OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText ) + { + _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); + Color background1 = m_pImpl->rModel.getOddRowBackgroundColor(); + Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor(); + Color line = m_pImpl->rModel.getLineColor(); + //if row is selected and line color isn't user specified, set it blue if(_bSelected) { - _rDevice.SetFillColor( _rStyle.GetFieldColor() ); - _rDevice.SetTextColor(COL_BLACK); + if(line == 0xFFFFFF) + _rDevice.SetLineColor(_rStyle.GetHighlightColor()); + else + _rDevice.SetLineColor(line); + } + //else set line color to the color of row background + else + { + if(background2 != 0xFFFFFF && m_pImpl->nCurrentRow%2) + { + if(line == 0xFFFFFF) + _rDevice.SetLineColor(background2); + else + _rDevice.SetLineColor(line); + } + else if(background1 != 0xFFFFFF && line == 0xFFFFFF) + _rDevice.SetLineColor(background1); + else + { + //if Line color is set, then it was user defined and should be visible + //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible + _rDevice.SetLineColor(line); + } } + _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); + { + // TODO: remove those temporary place holders + Rectangle aRect( _rArea ); + ++aRect.Left(); --aRect.Right(); + aRect.Top(); aRect.Bottom(); + String sText; + if(_bSelected) + { + _rDevice.SetTextColor(_rStyle.GetHighlightTextColor()); + } + else + _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); + //_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); + //(void)_nColumn; + ULONG nHorFlag = TEXT_DRAW_LEFT; + ULONG nVerFlag = TEXT_DRAW_TOP; + if(m_pImpl->rModel.getVerticalAlign() == 1) + nVerFlag = TEXT_DRAW_VCENTER; + else if(m_pImpl->rModel.getVerticalAlign() == 2) + nVerFlag = TEXT_DRAW_BOTTOM; + if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 1) + nHorFlag = TEXT_DRAW_CENTER; + else if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 2) + nHorFlag = TEXT_DRAW_RIGHT; + _rDevice.DrawText( aRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + } _rDevice.Pop(); (void)_bActive; -// // no special painting for the active cell at the moment + // no special painting for the active cell at the moment (void)_rStyle; -// // TODO: do we need this? + // TODO: do we need this? } //-------------------------------------------------------------------- diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 1d7b046ae94b..427f65557e52 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -67,6 +67,8 @@ namespace svt { namespace table TableControl::TableControl( Window* _pParent, WinBits _nStyle ) :Control( _pParent, _nStyle ) ,m_pImpl( new TableControl_Impl( *this ) ) + ,m_nCols(*( new ::com::sun::star::uno::Sequence< sal_Int32 >(0) )) + ,m_aText(*( new ::com::sun::star::uno::Sequence< ::rtl::OUString >(0) )) { m_pImpl->getDataWindow()->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) ); m_pImpl->getDataWindow()->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) ); @@ -239,6 +241,7 @@ namespace svt { namespace table ::rtl::OUString TableControl::GetAccessibleObjectName( AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const { ::rtl::OUString aRetText; + //Window* pWin; switch( eObjType ) { case TCTYPE_GRIDCONTROL: @@ -254,7 +257,8 @@ namespace svt { namespace table aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderBar" ) ); break; case TCTYPE_TABLECELL: - aRetText = GetCellContent(_nRow, _nCol); + //Window* pWin = GetCellContent(_nRow, _nCol); + aRetText = GetRowName(_nRow); break; case TCTYPE_ROWHEADERCELL: aRetText = GetRowName(_nRow); @@ -327,13 +331,13 @@ namespace svt { namespace table // ----------------------------------------------------------------------------- -::rtl::OUString TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const +::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const { - ::rtl::OUString cellContent = ::rtl::OUString::createFromAscii(""); - std::vector >& aTableContent = GetModel()->getCellContent(); + ::com::sun::star::uno::Any cellContent = ::com::sun::star::uno::Any(::rtl::OUString::createFromAscii("")); + std::vector >& aTableContent = GetModel()->getCellContent(); if(&aTableContent) { - std::vector& aRowContent = aTableContent[_nRowPos]; + std::vector< ::com::sun::star::uno::Any >& aRowContent = aTableContent[_nRowPos]; if(&aRowContent) cellContent = aRowContent[_nColPos]; } @@ -491,48 +495,64 @@ sal_Int32 TableControl::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnP { (void)_nRow; (void)_nColumnPos; - return GetIndexForPoint(_rPoint); + return GetIndexForPoint(_rPoint); ; } - // ----------------------------------------------------------------------------- -sal_Bool TableControl::isAccessibleAlive( ) const -{ - return ( NULL != m_pAccessTable->m_pAccessible ) && m_pAccessTable->m_pAccessible->isAlive(); -} + // ----------------------------------------------------------------------------- +sal_Bool TableControl::isAccessibleAlive( ) const +{ + return ( NULL != m_pAccessTable->m_pAccessible ) && m_pAccessTable->m_pAccessible->isAlive(); +} // ----------------------------------------------------------------------------- ::svt::IAccessibleFactory& TableControl::getAccessibleFactory() { return m_pAccessTable->m_aFactoryAccess.getFactory(); } -// ----------------------------------------------------------------------------- -void TableControl::commitGridControlEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) -{ - if ( isAccessibleAlive() ) - m_pAccessTable->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue); -} -// ----------------------------------------------------------------------------- -Rectangle TableControl::calcHeaderRect(sal_Bool _bIsColumnBar,BOOL _bOnScreen) -{ - (void)_bOnScreen; - Rectangle aRectTable, aRectTableWithHeaders; - m_pImpl->impl_getAllVisibleDataCellArea(aRectTable); - m_pImpl->impl_getAllVisibleCellsArea(aRectTableWithHeaders); - Size aSizeTable(aRectTable.GetSize()); - Size aSizeTableWithHeaders(aRectTableWithHeaders.GetSize()); - if(_bIsColumnBar) - return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width()-aSizeTable.Width(), aSizeTableWithHeaders.Height())); - else - return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width(), aSizeTableWithHeaders.Height()-aSizeTable.Height())); -} -// ----------------------------------------------------------------------------- -Rectangle TableControl::calcTableRect(BOOL _bOnScreen) -{ - (void)_bOnScreen; - Rectangle aRect; - m_pImpl->impl_getAllVisibleDataCellArea(aRect); - return aRect; -} +// ----------------------------------------------------------------------------- +void TableControl::commitGridControlEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) +{ + if ( isAccessibleAlive() ) + m_pAccessTable->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue); +} +// ----------------------------------------------------------------------------- +Rectangle TableControl::calcHeaderRect(sal_Bool _bIsColumnBar,BOOL _bOnScreen) +{ + (void)_bOnScreen; + Rectangle aRectTable, aRectTableWithHeaders; + m_pImpl->impl_getAllVisibleDataCellArea(aRectTable); + m_pImpl->impl_getAllVisibleCellsArea(aRectTableWithHeaders); + Size aSizeTable(aRectTable.GetSize()); + Size aSizeTableWithHeaders(aRectTableWithHeaders.GetSize()); + if(_bIsColumnBar) + return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width()-aSizeTable.Width(), aSizeTableWithHeaders.Height())); + else + return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width(), aSizeTableWithHeaders.Height()-aSizeTable.Height())); +} +// ----------------------------------------------------------------------------- +Rectangle TableControl::calcTableRect(BOOL _bOnScreen) +{ + (void)_bOnScreen; + Rectangle aRect; + m_pImpl->impl_getAllVisibleDataCellArea(aRect); + return aRect; +} +//-------------------------------------------------------------------- +::com::sun::star::uno::Sequence< sal_Int32 >& TableControl::getColumnsForTooltip() +{ + return m_nCols; +} +//-------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::rtl::OUString >& TableControl::getTextForTooltip() +{ + return m_aText; +} +//-------------------------------------------------------------------- +void TableControl::setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols ) +{ + m_aText = aText; + m_nCols = nCols; +} //........................................................................ }} // namespace svt::table diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 89c0eed4229a..9bc8644276f1 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -32,9 +32,14 @@ #include "tablecontrol_impl.hxx" #include "tablegeometry.hxx" #include "svtools/table/tabledatawindow.hxx" - +#include #include #include +#include +#include +#include +#include +#include #include #include @@ -177,13 +182,71 @@ namespace svt { namespace table (void)actWidth; return ScrollbarShowNever; } - virtual void setCellContent(std::vector > pCellEntryType) + virtual bool hasVerticalScrollbar() + { + return false; + } + virtual bool hasHorizontalScrollbar() + { + return false; + } + virtual void setCellContent(std::vector > pCellEntryType) { (void)pCellEntryType; } - virtual std::vector >& getCellContent() + virtual ::com::sun::star::util::Color getLineColor() + { + return 0; + } + virtual void setLineColor(::com::sun::star::util::Color _rColor) + { + (void)_rColor; + } + virtual ::com::sun::star::util::Color getHeaderBackgroundColor() + { + return -1; + } + + virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor) + { + (void)_rColor; + } + virtual ::com::sun::star::util::Color getTextColor() + { + return 0; + } + virtual void setTextColor(::com::sun::star::util::Color _rColor) + { + (void)_rColor; + } + virtual ::com::sun::star::util::Color getOddRowBackgroundColor() + { + return -1; + } + virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor) + { + (void)_rColor; + } + virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() + { + return com::sun::star::style::VerticalAlignment(0); + } + virtual void setVerticalAlign(com::sun::star::style::VerticalAlignment _Align) + { + (void)_Align; + } + virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() + { + return -1; + } + virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor) + { + (void)_rColor; + } + + virtual std::vector >& getCellContent() { - return *( new std::vector >); + return *( new std::vector >); } virtual void setRowHeaderName(std::vector pCellEntryType) { @@ -302,7 +365,8 @@ namespace svt { namespace table // m_nColHeaderHeightPixel consistent with the model's value? { TableMetrics nHeaderHeight = m_pModel->hasColumnHeaders() ? m_pModel->getColumnHeaderHeight() : 0; - nHeaderHeight = m_rAntiImpl.LogicToPixel( Size( 0, nHeaderHeight ), MAP_100TH_MM ).Height(); + // nHeaderHeight = m_rAntiImpl.LogicToPixel( Size( 0, nHeaderHeight ), MAP_100TH_MM ).Height(); + nHeaderHeight = m_rAntiImpl.LogicToPixel( Size( 0, nHeaderHeight ), MAP_APPFONT ).Height(); if ( nHeaderHeight != m_nColHeaderHeightPixel ) return "column header heights are inconsistent!"; } @@ -311,7 +375,8 @@ namespace svt { namespace table if ( !isDummyModel ) { TableMetrics nRowHeight = m_pModel->getRowHeight(); - nRowHeight = m_rAntiImpl.LogicToPixel( Size( 0, nRowHeight ), MAP_100TH_MM ).Height(); + // nRowHeight = m_rAntiImpl.LogicToPixel( Size( 0, nRowHeight ), MAP_100TH_MM ).Height(); + nRowHeight = m_rAntiImpl.LogicToPixel( Size( 0, nRowHeight ), MAP_APPFONT).Height(); if ( nRowHeight != m_nRowHeightPixel ) return "row heights are inconsistent!"; } @@ -319,7 +384,8 @@ namespace svt { namespace table // m_nRowHeaderWidthPixel consistent with the model's value? { TableMetrics nHeaderWidth = m_pModel->hasRowHeaders() ? m_pModel->getRowHeaderWidth() : 0; - nHeaderWidth = m_rAntiImpl.LogicToPixel( Size( nHeaderWidth, 0 ), MAP_100TH_MM ).Width(); + //nHeaderWidth = m_rAntiImpl.LogicToPixel( Size( nHeaderWidth, 0 ), MAP_100TH_MM ).Width(); + nHeaderWidth = m_rAntiImpl.LogicToPixel( Size( nHeaderWidth, 0 ), MAP_APPFONT ).Width(); if ( nHeaderWidth != m_nRowHeaderWidthPixel ) return "row header widths are inconsistent!"; } @@ -385,6 +451,8 @@ namespace svt { namespace table ,m_nRowSelected ( ) ,m_pTableFunctionSet ( new TableFunctionSet(this ) ) ,m_nAnchor (-1 ) + ,m_bResizing ( false ) + ,m_nResizingColumn ( 0 ) #if DBG_UTIL ,m_nRequiredInvariants ( INV_SCROLL_POSITION ) #endif @@ -429,7 +497,7 @@ namespace svt { namespace table // TODO: revoke as table listener from the model m_pModel = _pModel; - if ( !m_pModel ) + if ( !m_pModel) m_pModel.reset( new EmptyTableModel ); // TODO: register as table listener @@ -503,11 +571,13 @@ namespace svt { namespace table m_pInputHandler.reset(); m_nColumnCount = m_nRowCount = 0; - m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_100TH_MM ).Height(); + //m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_100TH_MM ).Height(); + m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_APPFONT ).Height(); if ( m_pModel->hasColumnHeaders() ) - m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_100TH_MM ).Height(); + //m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_100TH_MM ).Height(); + m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_APPFONT ).Height(); if ( m_pModel->hasRowHeaders() ) - m_nRowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_100TH_MM ).Width(); + m_nRowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT).Width(); impl_ni_updateColumnWidths(); @@ -528,34 +598,100 @@ namespace svt { namespace table return; TableSize colCount = m_pModel->getColumnCount(); + m_aColumnWidthsPixel.reserve( colCount ); m_aAccColumnWidthsPixel.reserve( colCount ); long accumulatedPixelWidth = 0; + double gridWidth = m_rAntiImpl.GetSizePixel().Width()-1; + if(m_pModel->hasRowHeaders()) + { + TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); + gridWidth-= m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); + } + if(m_pModel->hasVerticalScrollbar()) + { + sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); + gridWidth-=scrollbarWidth; + //m_rAntiImpl.LogicToPixel( Size( scrollbarWidth, 0 ), MAP_APPFONT ).Width(); + } + double colWidthsSum = 0.0; + double colWithoutFixedWidthsSum = 0.0; for ( ColPos col = 0; col < colCount; ++col ) { PColumnModel pColumn = m_pModel->getColumnModel( col ); DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); if ( !pColumn ) continue; - - TableMetrics colWidth = pColumn->getWidth(); - DBG_ASSERT( ( colWidth == COLWIDTH_FIT_TO_VIEW ) || ( colWidth > 0 ), - "TableControl_Impl::impl_ni_updateColumnWidths: invalid column width!" ); - - long pixelWidth = 0; - if ( colWidth == COLWIDTH_FIT_TO_VIEW ) + TableMetrics colWidth = 0; + TableMetrics colPrefWidth = pColumn->getPreferredWidth(); + if( colPrefWidth != 0) { - // TODO - DBG_ERROR( "TableControl_Impl::impl_ni_updateColumnWidths: COLWIDTH_FIT_TO_VIEW not implemented, yet!" ); + colWidth = colPrefWidth; + pColumn->setWidth(colPrefWidth); } else + colWidth = pColumn->getWidth(); + long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + if(pColumn->isResizable() && colPrefWidth == 0) + colWithoutFixedWidthsSum+=pixelWidth; + colWidthsSum+=pixelWidth; + } + if(colWidthsSum < gridWidth) + { + gridWidth = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; + double scalingFactor = 1.0; + if(colWithoutFixedWidthsSum>0) + scalingFactor = gridWidth/colWithoutFixedWidthsSum; + long pixelWidth = 0; + for ( ColPos col = 0; col < colCount; ++col ) { - pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_100TH_MM ).Width(); + PColumnModel pColumn = m_pModel->getColumnModel( col ); + DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + if ( !pColumn ) + continue; + TableMetrics colWidth = pColumn->getWidth(); + //if(pColumn->getPreferredWidth() != 0) + // colWidth = pColumn->getPreferredWidth(); + if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) + { + colWidth*=scalingFactor; + pColumn->setWidth(colWidth); + } + pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + m_aColumnWidthsPixel.push_back( pixelWidth ); + m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += pixelWidth ); } + //m_rAntiImpl.SetModel(m_pModel); + + } + else + { + for ( ColPos col = 0; col < colCount; ++col ) + { + PColumnModel pColumn = m_pModel->getColumnModel( col ); + DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + if ( !pColumn ) + continue; - m_aColumnWidthsPixel.push_back( pixelWidth ); + TableMetrics colWidth = pColumn->getWidth(); + DBG_ASSERT( ( colWidth == COLWIDTH_FIT_TO_VIEW ) || ( colWidth > 0 ), + "TableControl_Impl::impl_ni_updateColumnWidths: invalid column width!" ); - m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += pixelWidth ); + long pixelWidth = 0; + if ( colWidth == COLWIDTH_FIT_TO_VIEW ) + { + // TODO + DBG_ERROR( "TableControl_Impl::impl_ni_updateColumnWidths: COLWIDTH_FIT_TO_VIEW not implemented, yet!" ); + } + else + { + //pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_100TH_MM ).Width(); + pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + } + m_aColumnWidthsPixel.push_back( pixelWidth ); + + m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += pixelWidth ); + } } } @@ -677,6 +813,13 @@ namespace svt { namespace table Rectangle aDataCellPlayground( Point( 0, 0 ), m_rAntiImpl.GetOutputSizePixel() ); aDataCellPlayground.Left() = m_nRowHeaderWidthPixel; aDataCellPlayground.Top() = m_nColHeaderHeightPixel; + m_nRowCount = m_pModel->getRowCount(); + m_nColumnCount = m_pModel->getColumnCount(); + + if(m_aAccColumnWidthsPixel.empty()) + { + impl_ni_updateColumnWidths(); + } // do we need a vertical scrollbar? bool bFirstRoundVScrollNeed = false; @@ -708,15 +851,6 @@ namespace svt { namespace table aDataCellPlayground.Right() -= nScrollbarMetrics; } } - else - { - Size regionWithoutHeader = m_rAntiImpl.PixelToLogic(Size(aDataCellPlayground.Right() - aDataCellPlayground.Left(),0),MAP_100TH_MM); - TableMetrics nColWidth = regionWithoutHeader.Width()/m_nColumnCount; - for ( ColPos col = 0; col < m_nColumnCount; ++col ) - m_pModel->getColumnModel(col)->setWidth(nColWidth); - m_rAntiImpl.SetModel(m_pModel); - } - // create or destroy the vertical scrollbar, as needed lcl_updateScrollbar( m_rAntiImpl, @@ -791,20 +925,20 @@ namespace svt { namespace table void TableControl_Impl::onResize() { DBG_CHECK_ME(); - impl_ni_updateScrollbars(); + if(m_nColumnCount != 0) + impl_ni_updateScrollbars(); //Rectangle aAllCells; // impl_getAllVisibleCellsArea( aAllCells ); //m_pSelEngine->SetVisibleArea(aAllCells); } //-------------------------------------------------------------------- - void TableControl_Impl::doPaintContent( const Rectangle& _rUpdateRect ) + void TableControl_Impl::doPaintContent( const Rectangle& _rUpdateRect ) { DBG_CHECK_ME(); if ( !getModel() ) return; - PTableRenderer pRenderer = getModel()->getRenderer(); DBG_ASSERT( !!pRenderer, "TableDataWindow::Paint: invalid renderer!" ); if ( !pRenderer ) @@ -819,6 +953,14 @@ namespace svt { namespace table impl_getAllVisibleCellsArea( aAllCellsWithHeaders ); m_nRowCount = m_pModel->getRowCount(); + TableSize nVisibleRows = impl_getVisibleRows(true); + TableSize nVisibleColumns = impl_getVisibleColumns(true); + TableSize nActualRows = m_nRowCount; + TableSize nActualCols = m_nColumnCount; + if(m_nRowCount>nVisibleRows) + nActualRows = nVisibleRows; + if(m_nColumnCount>nVisibleColumns) + nActualCols = nVisibleColumns; // ............................ // draw the header column area if ( getModel()->hasColumnHeaders() ) @@ -853,7 +995,10 @@ namespace svt { namespace table { aRowHeaderArea = aAllCellsWithHeaders; aRowHeaderArea.Right() = m_nRowHeaderWidthPixel - 1; - aRowHeaderArea.Bottom() = m_nRowHeightPixel * m_nRowCount + m_nColHeaderHeightPixel - 1; + if(m_nTopRow+nActualRows>m_nRowCount) + aRowHeaderArea.Bottom() = m_nRowHeightPixel * (nActualRows -1)+ m_nColHeaderHeightPixel - 1; + else + aRowHeaderArea.Bottom() = m_nRowHeightPixel * nActualRows + m_nColHeaderHeightPixel - 1; pRenderer->PaintHeaderArea( *m_pDataWindow, aRowHeaderArea, false, true, rStyle ); @@ -881,25 +1026,24 @@ namespace svt { namespace table impl_getAllVisibleDataCellArea( aAllDataCellsArea ); //get the vector, which contains row vectors, each containing the data for the cells in this row - std::vector >& aCellContent = m_pModel->getCellContent(); + std::vector >& aCellContent = m_pModel->getCellContent(); //if the vector is empty, fill it with empty data, so the table can be painted if(aCellContent.empty()) { - std::vector emptyCells; + std::vector< ::com::sun::star::uno::Any > emptyCells; while(m_nRowCount!=0) { - aCellContent.push_back(emptyCells); + aCellContent.push_back( emptyCells); --m_nRowCount; } } - std::vector >::iterator it = aCellContent.begin()+m_nTopRow; + std::vector >::iterator it = aCellContent.begin()+m_nTopRow; //get the vector, which contains the row header titles std::vector& aRowHeaderContent = m_pModel->getRowHeaderName(); ::std::vector::iterator itRowName = aRowHeaderContent.begin(); if(m_pModel->hasRowHeaders()) { - aRowHeaderContent = m_pModel->getRowHeaderName(); //if the vector is empty, fill it with empty strings, so the table can be painted if(aRowHeaderContent.empty()) { @@ -933,28 +1077,29 @@ namespace svt { namespace table isSelectedRow = true; } } - std::vector aCellData; - if(it != aCellContent.end()) + std::vector< ::com::sun::star::uno::Any > aCellData; + if(it != aCellContent.begin()+m_nTopRow+nActualRows) { aCellData = *it; ++it; } - ::std::vector::iterator iter = aCellData.begin()+m_nLeftColumn; + ::std::vector< ::com::sun::star::uno::Any >::iterator iter = aCellData.begin()+m_nLeftColumn; // give the redenderer a chance to prepare the row pRenderer->PrepareRow( aRowIterator.getRow(), isActiveRow, isSelectedRow, - *m_pDataWindow, aRowIterator.getRect().GetIntersection( aAllDataCellsArea ), rStyle ); + *m_pDataWindow, aRowIterator.getRect().GetIntersection( aAllDataCellsArea ), rStyle ); // paint the row header if ( m_pModel->hasRowHeaders() ) { rtl::OUString rowHeaderName; - if(itRowName != aRowHeaderContent.end()) + if(itRowName != aRowHeaderContent.begin()+m_nTopRow+nActualRows) { rowHeaderName = *itRowName; ++itRowName; } Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); + //rStyle.SetBackgroundColor(m_rAntiImpl.getHeaderBackgroundColor()); pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, rStyle, rowHeaderName ); } @@ -967,25 +1112,34 @@ namespace svt { namespace table aCell.moveRight() ) { - // if ( _rUpdateRect.GetIntersection( aCell.getRect() ).IsEmpty() ) - // continue; - //bool isActiveCell = isActiveRow && ( aCell.getColumn() == getCurColumn() ); bool isSelectedColumn = false; - rtl::OUString cellData; - if(aCellData.empty()) - cellData=rtl::OUString::createFromAscii(""); - else if(iter != aCellData.end()) + ::com::sun::star::uno::Any rCellData; + if(!aCellData.empty() && iter != aCellData.begin()+m_nLeftColumn+nActualCols) { - cellData = *iter; + TableSize nPartlyVisibleCols = impl_getVisibleColumns(false); + TableSize nPartlyVisibleRows = impl_getVisibleRows(false); + rCellData = *iter; ++iter; + Size siz = m_rAntiImpl.GetSizePixel(); + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; + if(rCellData>>=xGraphic) + { + Image* pImage = new Image(xGraphic); + if(pImage!=NULL) + pRenderer->PaintCellImage( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, + *m_pDataWindow, aCell.getRect(), rStyle, pImage ); + } + else + { + ::rtl::OUString sContent = impl_convertToString(rCellData); + pRenderer->PaintCellString( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, + *m_pDataWindow, aCell.getRect(), rStyle, sContent ); + } } - pRenderer->PaintCell( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, - *m_pDataWindow, aCell.getRect(), rStyle, cellData ); } } } - //-------------------------------------------------------------------- void TableControl_Impl::hideCursor() { @@ -1042,7 +1196,11 @@ namespace svt { namespace table else { if ( m_nCurRow < m_nRowCount - 1 ) + { bSuccess = goTo( m_nCurColumn, m_nCurRow + 1 ); + if(m_pSelEngine->GetSelectionMode() == MULTIPLE_SELECTION) + m_nAnchor = m_nCurRow; + } } break; @@ -1076,7 +1234,11 @@ namespace svt { namespace table else { if ( m_nCurRow > 0 ) + { bSuccess = goTo( m_nCurColumn, m_nCurRow - 1 ); + if(m_pSelEngine->GetSelectionMode() == MULTIPLE_SELECTION) + m_nAnchor = m_nCurRow; + } } break; case cursorLeft: @@ -1183,24 +1345,24 @@ namespace svt { namespace table int prevRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow); int nextRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow-1); if(prevRow>-1) - { - //if m_nCurRow isn't the upper one, can move up, otherwise not + { + //if m_nCurRow isn't the upper one, can move up, otherwise not if(m_nCurRow>0) - m_nCurRow--; - else - return bSuccess = true; - //if nextRow already selected, deselect it, otherwise select it - if(m_nRowSelected[nextRow] == m_nCurRow) - { - m_nRowSelected.erase(m_nRowSelected.begin()+prevRow); - invalidateSelectedRow(m_nCurRow+1, rCells); - } - else + m_nCurRow--; + else + return bSuccess = true; + //if nextRow already selected, deselect it, otherwise select it + if(m_nRowSelected[nextRow] == m_nCurRow) + { + m_nRowSelected.erase(m_nRowSelected.begin()+prevRow); + invalidateSelectedRow(m_nCurRow+1, rCells); + } + else { - m_nRowSelected.push_back(m_nCurRow); - invalidateSelectedRow(m_nCurRow, rCells); - } - } + m_nRowSelected.push_back(m_nCurRow); + invalidateSelectedRow(m_nCurRow, rCells); + } + } } } else @@ -1260,23 +1422,23 @@ namespace svt { namespace table int prevRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow); int nextRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow+1); if(prevRow>-1) - { - //if m_nCurRow isn't the last one, can move down, otherwise not - if(m_nCurRow= 0 ) && ( _nColumn < m_pModel->getColumnCount() ), - "TableControl_Impl::impl_getCellRect: invalid column index!" ); - DBG_ASSERT( ( _nRow >= 0 ) && ( _nRow < m_pModel->getRowCount() ), - "TableControl_Impl::impl_getCellRect: invalid row index!" ); + //DBG_ASSERT( ( _nColumn >= 0 ) && ( _nColumn < m_pModel->getColumnCount() ), + // "TableControl_Impl::impl_getCellRect: invalid column index!" ); + //DBG_ASSERT( ( _nRow >= 0 ) && ( _nRow < m_pModel->getRowCount() ), + // "TableControl_Impl::impl_getCellRect: invalid row index!" ); Rectangle aAllCells; impl_getAllVisibleCellsArea( aAllCells ); @@ -1412,7 +1574,7 @@ namespace svt { namespace table RowPos newRowPos = -2;//-1 is HeaderRow ColPos newColPos = 0; //To Do: when only row position needed, the second loop isn't necessary, Please proove this!!! - for(int i=0;iInvalidate(_rCellRect); } @@ -1584,28 +1746,15 @@ namespace svt { namespace table //impl_getCellRect(m_nCurColumn,_nRowEnd,rCells2); //_rCellRect.Bottom()=rCells2.Bottom(); impl_ni_updateScrollbars(); + TableSize nVisibleRows = impl_getVisibleRows(true); + if(m_nTopRow+nVisibleRows>m_nRowCount && m_nRowCount>=nVisibleRows) + m_nTopRow--; + else + m_nTopRow = 0; //m_pDataWindow->Invalidate(_rCellRect); m_pDataWindow->Invalidate(); } - - //------------------------------------------------------------------------------- - bool TableControl_Impl::isClickInVisibleArea(const Point& rPoint) - { - DBG_CHECK_ME(); - long nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); - //clickable area is in the visible table control area without the scrollbars - Rectangle aDataCellPlayground( Point( 0, 0 ), m_rAntiImpl.GetOutputSizePixel() ); - aDataCellPlayground.Top() = m_nColHeaderHeightPixel; - aDataCellPlayground.Right() -= nScrollbarMetrics; - aDataCellPlayground.Bottom() -= nScrollbarMetrics; - if((rPoint.X() >= aDataCellPlayground.Left() && rPoint.X() <= aDataCellPlayground.Right()) && rPoint.Y() >= aDataCellPlayground.Top() && rPoint.Y() <= aDataCellPlayground.Bottom()) - { - return true; - } - else - return false; - } //-------------------------------------------------------------------- TableSize TableControl_Impl::impl_getVisibleRows( bool _bAcceptPartialRow ) const { @@ -1734,7 +1883,7 @@ namespace svt { namespace table && abs( nPixelDelta ) < aDataArea.GetHeight() ) { - m_pDataWindow->Scroll( 0, (long)-nPixelDelta, aDataArea, SCROLL_CLIP | SCROLL_UPDATE ); + m_pDataWindow->Scroll( 0, (long)-nPixelDelta, aDataArea, SCROLL_CLIP | SCROLL_UPDATE | SCROLL_CHILDREN); } else m_pDataWindow->Invalidate( INVALIDATE_UPDATE ); @@ -1822,12 +1971,284 @@ namespace svt { namespace table } return pos; } + void TableControl_Impl::setTooltip(const Point& rPoint ) + { + ::rtl::OUString aTooltipText; + RowPos current = getCurrentRow(rPoint); + com::sun::star::uno::Sequence< sal_Int32 > cols = m_rAntiImpl.getColumnsForTooltip(); + com::sun::star::uno::Sequence< ::rtl::OUString > text = m_rAntiImpl.getTextForTooltip(); + if(text.getLength() == 0) + { + for(int i=0; igetCellContent()[current][cols[i]]; + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; + if(content>>=xGraphic) + aTooltipText=::rtl::OUString::createFromAscii("IMAGE"); + else + aTooltipText = impl_convertToString(content); + } + else + { + aTooltipText+= ::rtl::OUString::createFromAscii("\n"); + ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; + if(content>>=xGraphic) + aTooltipText += ::rtl::OUString::createFromAscii("IMAGE"); + else + aTooltipText += impl_convertToString(content); + } + } + } + else if(cols.getLength() == 0) + { + for(int i=0; igetCellContent()[current][cols[i]]; + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; + if(content>>=xGraphic) + aTooltipText = ::rtl::OUString::createFromAscii("IMAGE"); + else + aTooltipText = text[i] + impl_convertToString(content); + } + else + { + aTooltipText+= ::rtl::OUString::createFromAscii("\n"); + aTooltipText+= text[i]; + if(nCols > i) + { + ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; + if(content>>=xGraphic) + aTooltipText +=::rtl::OUString::createFromAscii("IMAGE"); + else + aTooltipText += impl_convertToString(content); + } + } + } + } + Help::ShowBalloon(m_pDataWindow, rPoint, aTooltipText); + } + //-------------------------------------------------------------------- + void TableControl_Impl::resizeColumn(const Point& rPoint) + { + Pointer aNewPointer(POINTER_ARROW); + int headerRowWidth = 0; + if(m_pModel->hasRowHeaders()) + headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width(); + int resizingColumn=m_nCurColumn-m_nLeftColumn; + PColumnModel pColumn = m_pModel->getColumnModel(m_nCurColumn); + sal_Int32 colWidth = pColumn->getWidth(); + impl_ni_getAccVisibleColWidths(); + int newColWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + //subtract 1 from m_aAccColumnWidthPixel because right border should be part of the current cell + if(m_aVisibleColumnWidthsPixel[resizingColumn]-1 == rPoint.X() && pColumn->isResizable()) + { + aNewPointer = Pointer( POINTER_HSPLIT ); + } + //MouseButton was pressed but not yet released, mouse is moving + if(m_bResizing) + { + if(rPoint.X() > m_pDataWindow->GetSizePixel().Width() || rPoint.X() < m_aVisibleColumnWidthsPixel[resizingColumn]-newColWidth) + aNewPointer = Pointer( POINTER_NOTALLOWED); + else + aNewPointer = Pointer( POINTER_HSPLIT ); + m_pDataWindow->HideTracking(); + int lineHeight = 0; + if(m_pModel->hasColumnHeaders()) + lineHeight+= m_nColHeaderHeightPixel; + lineHeight+=m_nRowHeightPixel*m_nRowCount; + int gridHeight = m_pDataWindow->GetSizePixel().Height(); + if(lineHeight >= gridHeight) + lineHeight = gridHeight; + m_pDataWindow->ShowTracking(Rectangle(Point(rPoint.X(),0), Size(1, lineHeight )), + SHOWTRACK_SPLIT | SHOWTRACK_WINDOW); + } + m_pDataWindow->SetPointer(aNewPointer); + } - void TableControl_Impl::setCellContent(CellEntryType* pCellEntryType) + //-------------------------------------------------------------------- + bool TableControl_Impl::startResizeColumn(const Point& rPoint) { - (void)pCellEntryType; + m_nResizingColumn = m_nCurColumn; + PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn); + sal_Int32 colWidth = pColumn->getWidth(); + //impl_ni_getAccVisibleColWidths(); + int newColWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + if(m_aVisibleColumnWidthsPixel[m_nResizingColumn-m_nLeftColumn]-1 == rPoint.X() && pColumn->isResizable()) + { + m_pDataWindow->CaptureMouse(); + m_bResizing = true; + } + return m_bResizing; + } + //-------------------------------------------------------------------- + bool TableControl_Impl::endResizeColumn(const Point& rPoint) + { + if(m_bResizing) + { + m_pDataWindow->HideTracking(); + PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn); + int maxWidth = pColumn->getMaxWidth(); + int minWidth = pColumn->getMinWidth(); + int colWidth = pColumn->getWidth(); + int resizeCol = m_nResizingColumn-m_nLeftColumn; + //new position of mouse + int actX = rPoint.X(); + //old position of right border + int oldX = m_aVisibleColumnWidthsPixel[resizeCol]; + //position of left border if cursor in the first cell + int leftX = 0; + if(m_nResizingColumn-1 > 0 && m_nResizingColumn > m_nLeftColumn) + leftX = m_aVisibleColumnWidthsPixel[resizeCol-1]; + else if(m_nResizingColumn == 0 && m_pModel->hasRowHeaders()) + leftX = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width(); + int actWidth = actX - leftX; + int newActWidth = 0; + //minimize the column width + if(oldX > actX && actX >= leftX) + { + if(minWidth == 0 && pColumn->isResizable()) + { + minWidth = 1; + //TO DO: set it back to model + } + if(minWidth < actWidth) + { + newActWidth = m_rAntiImpl.PixelToLogic( Size( actWidth, 0 ), MAP_APPFONT ).Width(); + pColumn->setPreferredWidth(newActWidth); + } + else + pColumn->setPreferredWidth(minWidth); + if(m_nLeftColumn != 0) + impl_updateLeftColumn(); + } + else if(oldX < actX) + { + if(maxWidth == 0 && pColumn->isResizable()) + { + maxWidth = m_pDataWindow->GetSizePixel().Width()-1; + //TO DO: set it back to model + } + if(actWidth < maxWidth) + { + newActWidth = m_rAntiImpl.PixelToLogic( Size( actWidth, 0 ), MAP_APPFONT ).Width(); + pColumn->setPreferredWidth(newActWidth); + } + else + pColumn->setPreferredWidth(maxWidth); + } + m_nCurColumn = m_nResizingColumn; + impl_ni_updateColumnWidths(); + impl_ni_updateScrollbars(); + m_pDataWindow->Invalidate(INVALIDATE_UPDATE); + m_pDataWindow->SetPointer(Pointer()); + m_bResizing = false; + } + m_pDataWindow->ReleaseMouse(); + return m_bResizing; } + void TableControl_Impl::impl_ni_getAccVisibleColWidths() + { + TableSize nVisCols = impl_getVisibleColumns(true); + int widthsPixel = 0; + int pixelWidth = 0; + m_aVisibleColumnWidthsPixel.resize(0); + m_aVisibleColumnWidthsPixel.reserve(nVisCols); + int headerRowWidth = 0; + if(m_pModel->hasRowHeaders()) + { + headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width(); + widthsPixel+=headerRowWidth; + } + int col = m_nLeftColumn; + while(nVisCols) + { + PColumnModel pColumn = m_pModel->getColumnModel(col); + pixelWidth = m_rAntiImpl.LogicToPixel( Size( pColumn->getWidth(), 0 ), MAP_APPFONT ).Width(); + m_aVisibleColumnWidthsPixel.push_back(widthsPixel+=pixelWidth); + col++; + nVisCols--; + } + } + void TableControl_Impl::impl_updateLeftColumn() + { + int nVisCols = m_aVisibleColumnWidthsPixel.size(); + int headerRowWidth = 0; + //sum of currently visible columns + int widthsPixel = 0; + //header pixel should be added, because header doesn't vanish when scrolling + if(m_pModel->hasRowHeaders()) + { + headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width(); + widthsPixel+=headerRowWidth; + } + int col = m_nLeftColumn; + //add column width of the neighbour of the left column + widthsPixel+=m_aColumnWidthsPixel[col-1]; + //compute the sum of the new column widths + while(nVisCols) + { + PColumnModel pColumn = m_pModel->getColumnModel(col); + int colWidth = pColumn->getWidth(); + int colPrefWidth = pColumn->getPreferredWidth(); + if(colPrefWidth!=0) + colWidth = colPrefWidth; + widthsPixel += m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + col++; + nVisCols--; + } + //when the sum of all visible columns and the next to the left column is smaller than + //window width, then update m_nLeftColumn + if(widthsPixelGetSizePixel().Width()) + m_nLeftColumn--; + } + //-------------------------------------------------------------------- + rtl::OUString TableControl_Impl::impl_convertToString(::com::sun::star::uno::Any value) + { + sal_Int32 nInt; + sal_Bool bBool; + double fDouble; + ::rtl::OUString sNewString; + ::rtl::OUString sConvertString; + if(value >>= sConvertString) + sNewString = sConvertString; + else if(value >>= nInt) + sNewString = sConvertString.valueOf(nInt); + else if(value >>= bBool) + sNewString = sConvertString.valueOf(bBool); + else if(value >>= fDouble) + sNewString = sConvertString.valueOf(fDouble); + return sNewString; + } //-------------------------------------------------------------------- IMPL_LINK( TableControl_Impl, OnScroll, ScrollBar*, _pScrollbar ) { @@ -1841,7 +2262,6 @@ namespace svt { namespace table return 0L; } - //--------------------------------------------------------------------------------------- TableFunctionSet::TableFunctionSet(TableControl_Impl* _pTableControl): m_pTableControl( _pTableControl) diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 0a25e82e4502..a26079a37827 100644 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -38,6 +38,7 @@ #include #include + class ScrollBar; class ScrollBarBox; @@ -75,6 +76,8 @@ namespace svt { namespace table counting the space for a possible row header column */ ArrayOfLong m_aAccColumnWidthsPixel; + + ArrayOfLong m_aVisibleColumnWidthsPixel; /// the height of a single row in the table, measured in pixels long m_nRowHeightPixel; /// the height of the column header row in the table, measured in pixels @@ -113,8 +116,8 @@ namespace svt { namespace table TableFunctionSet* m_pTableFunctionSet; //part of selection engine RowPos m_nAnchor; - - + bool m_bResizing; + ColPos m_nResizingColumn; #if DBG_UTIL #define INV_SCROLL_POSITION 1 @@ -145,7 +148,6 @@ namespace svt { namespace table inline const TableControl& getAntiImpl() const { return m_rAntiImpl; } inline TableControl& getAntiImpl() { return m_rAntiImpl; } - void setCellContent(CellEntryType* pCellEntryType); public: TableControl_Impl( TableControl& _rAntiImpl ); @@ -181,7 +183,7 @@ namespace svt { namespace table */ void ensureVisible( ColPos _nColumn, RowPos _nRow, bool _bAcceptPartialVisibility ); /** returns the row, which contains the input point*/ - RowPos getCurrentRow (const Point& rPoint); + virtual RowPos getCurrentRow (const Point& rPoint); void setCursorAtCurrentCell(const Point& rPoint); /** proves whether the vector with the selected rows contains the current row*/ @@ -206,8 +208,11 @@ namespace svt { namespace table virtual void hideCursor(); virtual void showCursor(); virtual bool dispatchAction( TableControlAction _eAction ); - virtual bool isClickInVisibleArea(const Point& rPoint); virtual SelectionEngine* getSelEngine(); + virtual void setTooltip(const Point& rPoint ); + virtual void resizeColumn(const Point& rPoint); + virtual bool startResizeColumn(const Point& rPoint); + virtual bool endResizeColumn(const Point& rPoint); TableDataWindow* getDataWindow(); /** retrieves the area occupied by the totality of (at least partially) visible cells @@ -312,6 +317,10 @@ namespace svt { namespace table */ TableSize impl_ni_ScrollColumns( TableSize _nRowDelta ); + void impl_ni_getAccVisibleColWidths(); + void impl_updateLeftColumn(); + ::rtl::OUString impl_convertToString(::com::sun::star::uno::Any _value); + DECL_LINK( OnScroll, ScrollBar* ); }; //see seleng.hxx, seleng.cxx, FunctionSet overwritables, part of selection engine diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 71a313bb2e00..8631ed76a6c0 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -44,9 +44,6 @@ namespace svt { namespace table :Window( &_rTableControl.getAntiImpl() ) ,m_rTableControl ( _rTableControl ) { - Color backgroundColor = m_rTableControl.getAntiImpl().GetSettings().GetStyleSettings().GetFieldColor(); - SetBackground( backgroundColor ); - SetControlBackground( backgroundColor ); } //-------------------------------------------------------------------- @@ -56,8 +53,22 @@ namespace svt { namespace table } void TableDataWindow::MouseMove( const MouseEvent& rMEvt ) { + Point aPoint = rMEvt.GetPosPixel(); if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) ) - Window::MouseMove( rMEvt ); + { + if(m_rTableControl.getCurrentRow(aPoint)>=0 && + (!m_rTableControl.getAntiImpl().getColumnsForTooltip().getLength()==0 || !m_rTableControl.getAntiImpl().getTextForTooltip().getLength()==0)) + { + m_rTableControl.setTooltip(aPoint); + SetPointer(POINTER_ARROW); + } + else if(m_rTableControl.getCurrentRow(aPoint) == -1) + { + m_rTableControl.resizeColumn(aPoint); + } + else + Window::MouseMove( rMEvt ); + } } void TableDataWindow::MouseButtonDown( const MouseEvent& rMEvt ) { @@ -75,7 +86,18 @@ namespace svt { namespace table m_aMouseButtonUpHdl.Call( (MouseEvent*) &rMEvt); m_rTableControl.getAntiImpl().GetFocus(); } - + void TableDataWindow::SetPointer( const Pointer& rPointer ) + { + Window::SetPointer(rPointer); + } + void TableDataWindow::CaptureMouse() + { + Window::CaptureMouse(); + } + void TableDataWindow::ReleaseMouse( ) + { + Window::ReleaseMouse(); + } //........................................................................ } } // namespace svt::table //........................................................................ diff --git a/svtools/source/table/tablegeometry.cxx b/svtools/source/table/tablegeometry.cxx index 569e14c61726..4ec032260b82 100644 --- a/svtools/source/table/tablegeometry.cxx +++ b/svtools/source/table/tablegeometry.cxx @@ -48,8 +48,8 @@ namespace svt { namespace table { if ( m_nRowPos == ROW_COL_HEADERS ) { - DBG_ASSERT( m_rControl.m_pModel->hasColumnHeaders(), - "TableRowGeometry::TableRowGeometry: why asking for the geoemtry of the non-existent column header row?" ); + //DBG_ASSERT( m_rControl.m_pModel->hasColumnHeaders(), + // "TableRowGeometry::TableRowGeometry: why asking for the geoemtry of the non-existent column header row?" ); m_aRect.Top() = 0; m_aRect.Bottom() = m_rControl.m_nColHeaderHeightPixel - 1; } @@ -86,8 +86,8 @@ namespace svt { namespace table { if ( m_nColPos == COL_ROW_HEADERS ) { - DBG_ASSERT( m_rControl.m_pModel->hasRowHeaders(), - "TableColumnGeometry::TableColumnGeometry: why asking for the geoemtry of the non-existent row header column?" ); +/* DBG_ASSERT( m_rControl.m_pModel->hasRowHeaders(), + "TableColumnGeometry::TableColumnGeometry: why asking for the geoemtry of the non-existent row header column?" )*/; m_aRect.Left() = 0; m_aRect.Right() = m_rControl.m_nRowHeaderWidthPixel - 1; } diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 2f2c896ee6a8..ce04078687b1 100755 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -40,12 +40,16 @@ #include #include #include +#include #include #include -#include -#include -#include - +#include +#include +#include +#include +#include +#include +#include using ::rtl::OUString; using namespace ::svt::table; @@ -54,9 +58,9 @@ using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::view; using namespace ::toolkit; using namespace ::com::sun::star::accessibility; -using namespace ::com::sun::star::accessibility::AccessibleEventId; -using namespace ::com::sun::star::accessibility::AccessibleTableModelChangeType; -using ::com::sun::star::accessibility::AccessibleTableModelChange; +using namespace ::com::sun::star::accessibility::AccessibleEventId; +using namespace ::com::sun::star::accessibility::AccessibleTableModelChangeType; +using ::com::sun::star::accessibility::AccessibleTableModelChange; SVTXGridControl::SVTXGridControl() @@ -93,28 +97,20 @@ IMPL_XTYPEPROVIDER_START( SVTXGridControl ) VCLXWindow::getTypes() IMPL_XTYPEPROVIDER_END -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL SVTXGridControl::getColumnModel( ) throw (::com::sun::star::uno::RuntimeException) -{ - return NULL; -} -void SAL_CALL SVTXGridControl::setColumnModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >& model ) throw (::com::sun::star::uno::RuntimeException) -{ - (void)model; -} -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL SVTXGridControl::getDataModel( ) throw (::com::sun::star::uno::RuntimeException) -{ - return NULL; -} -void SAL_CALL SVTXGridControl::setDataModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >& model ) throw (::com::sun::star::uno::RuntimeException) -{ - (void)model; -} sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { TableControl* pTable = (TableControl*)GetWindow(); return pTable->GetCurrentRow( Point(x,y) ); } +void SAL_CALL SVTXGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const com::sun::star::uno::Sequence< sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException) +{ + TableControl* pTable = (TableControl*)GetWindow(); + /*std::vector< sal_Int32 > newCols( + comphelper::sequenceToContainer< std::vector< sal_Int32 > >(columns));*/ + pTable->setTooltip(text, columns); +} + void SAL_CALL SVTXGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { (void)listener; @@ -158,6 +154,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An if( aValue >>= bHScroll ) { m_bHScroll = bHScroll; + m_pTableModel->setHorizontalScrollbarVisibility(bHScroll); } break; } @@ -167,9 +164,11 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An if( aValue >>= bVScroll ) { m_bVScroll = bVScroll; + m_pTableModel->setVerticalScrollbarVisibility(bVScroll); } break; } + case BASEPROPERTY_GRID_SHOWROWHEADER: { sal_Bool rowHeader = true; @@ -179,6 +178,66 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } break; } + case BASEPROPERTY_GRID_HEADER_BACKGROUND: + { + sal_Int32 colorHeader = 0x000000; + if( aValue >>= colorHeader ) + { + m_pTableModel->setHeaderBackgroundColor(colorHeader); + } + break; + } + case BASEPROPERTY_GRID_LINE_COLOR: + { + sal_Int32 colorLine = 0x000000; + if( aValue >>= colorLine ) + { + m_pTableModel->setLineColor(colorLine); + } + break; + } + case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND: + { + sal_Int32 colorEvenRow = 0x000000; + if( aValue >>= colorEvenRow ) + { + m_pTableModel->setEvenRowBackgroundColor(colorEvenRow); + } + break; + } + case BASEPROPERTY_BACKGROUNDCOLOR: + { + sal_Int32 colorBackground = 0x000000; + if( aValue >>= colorBackground ) + { + m_pTableModel->setOddRowBackgroundColor(colorBackground); + } + break; + } + case BASEPROPERTY_TEXTCOLOR: + { + com::sun::star::util::Color colorText; + if( aValue >>= colorText ) + { + m_pTableModel->setTextColor(colorText); + } + break; + } + case BASEPROPERTY_VERTICALALIGN: + { + com::sun::star::style::VerticalAlignment vAlign; + if( aValue >>= vAlign ) + { + switch( vAlign ) + { + case com::sun::star::style::VerticalAlignment_TOP: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(0)); break; + case com::sun::star::style::VerticalAlignment_MIDDLE: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(1)); break; + case com::sun::star::style::VerticalAlignment_BOTTOM: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(2)); break; + default: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(0)); break; + } + } + break; + } case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: { @@ -191,40 +250,97 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_GRID_DATAMODEL: { - m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY ); - Sequence > cellData = m_xDataModel->getData(); - Sequence rowData(0); - std::vector< std::vector< rtl::OUString > > aCellContent(0); - for(int i = 0; i< m_xDataModel->getRowCount();++i) + //m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY ); + //Sequence > cellData = m_xDataModel->getData(); + //Sequence rowData(0); + //std::vector< std::vector< Window* > > aCellContent(0); + //for(int i = 0; i< m_xDataModel->getRowCount();++i) + //{ + // rowData = cellData[i]; + // std::vector newRow( + // comphelper::sequenceToContainer< std::vector >(rowData)); + // if(newRow.size() < (unsigned)m_pTableModel->getColumnCount()) + // newRow.resize( m_pTableModel->getColumnCount(),rtl::OUString::createFromAscii("")); + // aCellContent.push_back(newRow); + //} + //m_pTableModel->setCellContent(aCellContent); + //Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); + //std::vector< rtl::OUString > newRow( + // comphelper::sequenceToContainer< std::vector >(rowHeaders)); + //m_pTableModel->setRowCount(m_xDataModel->getRowCount()); + //m_pTableModel->setRowHeaderName(newRow); + //break; { - rowData = cellData[i]; - std::vector newRow( - comphelper::sequenceToContainer< std::vector >(rowData)); - if(newRow.size() < (unsigned)m_pTableModel->getColumnCount()) - newRow.resize( m_pTableModel->getColumnCount(),rtl::OUString::createFromAscii("")); - aCellContent.push_back(newRow); + m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY ); + if(m_xDataModel != NULL) + { + Sequence > cellData = m_xDataModel->getData(); + if(cellData.getLength()!= 0) + { + for (int i = 0; i < cellData.getLength(); i++) + { + std::vector< Any > newRow; + Sequence< Any > rawRowData = cellData[i]; + //check whether the data row vector length matches with the column count, + //all cells must have some content even if it is empty string + //preventing errors + if(m_xColumnModel->getColumnCount() == 0) + { + for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col ) + { + UnoControlTableColumn* tableColumn = new UnoControlTableColumn(); + m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); + } + m_xColumnModel->setDefaultColumns(rawRowData.getLength()); + } + if((unsigned int)rawRowData.getLength()!=(unsigned)m_pTableModel->getColumnCount()) + throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel); + + for ( int k = 0; k < rawRowData.getLength(); k++) + { + newRow.push_back(rawRowData[k]); + } + m_pTableModel->getCellContent().push_back(newRow); + } + + Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); + std::vector< rtl::OUString > newRow( + comphelper::sequenceToContainer< std::vector >(rowHeaders)); + m_pTableModel->setRowCount(m_xDataModel->getRowCount()); + m_pTableModel->setRowHeaderName(newRow); + m_pTableModel->setRowHeight(m_xDataModel->getRowHeight()); + m_pTableModel->setRowHeaderWidth(m_xDataModel->getRowHeaderWidth()); + } + } + else + throw GridInvalidDataException(rtl::OUString::createFromAscii("The data model isn't set!"), m_xDataModel); } - m_pTableModel->setCellContent(aCellContent); - Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); - std::vector< rtl::OUString > newRow( - comphelper::sequenceToContainer< std::vector >(rowHeaders)); - m_pTableModel->setRowCount(m_xDataModel->getRowCount()); - m_pTableModel->setRowHeaderName(newRow); break; } case BASEPROPERTY_GRID_COLUMNMODEL: { m_xColumnModel = Reference< XGridColumnModel >( aValue, UNO_QUERY ); - Sequence > columns = m_xColumnModel->getColumns(); - std::vector > aNewColumns( - comphelper::sequenceToContainer > >(columns)); - /* if(m_pTable->GetColumnCount().size()>0) - m_pTable->GetColumnName.clear();*/ - for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) + if(m_xColumnModel != NULL) { - UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]); - m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); + if(m_xColumnModel->getColumnCount() != 0) + { + Sequence > columns = m_xColumnModel->getColumns(); + std::vector > aNewColumns( + comphelper::sequenceToContainer > >(columns)); + m_pTableModel->setColumnHeaderHeight(m_xColumnModel->getColumnHeaderHeight()); + for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) + { + UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]); + m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); + m_pTableModel->getColumnModel()[col]->setHorizontalAlign(m_xColumnModel->getColumn(col)->getHorizontalAlign()); + m_pTableModel->getColumnModel()[col]->setWidth(m_xColumnModel->getColumn(col)->getColumnWidth()); + m_pTableModel->getColumnModel()[col]->setResizable(m_xColumnModel->getColumn(col)->getResizeable()); + } + } } + else + throw GridInvalidModelException(rtl::OUString::createFromAscii("The column model isn't set!"), m_xColumnModel); + break; } default: @@ -268,6 +384,7 @@ Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru return Any ( m_xDataModel ); case BASEPROPERTY_GRID_COLUMNMODEL: return Any ( m_xColumnModel); + case BASEPROPERTY_TABSTOP: case BASEPROPERTY_HSCROLL: return Any ( m_bHScroll); case BASEPROPERTY_VSCROLL: @@ -285,6 +402,9 @@ void SVTXGridControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_GRID_DATAMODEL, BASEPROPERTY_GRID_COLUMNMODEL, BASEPROPERTY_GRID_SELECTIONMODE, + BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND, + BASEPROPERTY_GRID_HEADER_BACKGROUND, + BASEPROPERTY_GRID_LINE_COLOR, 0); VCLXWindow::ImplGetPropertyIds( rIds, true ); } @@ -294,8 +414,18 @@ void SAL_CALL SVTXGridControl::setVisible( sal_Bool bVisible ) throw(::com::sun: if ( pTable ) { pTable->SetModel(PTableModel(m_pTableModel)); - //m_pTable->SetPosSizePixel( Point( nPosX, nPosY ), Size(nWidth, nHeight) ); pTable->Show( bVisible ); + if(m_xColumnModel != NULL) + { + for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) + { + //set the new widths, which are computed to fill the width of grid, back to uno awt gridcolumn + //so funktioniert es nicht!!! Die Toolkit Klassen müssen notifiziert werden, sonst kommt es nicht an + //herausfinden wie es gehen soll! + m_xColumnModel->getColumn(col)->setColumnWidth(m_pTableModel->getColumnModel()[col]->getWidth()); + } + } + //TO DO: notify uno awt GridModel about hor. /vert. scrollbars } } void SAL_CALL SVTXGridControl::setFocus() throw(::com::sun::star::uno::RuntimeException) @@ -306,87 +436,154 @@ void SAL_CALL SVTXGridControl::setFocus() throw(::com::sun::star::uno::RuntimeEx } void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { - std::vector aNewRow( - comphelper::sequenceToContainer< std::vector >(Event.rowData)); - if(aNewRow.size()< (unsigned)m_pTableModel->getColumnCount()) - aNewRow.resize(m_pTableModel->getColumnCount(),rtl::OUString::createFromAscii("")); - m_pTableModel->getCellContent().push_back(aNewRow); + std::vector< Any > newRow; + Sequence< Any > rawRowData = Event.rowData; + if(m_xColumnModel->getColumnCount() == 0) + { + for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col ) + { + UnoControlTableColumn* tableColumn = new UnoControlTableColumn(); + m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); + } + m_xColumnModel->setDefaultColumns(rawRowData.getLength()); + } + else if((unsigned int)rawRowData.getLength()!=(unsigned)m_xColumnModel->getColumnCount()) + throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel); + for ( int k = 0; k < rawRowData.getLength(); k++) + { + ::rtl::OUString xCellType; + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic> xGraphic; + /*if(xCellType.CellControl!= NULL) + { + xCellType.CellControl->createPeer( getToolkit(), this); + Window* pVclPeer = VCLUnoHelper::GetWindow( xCellType.CellControl->getPeer() ); + xTableCellType->pWindow = pVclPeer; + xTableCellType->pWindow->Hide(); + newRow.push_back(xTableCellType); + } + else + {*/ + newRow.push_back(rawRowData[k]); + //} + } + m_pTableModel->getCellContent().push_back(newRow); if(m_pTableModel->hasRowHeaders()) m_pTableModel->getRowHeaderName().push_back(Event.headerName); - m_pTableModel->setRowCount(m_pTableModel->getRowHeaderName().size()); + m_pTableModel->setRowCount(m_pTableModel->getCellContent().size()); + //if(m_pTableModel->hasVerticalScrollbar()) + m_bVScroll = m_pTableModel->hasVerticalScrollbar(); + com::sun::star::uno::Any aAny; + aAny <<= m_bVScroll; + setProperty(rtl::OUString::createFromAscii("VScroll"),aAny); + //Reference < XGridControl >( getPeer(), UNO_QUERY_THROW )->ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VSCROLL ), aAny, sal_True ); + + + m_bHScroll = m_pTableModel->hasHorizontalScrollbar(); TableControl* pTable = (TableControl*)GetWindow(); - pTable->InvalidateDataWindow(m_pTableModel->getRowHeaderName().size()-1, false); - //pTable->GrabFocus(); + pTable->InvalidateDataWindow(m_pTableModel->getCellContent().size()-1, false); if(pTable->isAccessibleAlive()) { - pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange(INSERT, m_pTableModel->getRowCount()-1, m_pTableModel->getRowCount(), 0, m_pTableModel->getColumnCount())), - Any()); - pTable->commitGridControlEvent(CHILD, - makeAny( pTable->m_pAccessTable->m_pAccessible->getTableHeader(TCTYPE_ROWHEADERBAR)), - Any()); + pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, + makeAny( AccessibleTableModelChange(INSERT, m_pTableModel->getRowCount()-1, m_pTableModel->getRowCount(), 0, m_pTableModel->getColumnCount())), + Any()); + pTable->commitGridControlEvent(CHILD, + makeAny( pTable->m_pAccessTable->m_pAccessible->getTableHeader(TCTYPE_ROWHEADERBAR)), + Any()); for (sal_Int32 i = 0 ; i <= m_pTableModel->getColumnCount() ; ++i) { pTable->commitGridControlEvent( CHILD, makeAny( pTable->m_pAccessTable->m_pAccessible->getTable() ), Any()); - } + } } } void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { + //TableControl* pTable = (TableControl*)GetWindow(); + ////unsigned int rows =m_pImpl->aCellContent.size()-1; + //if(Event.index == -1) + //{ + // if(m_pTableModel->hasRowHeaders()) + // m_pTableModel->getRowHeaderName().clear(); + // m_pTableModel->getCellContent().clear(); + // if(pTable->isAccessibleAlive()) + // { + // pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, + // makeAny( AccessibleTableModelChange(DELETE, 0, m_pTableModel->getColumnCount(), 0, m_pTableModel->getColumnCount())), + // Any()); + // } + //} + //else + //{ + // pTable->removeSelectedRow(Event.index); + // if(m_pTableModel->getCellContent().size()>1) + // { + // if(m_pTableModel->hasRowHeaders()) + // m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index); + // m_pTableModel->getCellContent().erase(m_pTableModel->getCellContent().begin()+Event.index); + // + // } + // else + // { + // if(m_pTableModel->hasRowHeaders()) + // m_pTableModel->getRowHeaderName().clear(); + // m_pTableModel->getCellContent().clear(); + // //m_pImpl->nRowCount=0; + // } + //} + ////pTable->InvalidateDataWindow(Event.index, true); + //m_pTableModel->setRowCount(m_pTableModel->getCellContent().size()); + //pTable->InvalidateDataWindow(Event.index, true); TableControl* pTable = (TableControl*)GetWindow(); - //unsigned int rows =m_pImpl->aCellContent.size()-1; if(Event.index == -1) { if(m_pTableModel->hasRowHeaders()) m_pTableModel->getRowHeaderName().clear(); + //::std::vector >::iterator iter = m_pTableModel->getCellContent().begin(); + //for(;iter!=m_pTableModel->getCellContent().end();++iter) + //{ + // std::vector vectIn = *iter; + // std::vector::iterator iterIn = vectIn.begin(); + // for(;iterIn!=vectIn.end();++iterIn) + // DELETEZ(*iterIn); + //} m_pTableModel->getCellContent().clear(); - if(pTable->isAccessibleAlive()) - { - pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange(DELETE, 0, m_pTableModel->getColumnCount(), 0, m_pTableModel->getColumnCount())), - Any()); - } } - else + else if(Event.index >= 0 && Event.index < m_pTableModel->getRowCount()) { pTable->removeSelectedRow(Event.index); - if(m_pTableModel->getCellContent().size()>1) - { - if(m_pTableModel->hasRowHeaders()) - m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index); - m_pTableModel->getCellContent().erase(m_pTableModel->getCellContent().begin()+Event.index); - } - else - { - if(m_pTableModel->hasRowHeaders()) - m_pTableModel->getRowHeaderName().clear(); - m_pTableModel->getCellContent().clear(); - //m_pImpl->nRowCount=0; - } + if(m_pTableModel->hasRowHeaders()) + m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index); + std::vector >::iterator rowPos =m_pTableModel->getCellContent().begin() + Event.index; + //for ( std::vector::iterator iterIn = rowPos->begin(); + // iterIn != rowPos->end(); + // ++iterIn + // ) + //{ + // DELETEZ(*iterIn); + //} + m_pTableModel->getCellContent().erase( rowPos ); } - //pTable->InvalidateDataWindow(Event.index, true); m_pTableModel->setRowCount(m_pTableModel->getCellContent().size()); pTable->InvalidateDataWindow(Event.index, true); if(pTable->isAccessibleAlive()) { - pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange(DELETE, Event.index, Event.index+1, 0, m_pTableModel->getColumnCount())), - Any()); - //pTable->commitGridControlEvent(CHILD, - // makeAny( pTable->m_pAccessTable->m_pAccessible->getTableHeader(TCTYPE_ROWHEADERBAR)), - // Any()); + pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, + makeAny( AccessibleTableModelChange(DELETE, Event.index, Event.index+1, 0, m_pTableModel->getColumnCount())), + Any()); + //pTable->commitGridControlEvent(CHILD, + // makeAny( pTable->m_pAccessTable->m_pAccessible->getTableHeader(TCTYPE_ROWHEADERBAR)), + // Any()); //for (sal_Int32 i = 0 ; i <= m_pTableModel->getColumnCount() ; ++i) //{ // pTable->commitGridControlEvent( // CHILD, // makeAny( pTable->m_pAccessTable->m_pAccessible->getTable() ), // Any()); - //} + //} } //pTable->Invalidate(); } diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index 9ca6901681c9..c8b8af574a61 100755 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -78,11 +78,6 @@ public: ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); //::com::sun::star::awt::grid::XGridControl - ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL getColumnModel( ) throw (::com::sun::star::uno::RuntimeException); - void SAL_CALL setColumnModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >& model ) throw (::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL getDataModel( ) throw (::com::sun::star::uno::RuntimeException); - void SAL_CALL setDataModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >& model ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException); @@ -96,11 +91,13 @@ public: virtual void SAL_CALL addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException); void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); void SAL_CALL setVisible(sal_Bool bVisible) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL setFocus() throw(::com::sun::star::uno::RuntimeException); + ::rtl::OUString impl_convertToString(::com::sun::star::uno::Any _value); }; #endif // _SVT_GRIDCONTROL_HXX_ diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index b4ddc2cc472d..d1eaee98e7bb 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -45,22 +45,34 @@ using ::rtl::OUString; using namespace ::svt::table; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- UnoControlTableColumn::UnoControlTableColumn(Reference m_xGridColumn) :m_nID( 0 ) ,m_sName() - ,m_bIsResizable( false ) - ,m_nWidth( 10 * 100 ) // 1 cm + ,m_bIsResizable( true ) + ,m_nWidth( 4 ) ,m_nMinWidth( 0 ) // no min width ,m_nMaxWidth( 0 ) // no max width + ,m_nPrefWidth ( 0 ) + ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0)) { //m_nID = m_xGridColumn->getIdentifier(); //m_nWidth = m_xGridColumn->getColumnWidth(); m_sName = m_xGridColumn->getTitle(); } + //-------------------------------------------------------------------- + UnoControlTableColumn::UnoControlTableColumn() + :m_nID( 0 ) + ,m_sName() + ,m_bIsResizable( true ) + ,m_nWidth( 4 ) + ,m_nMinWidth( 0 ) // no min width + ,m_nMaxWidth( 0 ) // no max width + ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0)) + { + } //-------------------------------------------------------------------- ColumnID UnoControlTableColumn::getID() const @@ -91,7 +103,6 @@ using namespace ::com::sun::star::awt::grid; m_sName = _rName; // TODO: notifications? } - //-------------------------------------------------------------------- bool UnoControlTableColumn::isResizable() const { @@ -143,6 +154,29 @@ using namespace ::com::sun::star::awt::grid; m_nMaxWidth = _nMaxWidth; // TODO: notifications? } + //-------------------------------------------------------------------- + TableMetrics UnoControlTableColumn::getPreferredWidth() const + { + return m_nPrefWidth; + } + + //-------------------------------------------------------------------- + void UnoControlTableColumn::setPreferredWidth( TableMetrics _nPrefWidth ) + { + m_nPrefWidth = _nPrefWidth; + // TODO: notifications? + } + //-------------------------------------------------------------------- + ::com::sun::star::style::HorizontalAlignment UnoControlTableColumn::getHorizontalAlign() + { + return m_xHorizontalAlign; + } + + //-------------------------------------------------------------------- + void UnoControlTableColumn::setHorizontalAlign( com::sun::star::style::HorizontalAlignment _align ) + { + m_xHorizontalAlign = _align; + } //==================================================================== //= DefaultTableModel_Impl @@ -153,26 +187,44 @@ using namespace ::com::sun::star::awt::grid; TableSize nRowCount; bool bHasColumnHeaders; bool bHasRowHeaders; + bool bVScroll; + bool bHScroll; PTableRenderer pRenderer; PTableInputHandler pInputHandler; TableMetrics nRowHeight; TableMetrics nColumnHeaderHeight; TableMetrics nRowHeaderWidth; std::vector& aRowHeadersTitle; - std::vector >& aCellContent; + //std::vector >& aCellContent; + std::vector >& aCellContent; + ::com::sun::star::util::Color m_xLineColor; + ::com::sun::star::util::Color m_xHeaderColor; + ::com::sun::star::util::Color m_xTextColor; + ::com::sun::star::util::Color m_xRowColor1; + ::com::sun::star::util::Color m_xRowColor2; + ::com::sun::star::style::VerticalAlignment m_xVerticalAlign; UnoControlTableModel_Impl() :aColumns ( *(new std::vector< PColumnModel> (0))) ,nRowCount ( 0 ) ,bHasColumnHeaders ( false ) ,bHasRowHeaders ( false ) + ,bVScroll ( false ) + ,bHScroll ( false ) ,pRenderer ( ) ,pInputHandler ( ) - ,nRowHeight ( 4 * 100 ) // 40 mm - ,nColumnHeaderHeight( 5 * 100 ) // 50 mm - ,nRowHeaderWidth ( 10 * 100 ) // 50 mm + ,nRowHeight ( 15 ) // 40 mm + ,nColumnHeaderHeight( 10 ) // 50 mm + ,nRowHeaderWidth ( 10 ) // 50 mm ,aRowHeadersTitle ( *(new std::vector(0))) - ,aCellContent ( *(new std::vector >(0))) + //,aCellContent ( *(new std::vector >(0))) + ,aCellContent ( *(new std::vector >(0)) ) + ,m_xLineColor( 0xFFFFFF ) + ,m_xHeaderColor( 0xFFFFFF ) + ,m_xTextColor( 0 ) //black as default + ,m_xRowColor1( 0xFFFFFF ) + ,m_xRowColor2( 0xFFFFFF ) + ,m_xVerticalAlign(com::sun::star::style::VerticalAlignment(0)) { } }; @@ -193,6 +245,17 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- UnoControlTableModel::~UnoControlTableModel() { + //if(!m_pImpl->aCellContent.empty()) + //{ + // ::std::vector >::iterator iter = m_pImpl->aCellContent.begin(); + // for(;iter!=m_pImpl->aCellContent.end();++iter) + // { + // std::vector vectIn = *iter; + // std::vector::iterator iterIn = vectIn.begin(); + // for(;iterIn!=vectIn.end();++iterIn) + // DELETEZ(*iterIn); + // } + //} DELETEZ( m_pImpl ); } @@ -324,6 +387,17 @@ using namespace ::com::sun::star::awt::grid; DBG_ASSERT( hasRowHeaders(), "DefaultTableModel::getRowHeaderWidth: invalid call!" ); return m_pImpl->nRowHeaderWidth; } + //-------------------------------------------------------------------- + void UnoControlTableModel::setColumnHeaderHeight(TableMetrics _nHeight) + { + m_pImpl->nColumnHeaderHeight = _nHeight; + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::setRowHeaderWidth(TableMetrics _nWidth) + { + m_pImpl->nRowHeaderWidth = _nWidth; + } //-------------------------------------------------------------------- void UnoControlTableModel::SetTitleHeight( TableMetrics _nHeight ) @@ -344,7 +418,7 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- ScrollbarVisibility UnoControlTableModel::getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const { - if(overAllHeight>=actHeight)// && !m_bVScroll) + if(overAllHeight>=actHeight && !m_pImpl->bVScroll) return ScrollbarShowNever; else return ScrollbarShowAlways; @@ -353,38 +427,88 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- ScrollbarVisibility UnoControlTableModel::getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const { - if(overAllWidth>=actWidth)// && !m_bHScroll) + if(overAllWidth>=actWidth && !m_pImpl->bHScroll) return ScrollbarShowNever; else return ScrollbarShowAlways; } //-------------------------------------------------------------------- - void UnoControlTableModel::setCellContent(std::vector > cellContent) + void UnoControlTableModel::setVerticalScrollbarVisibility(bool _bVScroll) const { - //if(cellContent.empty()) - //{ - // unsigned int i = m_pImpl->aColumns.size(); - // std::vector& emptyCells; - // while(i!=0) - // { - // cellContent.push_back(emptyCells); - // --i; - // } - //} - //std::vector cCC; - //for(::std::vector >::iterator iter = cellContent.begin(); iter!= cellContent.end();++iter) - //{ - // cCC = *iter; - // m_pImpl->aCellContent.push_back(cCC); - //} + m_pImpl->bVScroll = _bVScroll; + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::setHorizontalScrollbarVisibility(bool _bHScroll) const + { + m_pImpl->bHScroll = _bHScroll; + } + //-------------------------------------------------------------------- + bool UnoControlTableModel::hasVerticalScrollbar() + { + return m_pImpl->bVScroll; + } + //-------------------------------------------------------------------- + bool UnoControlTableModel::hasHorizontalScrollbar() + { + return m_pImpl->bHScroll; + } + //-------------------------------------------------------------------- + // void UnoControlTableModel::setCellContent(std::vector > cellContent) + // { + // //if(cellContent.empty()) + // //{ + // // unsigned int i = m_pImpl->aColumns.size(); + // // std::vector& emptyCells; + // // while(i!=0) + // // { + // // cellContent.push_back(emptyCells); + // // --i; + // // } + // //} + // //std::vector cCC; + // //for(::std::vector >::iterator iter = cellContent.begin(); iter!= cellContent.end();++iter) + // //{ + // // cCC = *iter; + // // m_pImpl->aCellContent.push_back(cCC); + // //} + // m_pImpl->aCellContent.swap( cellContent ); + // } + + //std::vector >& UnoControlTableModel::getCellContent() + // { + // return m_pImpl->aCellContent; + // } + //-------------------------------------------------------------------- + void UnoControlTableModel::setCellContent(std::vector > cellContent) + { + //::vos::OGuard aGuard( GetMutex() ); + /* + if(cellContent.empty()) + { + unsigned int i = m_pImpl->aColumns.size(); + std::vector emptyCells; + while(i!=0) + { + cellContent.push_back(emptyCells); + --i; + } + } + */ + m_pImpl->aCellContent.swap( cellContent ); + + /*for(::std::vector >::iterator iter = cellContent.begin(); iter!= cellContent.end();++iter) + { + m_pImpl->aCellContent.push_back(*iter); + }*/ } - std::vector >& UnoControlTableModel::getCellContent() + std::vector >& UnoControlTableModel::getCellContent() { + //::vos::OGuard aGuard( GetMutex() ); return m_pImpl->aCellContent; } - //-------------------------------------------------------------------- void UnoControlTableModel::setRowHeaderName(std::vector cellColumnContent) { @@ -408,4 +532,70 @@ using namespace ::com::sun::star::awt::grid; { return m_pImpl->aRowHeadersTitle; } + //-------------------------------------------------------------------- + ::com::sun::star::util::Color UnoControlTableModel::getLineColor() + { + return m_pImpl->m_xLineColor; + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::setLineColor( ::com::sun::star::util::Color _rColor ) + { + m_pImpl->m_xLineColor = _rColor; + } + //-------------------------------------------------------------------- + ::com::sun::star::util::Color UnoControlTableModel::getHeaderBackgroundColor() + { + return m_pImpl->m_xHeaderColor; + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::setHeaderBackgroundColor( ::com::sun::star::util::Color _rColor ) + { + m_pImpl->m_xHeaderColor = _rColor; + } + //-------------------------------------------------------------------- + ::com::sun::star::util::Color UnoControlTableModel::getTextColor() + { + return m_pImpl->m_xTextColor; + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::setTextColor( ::com::sun::star::util::Color _rColor ) + { + m_pImpl->m_xTextColor = _rColor; + } + //-------------------------------------------------------------------- + ::com::sun::star::util::Color UnoControlTableModel::getOddRowBackgroundColor() + { + return m_pImpl->m_xRowColor1; + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::setOddRowBackgroundColor( ::com::sun::star::util::Color _rColor ) + { + m_pImpl->m_xRowColor1 = _rColor; + } + //-------------------------------------------------------------------- + ::com::sun::star::util::Color UnoControlTableModel::getEvenRowBackgroundColor() + { + return m_pImpl->m_xRowColor2; + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::setEvenRowBackgroundColor( ::com::sun::star::util::Color _rColor ) + { + m_pImpl->m_xRowColor2 = _rColor; + } + //-------------------------------------------------------------------- + com::sun::star::style::VerticalAlignment UnoControlTableModel::getVerticalAlign() + { + return m_pImpl->m_xVerticalAlign; + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::setVerticalAlign( com::sun::star::style::VerticalAlignment _xAlign ) + { + m_pImpl->m_xVerticalAlign = _xAlign; + } diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index fe3d1f28e9ed..cff18f4d9be2 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -44,6 +44,9 @@ #include #include #include +#include +#include +#include //#include @@ -60,9 +63,12 @@ class UnoControlTableColumn : public IColumnModel TableMetrics m_nWidth; TableMetrics m_nMinWidth; TableMetrics m_nMaxWidth; + TableMetrics m_nPrefWidth; + ::com::sun::star::style::HorizontalAlignment m_xHorizontalAlign; public: UnoControlTableColumn(Reference); + UnoControlTableColumn(); // IColumnModel overridables virtual ColumnID getID() const; @@ -77,6 +83,10 @@ class UnoControlTableColumn : public IColumnModel virtual void setMinWidth( TableMetrics _nMinWidth ); virtual TableMetrics getMaxWidth() const; virtual void setMaxWidth( TableMetrics _nMaxWidth ); + virtual TableMetrics getPreferredWidth() const; + virtual void setPreferredWidth( TableMetrics _nPrefWidth ); + virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign(); + virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign); }; struct UnoControlTableModel_Impl; @@ -94,6 +104,10 @@ class UnoControlTableColumn : public IColumnModel inline TableMetrics GetRowHeight() const { return getRowHeight(); } /// sets a new row height. void setRowHeight( TableMetrics _nHeight ); + /// sets a new row header width. + void setRowHeaderWidth( TableMetrics _nWidth ); + /// sets a new column header height. + void setColumnHeaderHeight( TableMetrics _nHeight ); /// returns the height of the title row (containing the column headers) inline TableMetrics GetTitleHeight() const { return getColumnHeaderHeight(); } @@ -135,10 +149,26 @@ class UnoControlTableColumn : public IColumnModel virtual TableMetrics getRowHeaderWidth() const; virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const; virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const; - virtual void setCellContent(std::vector > cellContent); - virtual std::vector >& getCellContent(); + virtual void setVerticalScrollbarVisibility(bool _bVScroll) const; + virtual void setHorizontalScrollbarVisibility(bool _bHScroll) const; + virtual void setCellContent(std::vector > cellContent); + virtual std::vector >& getCellContent(); virtual void setRowHeaderName(std::vector cellColumnContent); virtual std::vector& getRowHeaderName(); + virtual ::com::sun::star::util::Color getLineColor(); + virtual void setLineColor(::com::sun::star::util::Color _rColor); + virtual ::com::sun::star::util::Color getHeaderBackgroundColor(); + virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor); + virtual ::com::sun::star::util::Color getTextColor(); + virtual void setTextColor(::com::sun::star::util::Color _rColor); + virtual ::com::sun::star::util::Color getOddRowBackgroundColor(); + virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor); + virtual ::com::sun::star::util::Color getEvenRowBackgroundColor(); + virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor); + virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign(); + virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); + virtual bool hasVerticalScrollbar(); + virtual bool hasHorizontalScrollbar(); }; inline void UnoControlTableModel::SetColumnWidth( ColPos _nColumn, TableMetrics _nWidth100thMM ) -- cgit From 9945f4ca9649f961bbc6d9f5be238771e3e2b96c Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Mon, 15 Feb 2010 14:45:34 +0100 Subject: recent changes for grid control --- toolkit/source/controls/grid/defaultgriddatamodel.cxx | 2 +- toolkit/source/controls/grid/gridcolumn.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index c564618336af..2d695a9bad0a 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -30,7 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" -#include "DefaultGridDataModel.hxx" +#include "defaultgriddatamodel.hxx" #include #include #include diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index e8dadc527fbd..40c2018c4cc5 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -162,13 +162,13 @@ void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star: bResizeable = value; } //--------------------------------------------------------------------- -HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() +HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) { return horizontalAlign; } //--------------------------------------------------------------------- -void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) +void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) { horizontalAlign = align; } -- cgit From 0eb1dc13a52d83ea03a7731876172485c6aa2671 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Fri, 19 Feb 2010 14:17:41 +0100 Subject: sw33bf03: #i108851# reintroduction of by accident removed parts of fix for issue i59051 --- svx/source/unodraw/unoshape.cxx | 81 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index bd1d71d36612..ca7ee8fa84fd 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -606,6 +606,37 @@ void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw() } } +//---------------------------------------------------------------------- +// --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051 +void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw() +{ + DBG_TESTSOLARMUTEX(); + if(mpModel) + { + SfxMapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0); + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + switch(eMapUnit) + { + case SFX_MAPUNIT_TWIP : + { + basegfx::B2DHomMatrix aTransform; + const double fMMToTWIPS(72.0 / 127.0); + + aTransform.scale(fMMToTWIPS, fMMToTWIPS); + rPolyPolygon.transform(aTransform); + break; + } + default: + { + DBG_ERROR("Missing unit translation to PoolMetric!"); + } + } + } + } +} +// <-- + //---------------------------------------------------------------------- void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw() { @@ -633,6 +664,37 @@ void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw() } } +//---------------------------------------------------------------------- +// --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051 +void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) const throw() +{ + DBG_TESTSOLARMUTEX(); + SfxMapUnit eMapUnit = SFX_MAPUNIT_100TH_MM; + if(mpModel) + { + eMapUnit = mpModel->GetItemPool().GetMetric(0); + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + switch(eMapUnit) + { + case SFX_MAPUNIT_TWIP : + { + basegfx::B2DHomMatrix aTransform; + const double fTWIPSToMM(127.0 / 72.0); + + aTransform.scale(fTWIPSToMM, fTWIPSToMM); + rPolyPolygon.transform(aTransform); + break; + } + default: + { + DBG_ERROR("Missing unit translation to 100th mm!"); + } + } + } + } +} +// <-- //---------------------------------------------------------------------- void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet) { @@ -2489,10 +2551,15 @@ bool SvxShape::setPropertyValueImpl( const ::rtl::OUString&, const SfxItemProper if( rValue >>= aUnoPoint ) { Point aPoint( aUnoPoint.X, aUnoPoint.Y ); + + // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051 + // perform metric change before applying anchor position, + // because the anchor position is in pool metric. + ForceMetricToItemPoolMetric( aPoint ); + // <-- if( mpModel->IsWriter() ) aPoint += mpObj->GetAnchorPos(); - ForceMetricToItemPoolMetric( aPoint ); pEdgeObj->SetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS, aPoint ); return true; } @@ -2516,6 +2583,9 @@ bool SvxShape::setPropertyValueImpl( const ::rtl::OUString&, const SfxItemProper if ( rValue >>= aPolyPoly ) { basegfx::B2DPolyPolygon aNewPolyPolygon( SvxConvertPolyPolygonBezierToB2DPolyPolygon( &aPolyPoly ) ); + // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051 + ForceMetricToItemPoolMetric( aNewPolyPolygon ); + // <-- if( mpModel->IsWriter() ) { Point aPoint( mpObj->GetAnchorPos() ); @@ -2538,6 +2608,9 @@ bool SvxShape::setPropertyValueImpl( const ::rtl::OUString&, const SfxItemProper { Point aPoint( aUnoPoint.X, aUnoPoint.Y ); + // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051 + ForceMetricToItemPoolMetric( aPoint ); + // <-- if( mpModel->IsWriter() ) aPoint += mpObj->GetAnchorPos(); @@ -2954,6 +3027,9 @@ bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemProper Point aPoint( mpObj->GetAnchorPos() ); aPolyPoly.transform(basegfx::tools::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y())); } + // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue 59051 + ForceMetricTo100th_mm( aPolyPoly ); + // <-- drawing::PolyPolygonBezierCoords aRetval; SvxConvertB2DPolyPolygonToPolyPolygonBezier( aPolyPoly, aRetval); rValue <<= aRetval; @@ -2974,6 +3050,9 @@ bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemProper if( mpModel->IsWriter() ) aPoint -= mpObj->GetAnchorPos(); + // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue 59051 + ForceMetricTo100th_mm( aPoint ); + // <-- awt::Point aUnoPoint( aPoint.X(), aPoint.Y() ); rValue <<= aUnoPoint; -- cgit From ad468a24d60160c9b3e2b184cb2daa1e2f137a08 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Fri, 26 Feb 2010 15:43:56 +0100 Subject: sw33bf03: #i100611#,#i107834# - method - remove adjustment to determined screen due to an arbitrary text string rendering and apply cmc's patch to preserve "faked" font properties (weight and italic) --- sw/source/core/txtnode/fntcache.cxx | 179 +----------------------------------- 1 file changed, 5 insertions(+), 174 deletions(-) diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 7aec6d4e9884..3a2c7ddc3f0e 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -447,8 +447,6 @@ USHORT SwFntObj::GetFontLeading( const ViewShell *pSh, const OutputDevice& rOut void SwFntObj::CreateScrFont( const ViewShell& rSh, const OutputDevice& rOut ) { -static sal_Char __READONLY_DATA sStandardString[] = "Dies ist der Teststring"; - if ( pScrFont ) return; @@ -484,6 +482,11 @@ static sal_Char __READONLY_DATA sStandardString[] = "Dies ist der Teststring"; pScrFont = pPrtFont; FontMetric aMet = pPrt->GetFontMetric( ); + //Don't loose "faked" properties of the logical font that don't truly + //exist in the physical font metrics which vcl which fake up for us + aMet.SetWeight(pScrFont->GetWeight()); + aMet.SetItalic(pScrFont->GetItalic()); + bSymbol = RTL_TEXTENCODING_SYMBOL == aMet.GetCharSet(); if ( USHRT_MAX == nGuessedLeading ) @@ -492,178 +495,6 @@ static sal_Char __READONLY_DATA sStandardString[] = "Dies ist der Teststring"; if ( USHRT_MAX == nExtLeading ) nExtLeading = static_cast(aMet.GetExtLeading()); -#if OSL_DEBUG_LEVEL > 1 - const XubString aDbgTxt1( pPrtFont->GetName() ); - const XubString aDbgTxt2( aMet.GetName() ); -#endif - - if ( aMet.IsDeviceFont( ) ) - { - if ( (RTL_TEXTENCODING_DONTKNOW == pPrtFont->GetCharSet() || - FAMILY_DONTKNOW == pPrtFont->GetFamily() || - PITCH_DONTKNOW == pPrtFont->GetPitch() ) && - (RTL_TEXTENCODING_DONTKNOW == aMet.GetCharSet() || - FAMILY_DONTKNOW == aMet.GetFamily() || - PITCH_DONTKNOW == aMet.GetPitch() ) ) - { - // Das folgende ist teuer, aber selten: ein unbekannter Font - // kann vom Drucker nicht vernuenftig zugeordnet werden. Dann - // nehmen wir eben das Mapping des Bildschirms in Anspruch und - // setzen den Familyname, Charset und Pitch wie dort. Dieser - // Font wird nun nochmals auf dem Drucker eingestellt. - Font aFnt1 = pOut->GetFontMetric(); - Font aFnt2( *pPrtFont ); - - if (RTL_TEXTENCODING_DONTKNOW == pPrtFont->GetCharSet()) - aFnt2.SetCharSet( aFnt1.GetCharSet() ); - if (FAMILY_DONTKNOW == pPrtFont->GetFamily()) - aFnt2.SetFamily( aFnt1.GetFamily() ); - if (PITCH_DONTKNOW == pPrtFont->GetPitch()) - aFnt2.SetPitch( aFnt1.GetPitch() ); - - pPrt->SetFont( aFnt2 ); - aMet = pPrt->GetFontMetric( ); - } - - const XubString aStandardStr( sStandardString, - RTL_TEXTENCODING_MS_1252 ); - - // This is the reference width - const long nOWidth = pPrt->GetTextWidth( aStandardStr ); - - // Let's have a look what's the difference to the width - // calculated for the output device using the font set at the - // reference device - long nSWidth = nOWidth - pOut->GetTextWidth( aStandardStr ); - nScrHeight = (USHORT) pOut->GetTextHeight(); - - // Um Aerger mit dem Generic Printer aus dem Wege zu gehen. - if( aMet.GetSize().Height() ) - { - BOOL bScrSymbol = FALSE; - CharSet ePrtChSet = aMet.GetCharSet(); - // NoSymbol bedeutet, dass der Drucker sich fuer einen - // Nicht-Symbol-Font entschieden hat. - BOOL bNoSymbol = ( RTL_TEXTENCODING_DONTKNOW != ePrtChSet && - RTL_TEXTENCODING_SYMBOL != ePrtChSet ); - if ( bNoSymbol ) - bScrSymbol = RTL_TEXTENCODING_SYMBOL == - pOut->GetFontMetric().GetCharSet(); - Size aTmp( aMet.GetSize() ); - - if( aTmp.Width() && !pPrtFont->GetSize().Width() ) - { - aTmp.Width() = 0; - aMet.SetSize( aTmp ); - } - - // Now we set the metrics used at the reference device at the - // output device - pOut->SetFont( aMet ); - - if( bNoSymbol && ( bScrSymbol != ( RTL_TEXTENCODING_SYMBOL == - pOut->GetFontMetric().GetCharSet() ) ) ) - { - // Hier landen wir, wenn der Drucker keinen Symbolfont waehlt, - // aber genau einer der beiden Screenfonts ein Symbolfont ist. - // Wir nehmen dann eben den anderen. - if ( bScrSymbol ) - pScrFont = new Font( aMet ); // mit Abgleich - else - pOut->SetFont( *pPrtFont ); // ohne Abgleich - } - else - { - // Let's have a look what's the difference to the width - // calculated for the output device using the metrics set at - // the reference device - long nPWidth = nOWidth - pOut->GetTextWidth( aStandardStr ); - - // We prefer smaller fonts - BYTE nNeg = 0; - if ( nSWidth<0 ) { nSWidth *= -2; nNeg = 1; } - if ( nPWidth<0 ) { nPWidth *= -2; nNeg |= 2; } - - // nSWidth = Difference between string width on reference device - // and string width on output device with user font set. - // nPWidth = Difference between string width on reference device - // and string width on output device with metric obtained - // from reference device. - // We prefer to take the font with the smaller deviation, - // exception: keep the original font unless the deviation - // is really bad (at least 3%) - // Since the test string is neither localized nor has a high resemblance - // of the "real text for this font" a higher deviation is reasonable - - if ( (nSWidth <= nPWidth) - || (nSWidth * 32 <= nOWidth ) ) - { - // No adjustment, we take the same font for the output - // device like for the reference device - pOut->SetFont( *pPrtFont ); - pScrFont = pPrtFont; - nPWidth = nSWidth; - nNeg &= 1; - } - else - { - // The metrics give a better result. So we build - // a new font for the output device based on the - // metrics used at the reference device - pScrFont = new Font( aMet ); // mit Abgleich - nSWidth = nPWidth; - nNeg &= 2; - } - - // - // now pScrFont is set to the better font and this should - // be set at the output device - // - - // we still have to check if the choosed font is not to wide - if( nNeg && nOWidth ) - { - nPWidth *= 100; - nPWidth /= nOWidth; - - // if the screen font is too wide, we try to reduce - // the font height and get a smaller one - if( nPWidth > 25 ) - { - if( nPWidth > 80 ) - nPWidth = 80; - nPWidth = 100 - nPWidth/4; - Size aTmpSize = pScrFont->GetSize(); - aTmpSize.Height() *= nPWidth; - aTmpSize.Height() /= 100; - if( aTmpSize.Width() ) - { - aTmpSize.Width() *= nPWidth; - aTmpSize.Width() /= 100; - } - Font *pNew = new Font( *pScrFont ); - pNew->SetSize( aTmpSize ); - pOut->SetFont( *pNew ); - nPWidth = nOWidth - - pOut->GetTextWidth( aStandardStr ); - if( nPWidth < 0 ) { nPWidth *= -2; } - if( nPWidth < nSWidth ) - { - if( pScrFont != pPrtFont ) - delete pScrFont; - pScrFont = pNew; - } - else - { - delete pNew; - pOut->SetFont( *pScrFont ); - } - } - } - } - } - } - // reset the original reference device font pPrt->SetFont( aOldPrtFnt ); } -- cgit From da0a3a0e7f71bc56a6e4e49b4d0645de6903739c Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 12:39:31 +0000 Subject: npower13_objectmodule: #i109734# object module stuff --- basic/inc/basic/sbmod.hxx | 12 +- basic/inc/basic/sbstar.hxx | 5 + basic/source/basmgr/basmgr.cxx | 40 ++- basic/source/classes/eventatt.cxx | 108 +++++-- basic/source/classes/sb.cxx | 42 ++- basic/source/classes/sbxmod.cxx | 422 ++++++++++++++++++++++++++- basic/source/comp/codegen.cxx | 10 +- basic/source/comp/parser.cxx | 12 +- basic/source/inc/codegen.hxx | 1 + basic/source/inc/image.hxx | 1 - basic/source/inc/namecont.hxx | 9 +- basic/source/inc/runtime.hxx | 2 +- basic/source/inc/scriptcont.hxx | 17 ++ basic/source/runtime/methods.cxx | 18 +- basic/source/runtime/methods1.cxx | 8 +- basic/source/runtime/runtime.cxx | 27 +- basic/source/uno/namecont.cxx | 25 +- basic/source/uno/scriptcont.cxx | 39 +++ oovbaapi/ooo/vba/excel/XWorksheet.idl | 5 +- vbahelper/source/vbahelper/vbaglobalbase.cxx | 7 +- 20 files changed, 745 insertions(+), 65 deletions(-) diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index d73c9780b1bb..81548198726b 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -34,6 +34,7 @@ #ifndef _RTL_USTRING_HXX #include #endif +#include class SbMethod; class SbProperty; @@ -63,6 +64,10 @@ protected: SbiImage* pImage; // the Image SbiBreakpoints* pBreaks; // Breakpoints SbClassData* pClassData; + bool mbVBACompat; + INT32 mnType; + SbxObjectRef pDocObject; // an impl object ( used by Document Modules ) + bool bIsProxyModule; void StartDefinitions(); SbMethod* GetMethod( const String&, SbxDataType ); @@ -87,7 +92,7 @@ protected: public: SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMOD,2); TYPEINFO(); - SbModule( const String& ); + SbModule( const String&, bool bCompat = false ); virtual void SetParent( SbxObject* ); virtual void Clear(); @@ -123,6 +128,11 @@ public: BOOL LoadBinaryData( SvStream& ); BOOL ExceedsLegacyModuleSize(); void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const; + bool IsVBACompat(); + void SetVBACompat( bool bCompat ); + INT32 GetModuleType() { return mnType; } + void SetModuleType( INT32 nType ) { mnType = nType; } + bool GetIsProxyModule() { return bIsProxyModule; } }; #ifndef __SB_SBMODULEREF_HXX diff --git a/basic/inc/basic/sbstar.hxx b/basic/inc/basic/sbstar.hxx index bdc4aa011cc9..a234dc206ec7 100644 --- a/basic/inc/basic/sbstar.hxx +++ b/basic/inc/basic/sbstar.hxx @@ -37,6 +37,7 @@ #include #include +#include class SbModule; // completed module class SbiInstance; // runtime instance @@ -69,6 +70,7 @@ class StarBASIC : public SbxObject BOOL bNoRtl; // if TRUE: do not search RTL BOOL bBreak; // if TRUE: Break, otherwise Step BOOL bDocBasic; + BOOL bVBAEnabled; BasicLibInfo* pLibInfo; // Info block for basic manager SbLanguageMode eLanguageMode; // LanguageMode of the basic object BOOL bQuit; @@ -117,6 +119,7 @@ public: // Compiler-Interface SbModule* MakeModule( const String& rName, const String& rSrc ); SbModule* MakeModule32( const String& rName, const ::rtl::OUString& rSrc ); + SbModule* MakeModule32( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, const ::rtl::OUString& rSrc ); BOOL Compile( SbModule* ); BOOL Disassemble( SbModule*, String& rText ); static void Stop(); @@ -189,6 +192,8 @@ public: ( const String& rName, USHORT& rStatus ); static SbMethod* GetActiveMethod( USHORT nLevel = 0 ); static SbModule* GetActiveModule(); + void SetVBAEnabled( BOOL bEnabled ); + BOOL isVBAEnabled(); // #60175 TRUE: SFX-Resource is not displayed on basic errors static void StaticSuppressSfxResource( BOOL bSuppress ); diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index da792f269fc9..ac7812fd6c66 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -65,6 +66,10 @@ #include #include #include +#include +#include +#include +#include #include @@ -243,7 +248,15 @@ void BasMgrContainerListenerImpl::addLibraryModulesImpl( BasicManager* pMgr, Any aElement = xLibNameAccess->getByName( aModuleName ); ::rtl::OUString aMod; aElement >>= aMod; - pLib->MakeModule32( aModuleName, aMod ); + Reference< XVBAModuleInfo > xVBAModuleInfo( xLibNameAccess, UNO_QUERY ); + if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( aModuleName ) ) + { + ModuleInfo mInfo = xVBAModuleInfo->getModuleInfo( aModuleName ); + OSL_TRACE("#addLibraryModulesImpl - aMod"); + pLib->MakeModule32( aModuleName, mInfo, aMod ); + } + else + pLib->MakeModule32( aModuleName, aMod ); } } @@ -277,11 +290,16 @@ void SAL_CALL BasMgrContainerListenerImpl::elementInserted( const ContainerEvent { Reference< XLibraryContainer > xScriptCont( Event.Source, UNO_QUERY ); insertLibraryImpl( xScriptCont, mpMgr, Event.Element, aName ); + StarBASIC* pLib = mpMgr->GetLib( aName ); + if ( pLib ) + { + Reference xVBACompat( xScriptCont, UNO_QUERY ); + if ( xVBACompat.is() ) + pLib->SetVBAEnabled( xVBACompat->getVBACompatModeOn() ); + } } else { - ::rtl::OUString aMod; - Event.Element >>= aMod; StarBASIC* pLib = mpMgr->GetLib( maLibName ); DBG_ASSERT( pLib, "BasMgrContainerListenerImpl::elementInserted: Unknown lib!"); @@ -290,7 +308,16 @@ void SAL_CALL BasMgrContainerListenerImpl::elementInserted( const ContainerEvent SbModule* pMod = pLib->FindModule( aName ); if( !pMod ) { - pLib->MakeModule32( aName, aMod ); + ::rtl::OUString aMod; + Event.Element >>= aMod; + Reference< XVBAModuleInfo > xVBAModuleInfo( Event.Source, UNO_QUERY ); + if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( aName ) ) + { + ModuleInfo mInfo = xVBAModuleInfo->getModuleInfo( aName ); + pLib->MakeModule32( aName, mInfo, aMod ); + } + else + pLib->MakeModule32( aName, aMod ); pLib->SetModified( FALSE ); } } @@ -319,10 +346,11 @@ void SAL_CALL BasMgrContainerListenerImpl::elementReplaced( const ContainerEvent SbModule* pMod = pLib->FindModule( aName ); ::rtl::OUString aMod; Event.Element >>= aMod; + if( pMod ) - pMod->SetSource32( aMod ); + pMod->SetSource32( aMod ); else - pLib->MakeModule32( aName, aMod ); + pLib->MakeModule32( aName, aMod ); pLib->SetModified( FALSE ); } diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx index 5c57af5b6ce8..1ffa6e374b9a 100644 --- a/basic/source/classes/eventatt.cxx +++ b/basic/source/classes/eventatt.cxx @@ -55,7 +55,10 @@ #include #include - +#include +#include +#include +#include //================================================================================================== #include @@ -450,6 +453,43 @@ Any implFindDialogLibForDialog( const Any& rDlgAny, SbxObject* pBasic ) return aRetDlgLibAny; } +Any implFindDialogLibForDialogBasic( const Any& aAnyISP, SbxObject* pBasic, StarBASIC*& pFoundBasic ) +{ + Any aDlgLibAny; + // Find dialog library for dialog, direct access is not possible here + StarBASIC* pStartedBasic = (StarBASIC*)pBasic; + SbxObject* pParentBasic = pStartedBasic ? pStartedBasic->GetParent() : NULL; + SbxObject* pParentParentBasic = pParentBasic ? pParentBasic->GetParent() : NULL; + + SbxObject* pSearchBasic1 = NULL; + SbxObject* pSearchBasic2 = NULL; + if( pParentParentBasic ) + { + pSearchBasic1 = pParentBasic; + pSearchBasic2 = pParentParentBasic; + } + else + { + pSearchBasic1 = pStartedBasic; + pSearchBasic2 = pParentBasic; + } + if( pSearchBasic1 ) + { + aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic1 ); + + if ( aDlgLibAny.hasValue() ) + pFoundBasic = (StarBASIC*)pSearchBasic1; + + else if( pSearchBasic2 ) + { + aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic2 ); + if ( aDlgLibAny.hasValue() ) + pFoundBasic = (StarBASIC*)pSearchBasic2; + } + } + return aDlgLibAny; +} + static ::rtl::OUString aDecorationPropName = ::rtl::OUString::createFromAscii( "Decoration" ); static ::rtl::OUString aTitlePropName = @@ -529,39 +569,51 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite ) {} } - // Find dialog library for dialog, direct access is not possible here - StarBASIC* pStartedBasic = pINST->GetBasic(); - SbxObject* pParentBasic = pStartedBasic ? pStartedBasic->GetParent() : NULL; - SbxObject* pParentParentBasic = pParentBasic ? pParentBasic->GetParent() : NULL; - - SbxObject* pSearchBasic1 = NULL; - SbxObject* pSearchBasic2 = NULL; - if( pParentParentBasic ) + Any aDlgLibAny; + bool bDocDialog = false; + StarBASIC* pFoundBasic = NULL; + OSL_TRACE("About to try get a hold of ThisComponent"); + Reference< frame::XModel > xModel = getModelFromBasic( pINST->GetBasic() ) ; + aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pINST->GetBasic(), pFoundBasic ); + // If we found the dialog then it belongs to the Search basic + if ( !pFoundBasic ) { - pSearchBasic1 = pParentBasic; - pSearchBasic2 = pParentParentBasic; - } - else + Reference< frame::XDesktop > xDesktop( xMSF->createInstance + ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ), + UNO_QUERY ); + Reference< container::XEnumeration > xModels; + if ( xDesktop.is() ) { - pSearchBasic1 = pStartedBasic; - pSearchBasic2 = pParentBasic; - } - - Any aDlgLibAny; - if( pSearchBasic1 ) + Reference< container::XEnumerationAccess > xComponents( xDesktop->getComponents(), UNO_QUERY ); + if ( xComponents.is() ) + xModels.set( xComponents->createEnumeration(), UNO_QUERY ); + if ( xModels.is() ) + { + while ( xModels->hasMoreElements() ) + { + Reference< frame::XModel > xNextModel( xModels->nextElement(), UNO_QUERY ); + if ( xNextModel.is() ) + { + BasicManager* pMgr = basic::BasicManagerRepository::getDocumentBasicManager( xNextModel ); + if ( pMgr ) + aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pMgr->GetLib(0), pFoundBasic ); + if ( aDlgLibAny.hasValue() ) { - aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic1 ); - if( pSearchBasic2 && aDlgLibAny.getValueType().getTypeClass() == TypeClass_VOID ) - aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic2 ); + bDocDialog = true; + xModel = xNextModel; + break; } - - - OSL_TRACE("About to try get a hold of ThisComponent"); - Reference< frame::XModel > xModel = getModelFromBasic( pStartedBasic ) ; - Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( pStartedBasic, xModel ); + } + } + } + } + } + if ( pFoundBasic ) + bDocDialog = pFoundBasic->IsDocBasic(); + Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( pINST->GetBasic(), xModel ); Sequence< Any > aArgs( 4 ); - aArgs[ 0 ] <<= xModel; + aArgs[ 0 ] <<= bDocDialog ? xModel : uno::Reference< uno::XInterface >(); aArgs[ 1 ] <<= xInput; aArgs[ 2 ] = aDlgLibAny; aArgs[ 3 ] <<= xScriptListener; diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index c5ac53c43092..7f7ac8784742 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -49,12 +49,17 @@ #include "disas.hxx" #include "runtime.hxx" #include +#include #include "stdobj.hxx" #include "filefmt.hxx" #include "sb.hrc" #include #include +#include +#include +using namespace ::com::sun::star::script; + // #pragma SW_SEGMENT_CLASS( SBASIC, SBASIC_CODE ) SV_IMPL_VARARR(SbTextPortions,SbTextPortion) @@ -485,6 +490,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) } } } + SetModuleType( com::sun::star::script::ModuleType::Class ); } SbClassModuleObject::~SbClassModuleObject() @@ -682,6 +688,7 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic ) SetParent( p ); pLibInfo = NULL; bNoRtl = bBreak = FALSE; + bVBAEnabled = FALSE; pModules = new SbxArray; if( !GetSbData()->nInst++ ) @@ -782,7 +789,34 @@ SbModule* StarBASIC::MakeModule( const String& rName, const String& rSrc ) SbModule* StarBASIC::MakeModule32( const String& rName, const ::rtl::OUString& rSrc ) { - SbModule* p = new SbModule( rName ); + ModuleInfo mInfo; + mInfo.ModuleType = ModuleType::Normal; + return MakeModule32( rName, mInfo, rSrc ); +} +SbModule* StarBASIC::MakeModule32( const String& rName, const ModuleInfo& mInfo, const rtl::OUString& rSrc ) +{ + + OSL_TRACE("create module %s type mInfo %d", rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr(), mInfo.ModuleType ); + SbModule* p = NULL; + switch ( mInfo.ModuleType ) + { + case ModuleType::Document: + // In theory we should be able to create Object modules + // in ordinary basic ( in vba mode thought these are create + // by the application/basic and not by the user ) + p = new SbObjModule( rName, mInfo, isVBAEnabled() ); + break; + case ModuleType::Class: + p = new SbModule( rName, isVBAEnabled() ); + p->SetModuleType( com::sun::star::script::ModuleType::Class ); + break; + case ModuleType::Form: + p = new SbUserFormModule( rName, mInfo, isVBAEnabled() ); + break; + default: + p = new SbModule( rName, isVBAEnabled() ); + + } p->SetSource32( rSrc ); p->SetParent( this ); pModules->Insert( p, pModules->Count() ); @@ -958,6 +992,12 @@ SbxVariable* StarBASIC::Find( const String& rName, SbxClassType t ) } pNamed = p; } + // Only variables qualified by the Module Name e.g. Sheet1.foo + // should work for Documant && Class type Modules + INT32 nType = p->GetModuleType(); + if ( nType == com::sun::star::script::ModuleType::Document || nType == com::sun::star::script::ModuleType::Form ) + continue; + // otherwise check if the element is available // unset GBLSEARCH-Flag (due to Rekursion) USHORT nGblFlag = p->GetFlags() & SBX_GBLSEARCH; diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 092ef458041e..fceda108bbd8 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -52,6 +52,8 @@ #include #include +#include +#include // for the bsearch @@ -72,6 +74,13 @@ #include using namespace ::com::sun::star; +#include +#include +#include +#include +#include +#include +#include TYPEINIT1(SbModule,SbxObject) TYPEINIT1(SbMethod,SbxMethod) @@ -79,6 +88,8 @@ TYPEINIT1(SbProperty,SbxProperty) TYPEINIT1(SbProcedureProperty,SbxProperty) TYPEINIT1(SbJScriptModule,SbModule) TYPEINIT1(SbJScriptMethod,SbMethod) +TYPEINIT1(SbObjModule,SbModule) +TYPEINIT1(SbUserFormModule,SbObjModule) SV_DECL_VARARR(SbiBreakpoints,USHORT,4,4) SV_IMPL_VARARR(SbiBreakpoints,USHORT) @@ -148,12 +159,13 @@ bool UnlockControllerHack( StarBASIC* pBasic ) // Ein BASIC-Modul hat EXTSEARCH gesetzt, damit die im Modul enthaltenen // Elemente von anderen Modulen aus gefunden werden koennen. -SbModule::SbModule( const String& rName ) +SbModule::SbModule( const String& rName, bool bVBACompat ) : SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("StarBASICModule") ) ), - pImage( NULL ), pBreaks( NULL ), pClassData( NULL ) + pImage( NULL ), pBreaks( NULL ), pClassData( NULL ), mbVBACompat( bVBACompat ), pDocObject( NULL ), bIsProxyModule( false ) { SetName( rName ); SetFlag( SBX_EXTSEARCH | SBX_GBLSEARCH ); + SetModuleType( com::sun::star::script::ModuleType::Normal ); } SbModule::~SbModule() @@ -328,7 +340,10 @@ void SbModule::Clear() SbxVariable* SbModule::Find( const XubString& rName, SbxClassType t ) { + // make sure a search in an uninstatiated class module will fail SbxVariable* pRes = SbxObject::Find( rName, t ); + if ( bIsProxyModule ) + return NULL; if( !pRes && pImage ) { SbiInstance* pInst = pINST; @@ -430,6 +445,7 @@ void SbModule::SetSource32( const ::rtl::OUString& r ) aOUSource = r; StartDefinitions(); SbiTokenizer aTok( r ); + aTok.SetCompatible( IsVBACompat() ); while( !aTok.IsEof() ) { SbiToken eEndTok = NIL; @@ -454,13 +470,6 @@ void SbModule::SetSource32( const ::rtl::OUString& r ) { eEndTok = ENDPROPERTY; break; } - if( eCurTok == OPTION ) - { - eCurTok = aTok.Next(); - if( eCurTok == COMPATIBLE - || ( ( eCurTok == VBASUPPORT ) && ( aTok.Next() == NUMBER ) && ( aTok.GetDbl()== 1 ) ) ) - aTok.SetCompatible( true ); - } } eLastTok = eCurTok; } @@ -600,7 +609,15 @@ void ClearUnoObjectsInRTL_Impl( StarBASIC* pBasic ) if( ((StarBASIC*)p) != pBasic ) ClearUnoObjectsInRTL_Impl_Rek( (StarBASIC*)p ); } +bool SbModule::IsVBACompat() +{ + return mbVBACompat; +} +void SbModule::SetVBACompat( bool bCompat ) +{ + mbVBACompat = bCompat; +} // Ausfuehren eines BASIC-Unterprogramms USHORT SbModule::Run( SbMethod* pMeth ) { @@ -695,10 +712,9 @@ USHORT SbModule::Run( SbMethod* pMeth ) if( pRt->pNext ) pRt->pNext->block(); pINST->pRun = pRt; - if ( SbiRuntime ::isVBAEnabled() ) + if ( mbVBACompat ) { pINST->EnableCompatibility( TRUE ); - pRt->SetVBAEnabled( true ); } while( pRt->Step() ) {} if( pRt->pNext ) @@ -1482,6 +1498,390 @@ SbJScriptMethod::~SbJScriptMethod() {} +///////////////////////////////////////////////////////////////////////// +SbObjModule::SbObjModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVbaCompatible ) + : SbModule( rName, bIsVbaCompatible ) +{ + SetModuleType( mInfo.ModuleType ); + if ( mInfo.ModuleType == script::ModuleType::Form ) + { + SetClassName( rtl::OUString::createFromAscii( "Form" ) ); + } + else if ( mInfo.ModuleObject.is() ) + SetUnoObject( uno::makeAny( mInfo.ModuleObject ) ); +} +void +SbObjModule::SetUnoObject( const uno::Any& aObj ) throw ( uno::RuntimeException ) +{ + SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,(SbxVariable*)pDocObject); + if ( pUnoObj && pUnoObj->getUnoAny() == aObj ) // object is equal, nothing to do + return; + pDocObject = new SbUnoObject( GetName(), uno::makeAny( aObj ) ); + + com::sun::star::uno::Reference< com::sun::star::lang::XServiceInfo > xServiceInfo( aObj, com::sun::star::uno::UNO_QUERY_THROW ); + if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "ooo.vba.excel.Worksheet" ) ) ) + { + SetClassName( rtl::OUString::createFromAscii( "Worksheet" ) ); + } + else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "ooo.vba.excel.Workbook" ) ) ) + { + SetClassName( rtl::OUString::createFromAscii( "Workbook" ) ); + } +} + +SbxVariable* +SbObjModule::GetObject() +{ + return pDocObject; +} +SbxVariable* +SbObjModule::Find( const XubString& rName, SbxClassType t ) +{ + //OSL_TRACE("SbObjectModule find for %s", rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr() ); + SbxVariable* pVar = NULL; + if ( !pVar && pDocObject) + pVar = pDocObject->Find( rName, t ); + if ( !pVar ) + pVar = SbModule::Find( rName, t ); + return pVar; +} + +typedef ::cppu::WeakImplHelper1< awt::XTopWindowListener > EventListener_BASE; + +class FormObjEventListenerImpl : public EventListener_BASE +{ + SbUserFormModule* mpUserForm; + uno::Reference< lang::XComponent > mxComponent; + bool mbDisposed; + sal_Bool mbOpened; + sal_Bool mbActivated; + sal_Bool mbShowing; + FormObjEventListenerImpl(); // not defined + FormObjEventListenerImpl(const FormObjEventListenerImpl&); // not defined +public: + FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent ) : mpUserForm( pUserForm ), mxComponent( xComponent) , mbDisposed( false ), mbOpened( sal_False ), mbActivated( sal_False ), mbShowing( sal_False ) + { + if ( mxComponent.is() ); + { + uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; + //uno::Reference< awt::XWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; + OSL_TRACE("*********** Registering the listener"); + xList->addTopWindowListener( this ); + } + } + + ~FormObjEventListenerImpl() + { + removeListener(); + } + sal_Bool isShowing() { return mbShowing; } + void removeListener() + { + try + { + if ( mxComponent.is() && !mbDisposed ) + { + uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; + OSL_TRACE("*********** Removing the listener"); + xList->removeTopWindowListener( this ); + mxComponent = NULL; + } + } + catch( uno::Exception& ) {} + } + virtual void SAL_CALL windowOpened( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + if ( mpUserForm ) + { + mbOpened = sal_True; + mbShowing = sal_True; + if ( mbActivated ) + { + mbOpened = mbActivated = sal_False; + mpUserForm->triggerActivateEvent(); + } + } + } + + //liuchen 2009-7-21, support Excel VBA Form_QueryClose event + virtual void SAL_CALL windowClosing( const lang::EventObject& e ) throw (uno::RuntimeException) + { +#if IN_THE_FUTURE + uno::Reference< awt::XDialog > xDialog( e.Source, uno::UNO_QUERY ); + if ( xDialog.is() ) + { + uno::Reference< awt::XControl > xControl( xDialog, uno::UNO_QUERY ); + if ( xControl->getPeer().is() ) + { + uno::Reference< document::XVbaMethodParameter > xVbaMethodParameter( xControl->getPeer(), uno::UNO_QUERY ); + if ( xVbaMethodParameter.is() ) + { + sal_Int8 nCancel = 0; + sal_Int8 nCloseMode = 0; + + Sequence< Any > aParams; + aParams.realloc(2); + aParams[0] <<= nCancel; + aParams[1] <<= nCloseMode; + + mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ), + aParams); + xVbaMethodParameter->setVbaMethodParameter( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cancel")), aParams[0]); + return; + + } + } + } + + mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ) ); +#endif + } + //liuchen 2009-7-21 + + virtual void SAL_CALL windowClosed( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { mbOpened = sal_False; mbShowing = sal_False; } + virtual void SAL_CALL windowMinimized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) {} + virtual void SAL_CALL windowNormalized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException){} + virtual void SAL_CALL windowActivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + if ( mpUserForm ) + { + mbActivated = sal_True; + if ( mbOpened ) + { + mbOpened = mbActivated = sal_False; + mpUserForm->triggerActivateEvent(); + } + } + } + + virtual void SAL_CALL windowDeactivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + if ( mpUserForm ) + mpUserForm->triggerDeActivateEvent(); + } + + + virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw (uno::RuntimeException) + { + OSL_TRACE("** Userform/Dialog disposing"); + mbDisposed = true; + uno::Any aSource; + aSource <<= Source; + mxComponent = NULL; + if ( mpUserForm ) + mpUserForm->ResetApiObj(); + } +}; + +SbUserFormModule::SbUserFormModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsCompat ) + :SbObjModule( rName, mInfo, bIsCompat ), mbInit( false ) +{ + m_xModel.set( mInfo.ModuleObject, uno::UNO_QUERY_THROW ); +} + +void SbUserFormModule::ResetApiObj() +{ + if ( m_xDialog.is() ) // probably someone close the dialog window + { + triggerTerminateEvent(); + } + pDocObject = NULL; + m_xDialog = NULL; +} + +void SbUserFormModule::triggerMethod( const String& aMethodToRun ) +{ + Sequence< Any > aArguments; + triggerMethod( aMethodToRun, aArguments ); +} +void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& aArguments) +{ + OSL_TRACE("*** trigger %s ***", rtl::OUStringToOString( aMethodToRun, RTL_TEXTENCODING_UTF8 ).getStr() ); + // Search method + SbxVariable* pMeth = SbObjModule::Find( aMethodToRun, SbxCLASS_METHOD ); + if( pMeth ) + { +#if IN_THE_FUTURE + //liuchen 2009-7-21, support Excel VBA UserForm_QueryClose event with parameters + if ( aArguments.getLength() > 0 ) // Setup parameters + { + SbxArrayRef xArray = new SbxArray; + xArray->Put( pMeth, 0 ); // Method as parameter 0 + + for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i ) + { + SbxVariableRef xSbxVar = new SbxVariable( SbxVARIANT ); + unoToSbxValue( static_cast< SbxVariable* >( xSbxVar ), aArguments[i] ); + xArray->Put( xSbxVar, static_cast< USHORT >( i ) + 1 ); + + // Enable passing by ref + if ( xSbxVar->GetType() != SbxVARIANT ) + xSbxVar->SetFlag( SBX_FIXED ); + } + pMeth->SetParameters( xArray ); + + SbxValues aVals; + pMeth->Get( aVals ); + + for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i ) + { + aArguments[i] = sbxToUnoValue( xArray->Get( static_cast< USHORT >(i) + 1) ); + } + pMeth->SetParameters( NULL ); + } + else +//liuchen 2009-7-21 +#endif + { + SbxValues aVals; + pMeth->Get( aVals ); + } + } +} + +void SbUserFormModule::triggerActivateEvent( void ) +{ + OSL_TRACE("**** entering SbUserFormModule::triggerActivate"); + triggerMethod( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserForm_activate") ) ); + OSL_TRACE("**** leaving SbUserFormModule::triggerActivate"); +} + +void SbUserFormModule::triggerDeActivateEvent( void ) +{ + OSL_TRACE("**** SbUserFormModule::triggerDeActivate"); + triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_DeActivate") ) ); +} + +void SbUserFormModule::triggerInitializeEvent( void ) + +{ + if ( mbInit ) + return; + OSL_TRACE("**** SbUserFormModule::triggerInitializeEvent"); + static String aInitMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Initialize") ); + triggerMethod( aInitMethodName ); + mbInit = true; +} + +void SbUserFormModule::triggerTerminateEvent( void ) +{ + OSL_TRACE("**** SbUserFormModule::triggerTerminateEvent"); + static String aTermMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Terminate") ); + triggerMethod( aTermMethodName ); + mbInit=false; +} + +void SbUserFormModule::load() +{ + OSL_TRACE("** load() "); + // forces a load + if ( !pDocObject ) + InitObject(); +} + +//liuchen 2009-7-21 change to accmordate VBA's beheavior +void SbUserFormModule::Unload() +{ + OSL_TRACE("** Unload() "); + + sal_Int8 nCancel = 0; + sal_Int8 nCloseMode = 1; + + Sequence< Any > aParams; + aParams.realloc(2); + aParams[0] <<= nCancel; + aParams[1] <<= nCloseMode; + + triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ), aParams); + + aParams[0] >>= nCancel; + if (nCancel == 1) + { + return; + } + + if ( m_xDialog.is() ) + { + triggerTerminateEvent(); + } + // Search method + SbxVariable* pMeth = SbObjModule::Find( String( RTL_CONSTASCII_USTRINGPARAM( "UnloadObject" ) ), SbxCLASS_METHOD ); + if( pMeth ) + { + OSL_TRACE("Attempting too run the UnloadObjectMethod"); + m_xDialog = NULL; //release ref to the uno object + SbxValues aVals; + FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() ); + bool bWaitForDispose = true; // assume dialog is showing + if ( pFormListener ) + { + bWaitForDispose = pFormListener->isShowing(); + OSL_TRACE("Showing %d", bWaitForDispose ); + } + pMeth->Get( aVals); + if ( !bWaitForDispose ) + { + // we've either already got a dispose or we'er never going to get one + ResetApiObj(); + } // else wait for dispose + OSL_TRACE("UnloadObject completed ( we hope )"); + } +} +//liuchen + +void SbUserFormModule::InitObject() +{ + try + { + + String aHook( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobals" ) ); + SbUnoObject* pGlobs = (SbUnoObject*)GetParent()->Find( aHook, SbxCLASS_DONTCARE ); + if ( m_xModel.is() && pGlobs ) + { + + uno::Reference< lang::XMultiServiceFactory > xVBAFactory( pGlobs->getUnoAny(), uno::UNO_QUERY_THROW ); + uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); + uno::Sequence< uno::Any > aArgs(1); + aArgs[ 0 ] <<= m_xModel; + rtl::OUString sDialogUrl( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.script:" ) ); + rtl::OUString sProjectName( RTL_CONSTASCII_USTRINGPARAM("Standard") ); + if ( this->GetParent()->GetName().Len() ) + sProjectName = this->GetParent()->GetName(); + sDialogUrl = sDialogUrl.concat( sProjectName ).concat( rtl::OUString( '.') ).concat( GetName() ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("?location=document") ) ); + + uno::Reference< awt::XDialogProvider > xProvider( xFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.DialogProvider")), aArgs ), uno::UNO_QUERY_THROW ); + m_xDialog = xProvider->createDialog( sDialogUrl ); + + // create vba api object + aArgs.realloc( 4 ); + aArgs[ 0 ] = uno::Any(); + aArgs[ 1 ] <<= m_xDialog; + aArgs[ 2 ] <<= m_xModel; + aArgs[ 3 ] <<= rtl::OUString( GetParent()->GetName() ); + pDocObject = new SbUnoObject( GetName(), uno::makeAny( xVBAFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.UserForm")), aArgs ) ) ); + uno::Reference< lang::XComponent > xComponent( aArgs[ 1 ], uno::UNO_QUERY_THROW ); + // remove old listener if it exists + FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() ); + if ( pFormListener ) + pFormListener->removeListener(); + m_DialogListener = new FormObjEventListenerImpl( this, xComponent ); + + triggerInitializeEvent(); + } + } + catch( uno::Exception& e ) + { + } + +} + +SbxVariable* +SbUserFormModule::Find( const XubString& rName, SbxClassType t ) +{ + if ( !pDocObject && !GetSbData()->bRunInit && pINST ) + InitObject(); + return SbObjModule::Find( rName, t ); +} ///////////////////////////////////////////////////////////////////////// SbProperty::SbProperty( const String& r, SbxDataType t, SbModule* p ) diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index c7a63b6d7fbb..1cf38f171e8b 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -127,12 +127,12 @@ void SbiCodeGen::Save() // OPTION EXPLICIT-Flag uebernehmen if( pParser->bExplicit ) p->SetFlag( SBIMG_EXPLICIT ); - if( pParser->IsVBASupportOn() ) - p->SetFlag( SBIMG_VBASUPPORT ); int nIfaceCount = 0; - if( pParser->bClassModule ) + if( rMod.mnType == com::sun::star::script::ModuleType::Class ) { + OSL_TRACE("COdeGen::save() classmodule processing"); + rMod.bIsProxyModule = true; p->SetFlag( SBIMG_CLASSMODULE ); pCLASSFAC->AddClassModule( &rMod ); @@ -155,6 +155,10 @@ void SbiCodeGen::Save() else { pCLASSFAC->RemoveClassModule( &rMod ); + // Only a ClassModule can revert to Normal + if ( rMod.mnType == com::sun::star::script::ModuleType::Class ) + rMod.mnType = com::sun::star::script::ModuleType::Normal; + rMod.bIsProxyModule = false; } if( pParser->bText ) p->SetFlag( SBIMG_COMPARETEXT ); diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx index 400e77a94b16..9fbd1035fa5f 100644 --- a/basic/source/comp/parser.cxx +++ b/basic/source/comp/parser.cxx @@ -140,7 +140,8 @@ SbiParser::SbiParser( StarBASIC* pb, SbModule* pm ) bNewGblDefs = bSingleLineIf = bExplicit = FALSE; - bClassModule = FALSE; + bClassModule = ( pm->GetModuleType() == com::sun::star::script::ModuleType::Class ); + OSL_TRACE("Parser - %s, bClassModule %d", rtl::OUStringToOString( pm->GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), bClassModule ); pPool = &aPublics; for( short i = 0; i < 26; i++ ) eDefTypes[ i ] = SbxVARIANT; // Kein expliziter Defaulttyp @@ -153,6 +154,10 @@ SbiParser::SbiParser( StarBASIC* pb, SbModule* pm ) rTypeArray = new SbxArray; // Array fuer Benutzerdefinierte Typen rEnumArray = new SbxArray; // Array for Enum types + bVBASupportOn = pm->IsVBACompat(); + if ( bVBASupportOn ) + EnableCompatibility(); + } @@ -751,6 +756,7 @@ void SbiParser::Option() case CLASSMODULE: bClassModule = TRUE; + aGen.GetModule().SetModuleType( com::sun::star::script::ModuleType::Class ); break; case VBASUPPORT: if( Next() == NUMBER ) @@ -760,6 +766,10 @@ void SbiParser::Option() bVBASupportOn = ( nVal == 1 ); if ( bVBASupportOn ) EnableCompatibility(); + // if the module setting is different + // reset it to what the Option tells us + if ( bVBASupportOn != aGen.GetModule().IsVBACompat() ) + aGen.GetModule().SetVBACompat( bVBASupportOn ); break; } } diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx index d0a613eabebc..3d90d16bdcbe 100644 --- a/basic/source/inc/codegen.hxx +++ b/basic/source/inc/codegen.hxx @@ -53,6 +53,7 @@ public: void GenStmnt(); // evtl. Statement-Opcode erzeugen UINT32 GetPC(); UINT32 GetOffset() { return GetPC() + 1; } + SbModule& GetModule() { return rMod; } void Save(); // #29955 for-Schleifen-Ebene pflegen diff --git a/basic/source/inc/image.hxx b/basic/source/inc/image.hxx index 7347efe288f3..d674b91faf71 100644 --- a/basic/source/inc/image.hxx +++ b/basic/source/inc/image.hxx @@ -106,6 +106,5 @@ public: #define SBIMG_COMPARETEXT 0x0002 // OPTION COMPARE TEXT ist aktiv #define SBIMG_INITCODE 0x0004 // Init-Code vorhanden #define SBIMG_CLASSMODULE 0x0008 // OPTION ClassModule is active -#define SBIMG_VBASUPPORT 0x0020 // OPTION VBASupport is 1 #endif diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index 1f7e77170d44..1f4084db1d0d 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -58,19 +58,22 @@ #include #include +#include #include +#include class BasicManager; namespace basic { -typedef ::cppu::WeakComponentImplHelper6< +typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::lang::XInitialization, ::com::sun::star::script::XStorageBasedLibraryContainer, ::com::sun::star::script::XLibraryContainerPassword, ::com::sun::star::script::XLibraryContainerExport, ::com::sun::star::container::XContainer, + ::com::sun::star::script::XVBACompat, ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper; typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer, @@ -216,6 +219,7 @@ public: class SfxLibraryContainer :public LibraryContainerHelper ,public ::utl::OEventListenerAdapter { + sal_Bool mbVBACompat; protected: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > mxSFI; @@ -493,6 +497,9 @@ public: throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0; + // Methods XVBACompat + virtual ::sal_Bool SAL_CALL getVBACompatModeOn() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setVBACompatModeOn( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException); }; class LibraryContainerMethodGuard diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index 4a3f38c51027..b831a0ba57d5 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -433,7 +433,7 @@ class SbiRuntime void StepFIND_CM( UINT32, UINT32 ); void StepFIND_STATIC( UINT32, UINT32 ); public: - void SetVBAEnabled( bool bEnabled ) { bVBAEnabled = bEnabled; }; + void SetVBAEnabled( bool bEnabled ); USHORT GetImageFlag( USHORT n ) const; USHORT GetBase(); xub_StrLen nLine,nCol1,nCol2; // aktuelle Zeile, Spaltenbereich diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx index 19b0698d22a9..31025c48c4a4 100644 --- a/basic/source/inc/scriptcont.hxx +++ b/basic/source/inc/scriptcont.hxx @@ -30,6 +30,8 @@ #include "namecont.hxx" #include +#include +#include class BasicManager; @@ -134,13 +136,19 @@ public: }; //============================================================================ +typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleInfoMap; + +typedef ::cppu::ImplHelper1 < ::com::sun::star::script::XVBAModuleInfo + > SfxScriptLibrary_BASE; class SfxScriptLibrary : public SfxLibrary + , public SfxScriptLibrary_BASE { friend class SfxScriptLibraryContainer; sal_Bool mbLoadedSource; sal_Bool mbLoadedBinary; + ModuleInfoMap mModuleInfos; // Provide modify state including resources virtual sal_Bool isModified( void ); @@ -167,6 +175,15 @@ public: const ::rtl::OUString& aLibInfoFileURL, const ::rtl::OUString& aStorageURL, sal_Bool ReadOnly ); + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + + // XVBAModuleInfo + virtual ::com::sun::star::script::ModuleInfo SAL_CALL getModuleInfo( const ::rtl::OUString& ModuleName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasModuleInfo( const ::rtl::OUString& ModuleName ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertModuleInfo( const ::rtl::OUString& ModuleName, const ::com::sun::star::script::ModuleInfo& ModuleInfo ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeModuleInfo( const ::rtl::OUString& ModuleName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + static bool containsValidModule( const ::com::sun::star::uno::Any& _rElement ); protected: diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 9a21e488d4aa..e1b704cb8918 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -120,6 +120,10 @@ using namespace com::sun::star::io; #include #endif +using namespace rtl; + +#include + static void FilterWhiteSpace( String& rStr ) { rStr.EraseAllChars( ' ' ); @@ -4106,7 +4110,12 @@ RTLFUNC(Load) // Diesen Call einfach an das Object weiterreichen SbxBase* pObj = (SbxObject*)rPar.Get(1)->GetObject(); - if( pObj && pObj->IsA( TYPE( SbxObject ) ) ) + if( pObj && pObj->IsA( TYPE( SbUserFormModule ) ) ) + { + SbUserFormModule* pFormModule = ( SbUserFormModule* )pObj; + pFormModule->load(); + } + else if( pObj && pObj->IsA( TYPE( SbxObject ) ) ) { SbxVariable* pVar = ((SbxObject*)pObj)-> Find( String( RTL_CONSTASCII_USTRINGPARAM("Load") ), SbxCLASS_METHOD ); @@ -4129,7 +4138,12 @@ RTLFUNC(Unload) // Diesen Call einfach an das Object weitereichen SbxBase* pObj = (SbxObject*)rPar.Get(1)->GetObject(); - if( pObj && pObj->IsA( TYPE( SbxObject ) ) ) + if( pObj && pObj->IsA( TYPE( SbUserFormModule ) ) ) + { + SbUserFormModule* pFormModule = ( SbUserFormModule* )pObj; + pFormModule->Unload(); + } + else if( pObj && pObj->IsA( TYPE( SbxObject ) ) ) { SbxVariable* pVar = ((SbxObject*)pObj)-> Find( String( RTL_CONSTASCII_USTRINGPARAM("Unload") ), SbxCLASS_METHOD ); diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index e0501e5c0d94..3a234b78e1df 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -61,6 +61,7 @@ #endif #include +#include #include "sbintern.hxx" #include "runtime.hxx" @@ -2594,14 +2595,15 @@ RTLFUNC(Me) SbModule* pActiveModule = pINST->GetActiveModule(); SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pActiveModule); + SbxVariableRef refVar = rPar.Get(0); if( pClassModuleObject == NULL ) { StarBASIC::Error( SbERR_INVALID_USAGE_OBJECT ); + SbObjModule* pMod = PTR_CAST(SbObjModule,pActiveModule); + if ( pMod ) + refVar->PutObject( pMod ); } else - { - SbxVariableRef refVar = rPar.Get(0); refVar->PutObject( pClassModuleObject ); - } } diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 52aa76e2f2df..4c80d2683e1c 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -49,7 +49,7 @@ bool SbiRuntime::isVBAEnabled() bool result = false; SbiInstance* pInst = pINST; if ( pInst && pINST->pRun ) - result = pInst->pRun->GetImageFlag( SBIMG_VBASUPPORT ); + result = pInst->pRun->bVBAEnabled; return result; } @@ -60,6 +60,24 @@ void StarBASIC::StaticEnableReschedule( BOOL bReschedule ) { bStaticGlobalEnableReschedule = bReschedule; } +void StarBASIC::SetVBAEnabled( BOOL bEnabled ) +{ + if ( bDocBasic ) + { + bVBAEnabled = bEnabled; + } +} + +BOOL StarBASIC::isVBAEnabled() +{ + if ( bDocBasic ) + { + if( SbiRuntime::isVBAEnabled() ) + return TRUE; + return bVBAEnabled; + } + return FALSE; +} struct SbiArgvStack { // Argv stack: @@ -520,6 +538,7 @@ SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, UINT32 nStart ) nForLvl = 0; nOps = 0; refExprStk = new SbxArray; + SetVBAEnabled( pMod->IsVBACompat() ); #if defined GCC SetParameters( pe ? pe->GetParameters() : (class SbxArray *)NULL ); #else @@ -527,7 +546,6 @@ SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, UINT32 nStart ) #endif pRefSaveList = NULL; pItemStoreList = NULL; - bVBAEnabled = isVBAEnabled(); } SbiRuntime::~SbiRuntime() @@ -546,6 +564,11 @@ SbiRuntime::~SbiRuntime() } } +void SbiRuntime::SetVBAEnabled(bool bEnabled ) +{ + bVBAEnabled = bEnabled; +} + // Aufbau der Parameterliste. Alle ByRef-Parameter werden direkt // uebernommen; von ByVal-Parametern werden Kopien angelegt. Falls // ein bestimmter Datentyp verlangt wird, wird konvertiert. diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index 6ccb7e81d2c4..05134620f173 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -73,7 +73,6 @@ #include #include - namespace basic { @@ -332,7 +331,7 @@ SfxLibraryContainer::SfxLibraryContainer( void ) , mbOldInfoFormat( sal_False ) , mbOasis2OOoFormat( sal_False ) , mpBasMgr( NULL ) - , mbOwnBasMgr( sal_False ) + , mbOwnBasMgr( sal_False ), mbVBACompat( sal_False ) { DBG_CTOR( SfxLibraryContainer, NULL ); @@ -2726,6 +2725,28 @@ OUString SfxLibraryContainer::expand_url( const OUString& url ) } } +::sal_Bool SAL_CALL SfxLibraryContainer::getVBACompatModeOn() throw (RuntimeException) +{ + return mbVBACompat; +} + +void SAL_CALL SfxLibraryContainer::setVBACompatModeOn( ::sal_Bool _vbacompatmodeon ) throw (RuntimeException) +{ + BasicManager* pBasMgr = getBasicManager(); + if( pBasMgr ) + { + // get the standard library + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( pBasMgr->GetName().Len() ) + aLibName = pBasMgr->GetName(); + + StarBASIC* pBasic = pBasMgr->GetLib( aLibName ); + if( pBasic ) + pBasic->SetVBAEnabled( _vbacompatmodeon ); + } + mbVBACompat = _vbacompatmodeon; +} + // Methods XServiceInfo ::sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index 096d497a4c50..6e8e1e7eff7b 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -1166,6 +1166,45 @@ bool SAL_CALL SfxScriptLibrary::isLibraryElementValid( ::com::sun::star::uno::An return SfxScriptLibrary::containsValidModule( aElement ); } +IMPLEMENT_FORWARD_XINTERFACE2( SfxScriptLibrary, SfxLibrary, SfxScriptLibrary_BASE ); +IMPLEMENT_FORWARD_XTYPEPROVIDER2( SfxScriptLibrary, SfxLibrary, SfxScriptLibrary_BASE ); + +script::ModuleInfo SAL_CALL +SfxScriptLibrary::getModuleInfo( const ::rtl::OUString& ModuleName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException) +{ + if ( !hasModuleInfo( ModuleName ) ) + throw NoSuchElementException(); + return mModuleInfos[ ModuleName ]; +} + +sal_Bool SAL_CALL +SfxScriptLibrary::hasModuleInfo( const ::rtl::OUString& ModuleName ) throw (RuntimeException) +{ + sal_Bool bRes = sal_False; + ModuleInfoMap::iterator it = mModuleInfos.find( ModuleName ); + + if ( it != mModuleInfos.end() ) + bRes = sal_True; + + return bRes; +} + +void SAL_CALL SfxScriptLibrary::insertModuleInfo( const ::rtl::OUString& ModuleName, const script::ModuleInfo& ModuleInfo ) throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) +{ + if ( hasModuleInfo( ModuleName ) ) + throw ElementExistException(); + mModuleInfos[ ModuleName ] = ModuleInfo; +} + +void SAL_CALL SfxScriptLibrary::removeModuleInfo( const ::rtl::OUString& ModuleName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException) +{ + // #FIXME add NoSuchElementException to the spec + if ( !hasModuleInfo( ModuleName ) ) + throw NoSuchElementException(); + mModuleInfos.erase( mModuleInfos.find( ModuleName ) ); +} + + //============================================================================ } // namespace basic diff --git a/oovbaapi/ooo/vba/excel/XWorksheet.idl b/oovbaapi/ooo/vba/excel/XWorksheet.idl index 2f66b7d0826f..3620c899de83 100644 --- a/oovbaapi/ooo/vba/excel/XWorksheet.idl +++ b/oovbaapi/ooo/vba/excel/XWorksheet.idl @@ -39,6 +39,9 @@ #include #endif +#ifndef __com_sun_star_container_XNamed_idl__ +#include +#endif //============================================================================= module ooo { module vba { module excel { @@ -55,8 +58,8 @@ interface XWorksheet { interface ::ooo::vba::XHelperInterface; interface ::com::sun::star::script::XInvocation; + interface ::com::sun::star::container::XNamed; - [attribute] string Name; [attribute] boolean Visible; [attribute, readonly] long StandardHeight; [attribute, readonly] long StandardWidth; diff --git a/vbahelper/source/vbahelper/vbaglobalbase.cxx b/vbahelper/source/vbahelper/vbaglobalbase.cxx index 4226a6bfbf53..2bb9d2f4a7ad 100644 --- a/vbahelper/source/vbahelper/vbaglobalbase.cxx +++ b/vbahelper/source/vbahelper/vbaglobalbase.cxx @@ -85,9 +85,14 @@ VbaGlobalsBase::createInstanceWithArguments( const ::rtl::OUString& ServiceSpeci { uno::Reference< uno::XInterface > xReturn; - + OSL_TRACE("VbaGlobalsBase::createInstanceWithArguments(%s)", rtl::OUStringToOString( ServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); if ( hasServiceName( ServiceSpecifier ) ) + { + OSL_TRACE("VbaGlobalsBase::hasServiceName(%s) - true", rtl::OUStringToOString( ServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); xReturn = mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( ServiceSpecifier, Arguments, mxContext ); + } + else + OSL_TRACE("VbaGlobalsBase::hasServiceName(%s) - false", rtl::OUStringToOString( ServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); return xReturn; } -- cgit From 2e51e1d3e3dd632f0346e2810bbd5b7aac4d7fa8 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 12:39:31 +0000 Subject: npower13_objectmodule: #i109734# object module stuff --- offapi/com/sun/star/script/makefile.mk | 2 ++ udkapi/com/sun/star/script/makefile.mk | 2 ++ 2 files changed, 4 insertions(+) diff --git a/offapi/com/sun/star/script/makefile.mk b/offapi/com/sun/star/script/makefile.mk index 579174390ec4..bc9b8c3d2ed2 100644 --- a/offapi/com/sun/star/script/makefile.mk +++ b/offapi/com/sun/star/script/makefile.mk @@ -48,6 +48,8 @@ IDLFILES=\ XPersistentLibraryContainer.idl\ XStorageBasedLibraryContainer.idl\ ModuleSizeExceededRequest.idl\ + XVBACompat.idl\ + XVBAModuleInfo.idl\ # ------------------------------------------------------------------ diff --git a/udkapi/com/sun/star/script/makefile.mk b/udkapi/com/sun/star/script/makefile.mk index 32aa58fefa6d..2c5388c10542 100644 --- a/udkapi/com/sun/star/script/makefile.mk +++ b/udkapi/com/sun/star/script/makefile.mk @@ -81,6 +81,8 @@ IDLFILES=\ XScriptEventsAttacher.idl\ XDefaultMethod.idl\ XDefaultProperty.idl\ + ModuleInfo.idl\ + ModuleType.idl\ # ------------------------------------------------------------------ -- cgit From 67f4b1791d5b9e1bf7f5b969174de322adbaec21 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 12:39:31 +0000 Subject: npower13_objectmodule: #i109734# object module stuff --- filter/inc/filter/msfilter/svxmsbas.hxx | 4 + filter/source/msfilter/msvbasic.cxx | 16 ++-- filter/source/msfilter/msvbasic.hxx | 9 +-- filter/source/msfilter/svxmsbas.cxx | 128 +++++++++++++++++++++++++++----- 4 files changed, 127 insertions(+), 30 deletions(-) diff --git a/filter/inc/filter/msfilter/svxmsbas.hxx b/filter/inc/filter/msfilter/svxmsbas.hxx index f488017e4804..716c6788989c 100644 --- a/filter/inc/filter/msfilter/svxmsbas.hxx +++ b/filter/inc/filter/msfilter/svxmsbas.hxx @@ -64,6 +64,9 @@ public: // bit 1 = 1 -> the VBA - storage is copy to the ObjectShell storage int Import( const String& rStorageName, const String &rSubStorageName, BOOL bAsComment=TRUE, BOOL bStripped=TRUE ); + int Import( const String& rStorageName, const String &rSubStorageName, + const std::vector< String >& codeNames, + BOOL bAsComment=TRUE, BOOL bStripped=TRUE ); // only for the export - copy or delete the saved VBA-macro-storage // form the ObjectShell @@ -84,6 +87,7 @@ private: MSFILTER_DLLPRIVATE BOOL ImportCode_Impl( const String& rStorageName, const String &rSubStorageName, + const std::vector< String >& codeNames, BOOL bAsComment, BOOL bStripped); MSFILTER_DLLPRIVATE bool ImportForms_Impl(const String& rStorageName, const String &rSubStorageName); diff --git a/filter/source/msfilter/msvbasic.cxx b/filter/source/msfilter/msvbasic.cxx index 91348043b75f..8a87c70f19d0 100644 --- a/filter/source/msfilter/msvbasic.cxx +++ b/filter/source/msfilter/msvbasic.cxx @@ -38,6 +38,8 @@ #include //rtl_getTextEncodingFromWindowsCodePage #include "msvbasic.hxx" +using namespace ::com::sun::star::script; + /* A few urls which may in the future be of some use http://www.virusbtn.com/vb2000/Programme/papers/bontchev.pdf @@ -429,7 +431,7 @@ int VBA_Impl::ReadVBAProject(const SvStorageRef &rxVBAStorage) * */ -ModuleType VBA_Impl::GetModuleType( const UniString& rModuleName ) +ModType VBA_Impl::GetModuleType( const UniString& rModuleName ) { ModuleTypeHash::iterator iter = mhModHash.find( rModuleName ); ModuleTypeHash::iterator iterEnd = mhModHash.end(); @@ -437,7 +439,7 @@ ModuleType VBA_Impl::GetModuleType( const UniString& rModuleName ) { return iter->second; } - return Unknown; + return ModuleType::Unknown; } bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) @@ -480,7 +482,7 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) static const String sClass( RTL_CONSTASCII_USTRINGPARAM( "Class" ) ); static const String sBaseClass( RTL_CONSTASCII_USTRINGPARAM( "BaseClass" ) ); static const String sDocument( RTL_CONSTASCII_USTRINGPARAM( "Document" ) ); - mhModHash[ sThisDoc ] = Class; + mhModHash[ sThisDoc ] = ModuleType::Class; while ( pStp->ReadByteStringLine( tmp, meCharSet ) ) { xub_StrLen index = tmp.Search( '=' ); @@ -490,14 +492,14 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) String value = tmp.Copy( index + 1 ); if ( key == sClass ) { - mhModHash[ value ] = Class; + mhModHash[ value ] = ModuleType::Class; OSL_TRACE("Module %s is of type Class", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); } else if ( key == sBaseClass ) { - mhModHash[ value ] = Form; + mhModHash[ value ] = ModuleType::Form; OSL_TRACE("Module %s is of type Form", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); @@ -510,14 +512,14 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) // value is of form /&H, strip the identifier value.Erase( value.Search( '/' ) ); - mhModHash[ value ] = Document; + mhModHash[ value ] = ModuleType::Document; OSL_TRACE("Module %s is of type Document VBA", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); } else if ( key == sModule ) { - mhModHash[ value ] = Normal; + mhModHash[ value ] = ModuleType::Normal; OSL_TRACE("Module %s is of type Normal VBA", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); diff --git a/filter/source/msfilter/msvbasic.hxx b/filter/source/msfilter/msvbasic.hxx index 5b361518c0f5..ed77b34c4f48 100644 --- a/filter/source/msfilter/msvbasic.hxx +++ b/filter/source/msfilter/msvbasic.hxx @@ -40,6 +40,7 @@ #include #endif #include +#include /* class VBA: * The VBA class provides a set of methods to handle Visual Basic For @@ -63,13 +64,12 @@ DECLARE_DYNARRAY(StringArray,String *) // #117718# define internal types to distinguish between // module types, form, class & normal // #i37965# DR 2004-12-03: add "Document", used in Excel for macros attached to sheet -enum ModuleType { Unknown = 0, Normal, Class, Form, Document }; // #117718# define map to hold types of module // - +typedef sal_Int32 ModType; typedef ::std::map< UniString, - ModuleType > ModuleTypeHash; + ModType > ModuleTypeHash; class VBA_Impl { @@ -90,8 +90,7 @@ public: void Output(int len, const sal_uInt8 *data); // // #117718# member map of module names to types of module - ModuleType GetModuleType( const UniString& rModuleName ); - + ModType GetModuleType( const UniString& rModuleName ); std::vector maReferences; private: struct VBAOffset_Impl diff --git a/filter/source/msfilter/svxmsbas.cxx b/filter/source/msfilter/svxmsbas.cxx index e4305c2e4e65..0b42fe7e4843 100644 --- a/filter/source/msfilter/svxmsbas.cxx +++ b/filter/source/msfilter/svxmsbas.cxx @@ -50,6 +50,10 @@ using namespace com::sun::star::awt; #include #include +#include +#include +#include + using namespace com::sun::star::container; using namespace com::sun::star::script; using namespace com::sun::star::uno; @@ -58,12 +62,23 @@ using namespace com::sun::star; using rtl::OUString; +static ::rtl::OUString sVBAOption( RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ); + +int SvxImportMSVBasic::Import( const String& rStorageName, + const String &rSubStorageName, + BOOL bAsComment, BOOL bStripped ) +{ + std::vector< String > codeNames; + return Import( rStorageName, rSubStorageName, codeNames, bAsComment, bStripped ); +} + int SvxImportMSVBasic::Import( const String& rStorageName, const String &rSubStorageName, + const std::vector< String >& codeNames, BOOL bAsComment, BOOL bStripped ) { int nRet = 0; - if( bImport && ImportCode_Impl( rStorageName, rSubStorageName, + if( bImport && ImportCode_Impl( rStorageName, rSubStorageName, codeNames, bAsComment, bStripped )) nRet |= 1; @@ -225,6 +240,7 @@ BOOL SvxImportMSVBasic::CopyStorage_Impl( const String& rStorageName, BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, const String &rSubStorageName, + const std::vector< String >& codeNames, BOOL bAsComment, BOOL bStripped ) { BOOL bRet = FALSE; @@ -233,13 +249,18 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, { SFX_APP()->EnterBasicCall(); Reference xLibContainer = rDocSh.GetBasicContainer(); + Reference xVBACompat( xLibContainer, UNO_QUERY ); + + if ( xVBACompat.is() && !bAsComment ) + xVBACompat->setVBACompatModeOn( sal_True ); + DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" ); UINT16 nStreamCount = aVBA.GetNoStreams(); Reference xLib; + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); if( xLibContainer.is() && nStreamCount ) { - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); if( !xLibContainer->hasByName( aLibName ) ) xLibContainer->createLibrary( aLibName ); @@ -248,6 +269,28 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, } if( xLib.is() ) { + Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); + Reference< container::XNameAccess > xVBACodeNamedObjectAccess; + if ( !bAsComment ) + { + Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY); + if ( xSF.is() ) + { + try + { + xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), UNO_QUERY ); + } + catch( Exception& ) { } + } + } + typedef std::hash_map< rtl::OUString, uno::Any, ::rtl::OUStringHash, +::std::equal_to< ::rtl::OUString > > NameModuleDataHash; + typedef std::hash_map< rtl::OUString, script::ModuleInfo, ::rtl::OUStringHash, +::std::equal_to< ::rtl::OUString > > NameModuleInfoHash; + + NameModuleDataHash moduleData; + NameModuleInfoHash moduleInfos; + for( UINT16 i=0; ihasByName( aModName ) ) - xLib->replaceByName( aModName, aSourceAny ); - else - xLib->insertByName( aModName, aSourceAny ); + if ( !bAsComment ) + { + OSL_TRACE("vba processing %d", mType ); + script::ModuleInfo sModuleInfo; + sModuleInfo.ModuleType = mType; + moduleInfos[ aModName ] = sModuleInfo; + } + moduleData[ aModName ] = aSourceAny; + } + // Hack for missing codenames ( only know to happen in excel but... ) + // only makes sense to do this if we are importing non-commented basic + if ( !bAsComment ) + { + for ( std::vector< String >::const_iterator it = codeNames.begin(); it != codeNames.end(); ++it ) + { + script::ModuleInfo sModuleInfo; + sModuleInfo.ModuleType = ModuleType::Document; + moduleInfos[ *it ] = sModuleInfo; + moduleData[ *it ] = uno::makeAny( sVBAOption ); + } + } + NameModuleDataHash::iterator it_end = moduleData.end(); + for ( NameModuleDataHash::iterator it = moduleData.begin(); it != it_end; ++it ) + { + NameModuleInfoHash::iterator it_info = moduleInfos.find( it->first ); + if ( it_info != moduleInfos.end() ) + { + ModuleInfo& sModuleInfo = it_info->second; + if ( sModuleInfo.ModuleType == ModuleType::Form ) + // hack, the module ( imo document basic should... + // know the XModel... ) but it doesn't + sModuleInfo.ModuleObject.set( rDocSh.GetModel(), UNO_QUERY ); + // document modules, we should be able to access + // the api objects at this time + else if ( sModuleInfo.ModuleType == ModuleType::Document ) + { + if ( xVBACodeNamedObjectAccess.is() ) + { + try + { + sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( it->first ), uno::UNO_QUERY ); + OSL_TRACE("** Straight up creation of Module"); + } + catch(uno::Exception& e) + { + OSL_TRACE("Failed to get documument object for %s", rtl::OUStringToOString( it->first, RTL_TEXTENCODING_UTF8 ).getStr() ); + } + } + } + xVBAModuleInfo->insertModuleInfo( it->first, sModuleInfo ); } - bRet = true; + if( xLib->hasByName( it->first ) ) + xLib->replaceByName( it->first, it->second ); + else + xLib->insertByName( it->first, it->second ); } + bRet = true; } SFX_APP()->LeaveBasicCall(); } -- cgit From aac4d6a3a645d3c11e4094a2c5ca701810e6df07 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 12:39:31 +0000 Subject: npower13_objectmodule: #i109734# object module stuff --- sc/inc/document.hxx | 2 + sc/inc/servuno.hxx | 5 +- sc/source/core/data/documen2.cxx | 37 ++++++++++ sc/source/core/data/document.cxx | 12 +++- sc/source/filter/excel/excimp8.cxx | 9 +-- sc/source/filter/excel/read.cxx | 2 +- sc/source/ui/docshell/docfunc.cxx | 139 ++++++++++++++++++++++++++++++++++++- sc/source/ui/docshell/docsh5.cxx | 40 +++++++++++ sc/source/ui/unoobj/servuno.cxx | 123 +++++++++++++++++++++++++++++++- sc/source/ui/view/viewfun2.cxx | 17 +++++ 10 files changed, 376 insertions(+), 10 deletions(-) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 44bda96f8322..48b98a7551af 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1716,6 +1716,8 @@ public: { return eStorageGrammar; } SfxUndoManager* GetUndoManager(); + bool IsInVBAMode() const; + private: // CLOOK-Impl-Methoden /** diff --git a/sc/inc/servuno.hxx b/sc/inc/servuno.hxx index 785e5e4049d0..a8159da5158f 100644 --- a/sc/inc/servuno.hxx +++ b/sc/inc/servuno.hxx @@ -90,9 +90,10 @@ class ScDocShell; #define SC_SERVICE_FORMULAPARS 38 #define SC_SERVICE_OPCODEMAPPER 39 -#define SC_SERVICE_VBACODENAMEPROVIDER 40 +#define SC_SERVICE_VBAOBJECTPROVIDER 40 +#define SC_SERVICE_VBACODENAMEPROVIDER 41 -#define SC_SERVICE_COUNT 41 +#define SC_SERVICE_COUNT 42 #define SC_SERVICE_INVALID USHRT_MAX diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index c08fb7a10228..ce3bf4df3490 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -93,6 +93,7 @@ #include "tabprotection.hxx" #include "formulaparserpool.hxx" #include "clipparam.hxx" +#include // pImpl because including lookupcache.hxx in document.hxx isn't wanted, and // dtor plus helpers are convenient. @@ -934,6 +935,8 @@ BOOL ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM return bValid; } +void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sModuleSource ); + ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos, BOOL bInsertNew, BOOL bResultsOnly ) @@ -1104,6 +1107,40 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, } if (!bValid) nRetVal = 0; + SfxObjectShell* pDestShell = pSrcDoc ? pSrcDoc->GetDocumentShell() : NULL; + StarBASIC* pStarBASIC = pDestShell ? pDestShell->GetBasic() : NULL; + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( pDestShell && pDestShell->GetBasicManager()->GetName().Len() > 0 ) + { + aLibName = pDestShell->GetBasicManager()->GetName(); + pStarBASIC = pDestShell->GetBasicManager()->GetLib( aLibName ); + } + + BOOL bVbaEnabled = IsInVBAMode(); + + if ( bVbaEnabled && pDestShell ) + { + String sCodeName; + String sSource; + com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = pDestShell->GetBasicContainer(); + com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + + if( xLib.is() ) + { + String sSrcCodeName; + pSrcDoc->GetCodeName( nSrcPos, sSrcCodeName ); + rtl::OUString sRTLSource; + xLib->getByName( sSrcCodeName ) >>= sRTLSource; + sSource = sRTLSource; + } + VBA_InsertModule( *this, nDestPos, sCodeName, sSource ); + } + return nRetVal; } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index fa4fb296d9a7..3424df4824af 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -51,6 +51,7 @@ #include #include +#include #include "document.hxx" #include "table.hxx" @@ -4963,4 +4964,13 @@ void ScDocument::EnableUndo( bool bVal ) mbUndoEnabled = bVal; } - +bool ScDocument::IsInVBAMode() const +{ + bool bResult = false; + if ( pShell ) + { + com::sun::star::uno::Reference< com::sun::star::script::XVBACompat > xVBA( pShell->GetBasicContainer(), com::sun::star::uno::UNO_QUERY ); + bResult = xVBA->getVBACompatModeOn(); + } + return bResult; +} diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index e424ad2d95fe..19df7c2520c1 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -104,7 +104,6 @@ #include #include - using namespace com::sun::star; @@ -257,8 +256,6 @@ void ImportExcel8::SheetProtection( void ) void ImportExcel8::ReadBasic( void ) { - bHasBasic = TRUE; - SfxObjectShell* pShell = GetDocShell(); SotStorageRef xRootStrg = GetRootStorage(); SvtFilterOptions* pFilterOpt = SvtFilterOptions::Get(); @@ -271,7 +268,7 @@ void ImportExcel8::ReadBasic( void ) { SvxImportMSVBasic aBasicImport( *pShell, *xRootStrg, bLoadCode, bLoadStrg ); bool bAsComment = !bLoadExecutable; - aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment ); + aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment ); } } } @@ -286,6 +283,10 @@ void ImportExcel8::EndSheet( void ) void ImportExcel8::PostDocLoad( void ) { + // delay reading basic until sheet object ( codenames etc. ) are read + + if ( bHasBasic ) + ReadBasic(); // #i11776# filtered ranges before outlines and hidden rows if( pExcRoot->pAutoFilterBuffer ) pExcRoot->pAutoFilterBuffer->Apply(); diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx index 91b749030dd7..9c99c9a0a6c6 100644 --- a/sc/source/filter/excel/read.cxx +++ b/sc/source/filter/excel/read.cxx @@ -983,7 +983,7 @@ FltError ImportExcel8::Read( void ) case 0x22: Rec1904(); break; // 1904 [ 2345 ] case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ] case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ] - case 0xD3: ReadBasic(); break; + case 0xD3: bHasBasic = true; break; case 0xDE: Olesize(); break; case 0x01BA: Codename( TRUE ); break; diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index cd28daa99401..3b735c061cab 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -48,6 +48,12 @@ #include #include +#include +#include +#include +#include +#include + #include #include "docfunc.hxx" @@ -94,6 +100,7 @@ #include "clipparam.hxx" #include +#include using namespace com::sun::star; using ::com::sun::star::uno::Sequence; @@ -2576,6 +2583,106 @@ BOOL ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, } //------------------------------------------------------------------------ +uno::Reference< uno::XInterface > GetDocModuleObject( SfxObjectShell& rDocSh, String& sCodeName ) +{ + uno::Reference< lang::XMultiServiceFactory> xSF(rDocSh.GetModel(), uno::UNO_QUERY); + uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess; + uno::Reference< uno::XInterface > xDocModuleApiObject; + if ( xSF.is() ) + { + xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY ); + xDocModuleApiObject.set( xVBACodeNamedObjectAccess->getByName( sCodeName ), uno::UNO_QUERY ); + } + return xDocModuleApiObject; + +} + +script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule ) +{ + ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )); + script::ModuleInfo sModuleInfo; + sModuleInfo.ModuleType = script::ModuleType::Document; + sModuleInfo.ModuleObject = GetDocModuleObject( rDocSh, sModule ); + return sModuleInfo; +} + +void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sSource ) +{ + SFX_APP()->EnterBasicCall(); + SfxObjectShell& rDocSh = *rDoc.GetDocumentShell(); + uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer(); + DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" ); + + uno::Reference< container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( rDocSh.GetBasicManager() && rDocSh.GetBasicManager()->GetName().Len() ) + aLibName = rDocSh.GetBasicManager()->GetName(); + uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + if( xLib.is() ) + { + // if the Module with codename exists then find a new name + sal_Int32 nNum = 0; + String genModuleName; + if ( sModuleName.Len() ) + sModuleName = sModuleName; + else + { + genModuleName = String::CreateFromAscii( "Sheet1" ); + nNum = 1; + } + while( xLib->hasByName( genModuleName ) ) + genModuleName = rtl::OUString::createFromAscii( "Sheet" ) + rtl::OUString::valueOf( ++nNum ); + + uno::Any aSourceAny; + rtl::OUString sTmpSource = sSource; + if ( sTmpSource.getLength() == 0 ) + sTmpSource = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )); + aSourceAny <<= sTmpSource; + uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); + if ( xVBAModuleInfo.is() ) + { + String sCodeName( genModuleName ); + rDoc.SetCodeName( nTab, sCodeName ); + script::ModuleInfo sModuleInfo = lcl_InitModuleInfo( rDocSh, genModuleName ); + xVBAModuleInfo->insertModuleInfo( genModuleName, sModuleInfo ); + xLib->insertByName( genModuleName, aSourceAny ); + } + + } + SFX_APP()->LeaveBasicCall(); +} + +void VBA_DeleteModule( ScDocShell& rDocSh, String& sModuleName ) +{ + SFX_APP()->EnterBasicCall(); + uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer(); + DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" ); + + uno::Reference< container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( rDocSh.GetBasicManager() && rDocSh.GetBasicManager()->GetName().Len() ) + aLibName = rDocSh.GetBasicManager()->GetName(); + uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + if( xLib.is() ) + { + uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); + if( xLib->hasByName( sModuleName ) ) + xLib->removeByName( sModuleName ); + if ( xVBAModuleInfo.is() ) + xVBAModuleInfo->removeModuleInfo( sModuleName ); + + } + SFX_APP()->LeaveBasicCall(); +} + BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi ) { @@ -2585,8 +2692,19 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL ScDocShellModificator aModificator( rDocShell ); ScDocument* pDoc = rDocShell.GetDocument(); - if (bRecord && !pDoc->IsUndoEnabled()) + + + // Strange loop, also basic is loaded too early ( InsertTable ) + // is called via the xml import for sheets in described in odf + BOOL bInsertDocModule = false; + + if( !rDocShell.GetDocument()->IsImportingXML() ) + { + bInsertDocModule = pDoc ? pDoc->IsInVBAMode() : false; + } + if ( bInsertDocModule || ( bRecord && !pDoc->IsUndoEnabled() ) ) bRecord = FALSE; + if (bRecord) pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage @@ -2597,10 +2715,17 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL if (pDoc->InsertTab( nTab, rName )) { + String sCodeName; if (bRecord) rDocShell.GetUndoManager()->AddUndoAction( new ScUndoInsertTab( &rDocShell, nTab, bAppend, rName)); // Views updaten: + // Only insert vba modules if vba mode ( and not currently importing XML ) + if( bInsertDocModule ) + { + String sSource; + VBA_InsertModule( *pDoc, nTab, sCodeName, sSource ); + } rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) ); rDocShell.PostPaintExtras(); @@ -2622,8 +2747,11 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab, BOOL bRecord, BOOL /* bApi */ ) BOOL bSuccess = FALSE; ScDocument* pDoc = rDocShell.GetDocument(); + BOOL bVbaEnabled = pDoc ? pDoc->IsInVBAMode() : false; if (bRecord && !pDoc->IsUndoEnabled()) bRecord = FALSE; + if ( bVbaEnabled ) + bRecord = FALSE; BOOL bWasLinked = pDoc->IsLinked(nTab); ScDocument* pUndoDoc = NULL; ScRefUndoData* pUndoData = NULL; @@ -2664,6 +2792,8 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab, BOOL bRecord, BOOL /* bApi */ ) pUndoData = new ScRefUndoData( pDoc ); } + String sCodeName; + BOOL bHasCodeName = pDoc->GetCodeName( nTab, sCodeName ); if (pDoc->DeleteTab( nTab, pUndoDoc )) { if (bRecord) @@ -2674,6 +2804,13 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab, BOOL bRecord, BOOL /* bApi */ ) new ScUndoDeleteTab( &rDocShell, theTabs, pUndoDoc, pUndoData )); } // Views updaten: + if( bVbaEnabled ) + { + if( bHasCodeName ) + { + VBA_DeleteModule( rDocShell, sCodeName ); + } + } rDocShell.Broadcast( ScTablesHint( SC_TAB_DELETED, nTab ) ); if (bWasLinked) diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 6fa6a5ac7863..06d7cab0d14d 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -65,6 +65,11 @@ #include "sc.hrc" #include "waitoff.hxx" #include "sizedev.hxx" +#include +#include + +// defined in docfunc.cxx +void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sModuleSource ); // --------------------------------------------------------------------------- @@ -846,6 +851,8 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec if (bRecord) aDocument.BeginDrawUndo(); // drawing layer must do its own undo actions + String sSrcCodeName; + aDocument.GetCodeName( nSrcTab, sSrcCodeName ); if (!aDocument.CopyTab( nSrcTab, nDestTab )) { //! EndDrawUndo? @@ -869,6 +876,39 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec GetUndoManager()->AddUndoAction( new ScUndoCopyTab( this, aSrcList, aDestList ) ); } + + StarBASIC* pStarBASIC = GetBasic(); + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( GetBasicManager()->GetName().Len() > 0 ) + { + aLibName = GetBasicManager()->GetName(); + pStarBASIC = GetBasicManager()->GetLib( aLibName ); + } + BOOL bVbaEnabled = aDocument.IsInVBAMode(); + SCTAB nTabToUse = nDestTab; + + if ( nDestTab == SC_TAB_APPEND ) + nTabToUse = aDocument.GetMaxTableNumber() - 1; + + if ( bVbaEnabled ) + { + String sCodeName; + String sSource; + com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = GetBasicContainer(); + com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + if( xLib.is() ) + { + rtl::OUString sRTLSource; + xLib->getByName( sSrcCodeName ) >>= sRTLSource; + sSource = sRTLSource; + } + VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); + } } Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) ); diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx index 0c57963a4f12..d69659b41f11 100644 --- a/sc/source/ui/unoobj/servuno.cxx +++ b/sc/source/ui/unoobj/servuno.cxx @@ -64,9 +64,121 @@ #include #include #include - using namespace ::com::sun::star; +#ifndef CWS_NPOWER14MISCFIXES +#include +uno::Reference< uno::XInterface > lcl_createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const uno::Sequence< uno::Any >& aArgs ) throw (uno::RuntimeException) +{ + uno::Any aUnoVar; + if ( !pShell || !pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) ) + throw lang::IllegalArgumentException(); + uno::Reference< lang::XMultiServiceFactory > xVBAFactory( aUnoVar, uno::UNO_QUERY_THROW ); + ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) ); + uno::Reference< uno::XInterface > xIf = xVBAFactory->createInstanceWithArguments( sVarName, aArgs ); + return xIf; +} +#endif + +class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess > +{ + uno::Any maWorkbook; + uno::Any maCachedObject; + ScDocShell* mpDocShell; +public: + ScVbaObjectForCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) + { + ScDocument* pDoc = mpDocShell->GetDocument(); + if ( !pDoc ) + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() ); + + uno::Sequence< uno::Any > aArgs(2); + aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() ); + aArgs[1] = uno::Any( mpDocShell->GetModel() ); +#ifdef CWS_NPOWER14MISCFIXES + maWorkbook <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs ); +#else + maWorkbook <<= lcl_createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs ); +#endif + } + + virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException ) + { + maCachedObject = uno::Any(); // clear cached object + String sName = aName; + + ScDocument* pDoc = mpDocShell->GetDocument(); + if ( !pDoc ) + throw uno::RuntimeException(); + if ( sName == pDoc->GetCodeName() ) + maCachedObject = maWorkbook; + else + { + String sCodeName; + SCTAB nCount = pDoc->GetTableCount(); + for( SCTAB i = 0; i < nCount; i++ ) + { + pDoc->GetCodeName( i, sCodeName ); + if( sCodeName == sName ) + { + String sSheetName; + if( pDoc->GetName( i, sSheetName ) ) + { + uno::Reference< frame::XModel > xModel( mpDocShell->GetModel() ); + uno::Reference xSpreadDoc( xModel, uno::UNO_QUERY_THROW ); + uno::Reference xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xIndexAccess( xSheets, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW ); + uno::Sequence< uno::Any > aArgs(3); + aArgs[0] = maWorkbook; + aArgs[1] = uno::Any( xModel ); + aArgs[2] = uno::Any( rtl::OUString( sSheetName ) ); +#ifdef CWS_NPOWER14MISCFIXES + // use the convience function + maCachedObject <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs ); +#else + // use the temp function + maCachedObject <<= lcl_createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs ); +#endif + break; + } + } + } + } + return maCachedObject.hasValue(); + + } + ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { + OSL_TRACE("ScVbaObjectForCodeNameProvider::getByName( %s )", + rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr() ); + if ( !hasByName( aName ) ) + throw ::com::sun::star::container::NoSuchElementException(); + return maCachedObject; + } + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException) + { + ScDocument* pDoc = mpDocShell->GetDocument(); + if ( !pDoc ) + throw uno::RuntimeException(); + SCTAB nCount = pDoc->GetTableCount(); + uno::Sequence< rtl::OUString > aNames( nCount + 1 ); + SCTAB index = 0; + String sCodeName; + for( ; index < nCount; ++index ) + { + pDoc->GetCodeName( index, sCodeName ); + aNames[ index ] = sCodeName; + } + aNames[ index ] = pDoc->GetCodeName(); + return aNames; + } + // XElemenAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException){ return uno::Type(); } + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException ) { return sal_True; } + +}; + class ScVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery > { ScDocShell* mpDocShell; @@ -172,6 +284,7 @@ static const ProvNamesId_Type __FAR_DATA aProvNamesId[] = { SC_SERVICENAME_CHDATAPROV, SC_SERVICE_CHDATAPROV }, { SC_SERVICENAME_FORMULAPARS, SC_SERVICE_FORMULAPARS }, { SC_SERVICENAME_OPCODEMAPPER, SC_SERVICE_OPCODEMAPPER }, + { "ooo.vba.VBAObjectModuleObjectProvider", SC_SERVICE_VBAOBJECTPROVIDER }, // SC_SERVICE_VBAOBJECTPROVIDER { "ooo.vba.VBACodeNameProvider", SC_SERVICE_VBACODENAMEPROVIDER }, // case-correct versions of the service names (#i102468#) @@ -235,6 +348,7 @@ static const sal_Char* __FAR_DATA aOldNames[SC_SERVICE_COUNT] = "", // SC_SERVICE_CHDATAPROV "", // SC_SERVICE_FORMULAPARS "", // SC_SERVICE_OPCODEMAPPER + "", // SC_SERVICE_VBAOBJECTPROVIDER "", // SC_SERVICE_VBACODENAMEPROVIDER }; @@ -440,6 +554,13 @@ uno::Reference ScServiceProvider::MakeInstance( xRet.set(static_cast(new ScFormulaOpCodeMapperObj(::std::auto_ptr (pComp)))); break; } + case SC_SERVICE_VBAOBJECTPROVIDER: + if ( pDocShell ) + { + OSL_TRACE("**** creating VBA Object mapper"); + xRet.set(static_cast(new ScVbaObjectForCodeNameProvider( pDocShell ))); + } + break; case SC_SERVICE_VBACODENAMEPROVIDER: { // Only create the excel faking service for excel docs diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 627f214c4ec6..4c0d14d620bc 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -86,6 +86,13 @@ #include "funcdesc.hxx" #include "docuno.hxx" +#include +#include +#include +using namespace com::sun::star; + +// helper func defined in docfunc.cxx +void VBA_DeleteModule( ScDocShell& rDocSh, String& sModuleName ); // STATIC DATA --------------------------------------------------------------- @@ -2140,6 +2147,7 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord ) { ScDocShell* pDocSh = GetViewData()->GetDocShell(); ScDocument* pDoc = pDocSh->GetDocument(); + BOOL bVbaEnabled = pDoc ? pDoc->IsInVBAMode() : FALSE; SCTAB nNewTab = TheTabs[0]; int i; WaitObject aWait( GetFrameWin() ); @@ -2211,9 +2219,18 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord ) for(i=TheTabs.Count()-1;i>=0;i--) { + String sCodeName; + BOOL bHasCodeName = pDoc->GetCodeName( TheTabs[sal::static_int_cast(i)], sCodeName ); if (pDoc->DeleteTab( TheTabs[sal::static_int_cast(i)], pUndoDoc )) { bDelDone = TRUE; + if( bVbaEnabled ) + { + if( bHasCodeName ) + { + VBA_DeleteModule( *pDocSh, sCodeName ); + } + } pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[sal::static_int_cast(i)] ) ); } } -- cgit From 07716c77cc6b451aa4717b7811fd5f5c2aa22967 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 12:39:31 +0000 Subject: npower13_objectmodule: #i109734# object module stuff --- basctl/inc/basidesh.hrc | 4 + basctl/source/basicide/baside2.cxx | 47 +++++++- basctl/source/basicide/baside3.cxx | 14 ++- basctl/source/basicide/basides1.cxx | 10 +- basctl/source/basicide/basides2.cxx | 48 +++++++- basctl/source/basicide/basidesh.cxx | 106 ++++++++++++++++- basctl/source/basicide/basidesh.src | 16 +++ basctl/source/basicide/bastype2.cxx | 185 +++++++++++++++++++++++++++++- basctl/source/basicide/bastype2.hxx | 13 ++- basctl/source/basicide/bastype3.cxx | 46 +++++++- basctl/source/basicide/bastypes.cxx | 23 ++++ basctl/source/basicide/macrodlg.cxx | 14 +++ basctl/source/basicide/moduldlg.cxx | 70 ++++++++--- basctl/source/basicide/scriptdocument.cxx | 38 +++++- basctl/source/dlged/dlged.cxx | 3 +- basctl/source/dlged/dlgedobj.cxx | 40 +++++-- basctl/source/inc/basidesh.hxx | 3 + basctl/source/inc/dlged.hxx | 5 +- basctl/source/inc/scriptdocument.hxx | 1 + 19 files changed, 629 insertions(+), 57 deletions(-) diff --git a/basctl/inc/basidesh.hrc b/basctl/inc/basidesh.hrc index 51d1ed2be6fc..8bf7d3316cd0 100644 --- a/basctl/inc/basidesh.hrc +++ b/basctl/inc/basidesh.hrc @@ -182,6 +182,10 @@ #define RID_STR_DLGIMP_MISMATCH_OMIT ( RID_BASICIDE_START + 115 ) #define RID_STR_DLGIMP_MISMATCH_TITLE ( RID_BASICIDE_START + 116 ) #define RID_STR_DLGIMP_MISMATCH_TEXT ( RID_BASICIDE_START + 117 ) +#define RID_STR_DOCUMENT_OBJECTS ( RID_BASICIDE_START + 118 ) +#define RID_STR_USERFORMS ( RID_BASICIDE_START + 119 ) +#define RID_STR_NORMAL_MODULES ( RID_BASICIDE_START + 120 ) +#define RID_STR_CLASS_MODULES ( RID_BASICIDE_START + 121 ) #endif // _SVX_NOIDERESIDS diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 9fc700948249..bed5aa96dc28 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -46,6 +46,7 @@ #include #endif #include +#include #include #include #include @@ -107,6 +108,8 @@ DBG_NAME( ModulWindow ) TYPEINIT1( ModulWindow , IDEBaseWindow ); +void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName ); + void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle, bool bOutput ) { short nLeftMargin = LMARGPRN; @@ -332,6 +335,8 @@ BOOL ModulWindow::BasicExecute() DBG_ASSERT( xModule.Is(), "Kein Modul!" ); AddStatus( BASWIN_RUNNINGBASIC ); USHORT nStart, nEnd, nCurMethodStart = 0; + TextSelection aSel = GetEditView()->GetSelection(); + nCurMethodStart = ( aSel.GetStart().GetPara() + 1 ); SbMethod* pMethod = 0; // erstes Macro, sonst blind "Main" (ExtSearch?) for ( USHORT nMacro = 0; nMacro < xModule->GetMethods()->Count(); nMacro++ ) @@ -339,16 +344,16 @@ BOOL ModulWindow::BasicExecute() SbMethod* pM = (SbMethod*)xModule->GetMethods()->Get( nMacro ); DBG_ASSERT( pM, "Method?" ); pM->GetLineRange( nStart, nEnd ); - if ( !pMethod || ( nStart < nCurMethodStart ) ) + if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd ) { pMethod = pM; - nCurMethodStart = nStart; + break; } } if ( !pMethod ) - pMethod = (SbMethod*)xModule->Find( String( RTL_CONSTASCII_USTRINGPARAM( "Main" ) ), SbxCLASS_METHOD ); + return ( BasicIDE::ChooseMacro( uno::Reference< frame::XModel >(), FALSE, rtl::OUString() ).getLength() > 0 ) ? TRUE : FALSE; - if ( pMethod ) + else { pMethod->SetDebugFlags( aStatus.nBasicFlags ); BasicDLL::SetDebugMode( TRUE ); @@ -1372,7 +1377,39 @@ BasicEntryDescriptor ModulWindow::CreateEntryDescriptor() ScriptDocument aDocument( GetDocument() ); String aLibName( GetLibName() ); LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName ); - return BasicEntryDescriptor( aDocument, eLocation, aLibName, GetName(), OBJ_TYPE_MODULE ); + String aModName( GetName() ); + String aLibSubName; + if( xBasic.Is() && aDocument.isInVBAMode() && xModule.Is() ) + { + switch( xModule->GetModuleType() ) + { + case script::ModuleType::Document: + { + aLibSubName = String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ); + uno::Reference< container::XNameContainer > xLib = aDocument.getOrCreateLibrary( E_SCRIPTS, aLibName ); + if( xLib.is() ) + { + String sObjName; + lcl_getObjectName( xLib, aModName, sObjName ); + if( sObjName.Len() ) + { + aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")"); + } + } + break; + } + case script::ModuleType::Form: + aLibSubName = String( IDEResId( RID_STR_USERFORMS ) ); + break; + case script::ModuleType::Normal: + aLibSubName = String( IDEResId( RID_STR_NORMAL_MODULES ) ); + break; + case script::ModuleType::Class: + aLibSubName = String( IDEResId( RID_STR_CLASS_MODULES ) ); + break; + } + } + return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aModName, OBJ_TYPE_MODULE ); } void ModulWindow::SetReadOnly( BOOL b ) diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index afbe3daf5be1..c5628451ac8f 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -82,6 +82,7 @@ #include #include #include +#include using namespace comphelper; using namespace ::com::sun::star; @@ -112,8 +113,16 @@ DialogWindow::DialogWindow( Window* pParent, const ScriptDocument& rDocument, St { InitSettings( TRUE, TRUE, TRUE ); - pEditor = new DlgEditor(); + pEditor = new DlgEditor( rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); pEditor->SetWindow( this ); + // set vba mode on DialogModel ( allows it to work in 100thmm instead of MAP_APPFONT ) + if ( rDocument.isDocument() && rDocument.getDocument().is() ) + { + uno::Reference< script::XVBACompat > xDocVBAMode( rDocument.getLibraryContainer( E_SCRIPTS ), uno::UNO_QUERY ); + uno::Reference< script::XVBACompat > xDialogModelVBAMode( xDialogModel, uno::UNO_QUERY ); + if ( xDocVBAMode.is() && xDialogModelVBAMode.is() ) + xDialogModelVBAMode->setVBACompatModeOn( xDocVBAMode->getVBACompatModeOn() ); + } pEditor->SetDialog( xDialogModel ); // Undo einrichten @@ -1297,8 +1306,9 @@ BasicEntryDescriptor DialogWindow::CreateEntryDescriptor() { ScriptDocument aDocument( GetDocument() ); String aLibName( GetLibName() ); + String aLibSubName; LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName ); - return BasicEntryDescriptor( aDocument, eLocation, aLibName, GetName(), OBJ_TYPE_DIALOG ); + return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, GetName(), OBJ_TYPE_DIALOG ); } void DialogWindow::SetReadOnly( BOOL b ) diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 909a28543fae..ded495d416be 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -1198,10 +1198,16 @@ IDEBaseWindow* BasicIDEShell::FindWindow( const ScriptDocument& rDocument, const // return any non-suspended window return pWin; } - else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rName && + else if ( pWin->IsDocument( rDocument ) ) + { + OSL_TRACE("FindWindow pWin->GetLibName() %s rLibName %s", + rtl::OUStringToOString( pWin->GetLibName(), RTL_TEXTENCODING_UTF8 ).getStr(), + rtl::OUStringToOString( rLibName, RTL_TEXTENCODING_UTF8 ).getStr() ); + OSL_TRACE("pWin->pWin->IsA( TYPE( ModulWindow ) %d && nType %d = BASICIDE_TYPE_MODULE %d", pWin->IsA( TYPE( ModulWindow ) ), nType, BASICIDE_TYPE_MODULE ); + OSL_TRACE("pWin->pWin->IsA( TYPE( DialogWindow ) %d && nType %d = BASICIDE_TYPE_DIALOG %d", pWin->IsA( TYPE( DialogWindow ) ), nType, BASICIDE_TYPE_DIALOG ); + if ( pWin->GetLibName() == rLibName && pWin->GetName() == rName && ( ( pWin->IsA( TYPE( ModulWindow ) ) && nType == BASICIDE_TYPE_MODULE ) || ( pWin->IsA( TYPE( DialogWindow ) ) && nType == BASICIDE_TYPE_DIALOG ) ) ) - { return pWin; } } diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index 20de8e9aafba..8da483e209d4 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -51,11 +51,38 @@ #include #include #include +#include +#include +#include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; namespace css = ::com::sun::star; +void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName ) +{ + try + { + uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); + if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) ) + { + script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName ); + uno::Any aObject( aModuleInfo.ModuleObject ); + uno::Reference< lang::XServiceInfo > xServiceInfo( aObject, uno::UNO_QUERY ); + if( xServiceInfo.is() && xServiceInfo->supportsService( rtl::OUString::createFromAscii( "ooo.vba.excel.Worksheet" ) ) ) + { + uno::Reference< container::XNamed > xNamed( aObject, uno::UNO_QUERY ); + if( xNamed.is() ) + rObjName = xNamed->getName(); + } + } + } + catch( uno::Exception& ) + { + } +} + IMPL_LINK_INLINE_START( BasicIDEShell, ObjectDialogCancelHdl, ObjectCatalog *, EMPTYARG ) { ShowObjectDialog( FALSE, TRUE ); @@ -235,7 +262,7 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const if ( !aLibName.Len() ) aLibName = String::CreateFromAscii( "Standard" ); - rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName ); + uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName ); if ( !aModName.Len() ) aModName = rDocument.createObjectName( E_SCRIPTS, aLibName ); @@ -254,11 +281,14 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const if ( bSuccess ) { - // new module window + pWin = FindBasWin( rDocument, aLibName, aModName, FALSE, TRUE ); + if( !pWin ) + { // new module window pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule ); nKey = InsertWindowInTable( pWin ); } } + } else { pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED ); @@ -271,7 +301,21 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const } DBG_ASSERT( nKey, "CreateBasWin: Kein Key- Fenster nicht gefunden!" ); } + if( nKey ) + { + if( xLib.is() ) + { + // display a nice friendly name in the ObjectModule tab, + // combining the objectname and module name, e.g. Sheet1 ( Financials ) + String sObjName; + lcl_getObjectName( xLib, rModName, sObjName ); + if( sObjName.Len() ) + { + aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")"); + } + } pTabBar->InsertPage( (USHORT)nKey, aModName ); + } pTabBar->Sort(); pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar ); if ( !pCurWin ) diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index 2c3ccc4eb678..9e698af58917 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -77,6 +77,9 @@ #include #include #include +#include +#include +#include #include @@ -84,6 +87,71 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star; using ::rtl::OUString; +static const rtl::OUString sStandardLibName( rtl::OUString::createFromAscii("Standard") ); + +typedef ::cppu::WeakImplHelper1< container::XContainerListener > ContainerListenerBASE; + +class ContainerListenerImpl : public ContainerListenerBASE +{ + BasicIDEShell* mpShell; +public: + + ContainerListenerImpl( BasicIDEShell* pShell ) : mpShell( pShell ) {} + + ~ContainerListenerImpl() + { + } + + void addContainerListener( const ScriptDocument& rScriptDocument, const String& aLibName ) + { + try + { + uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, FALSE ), uno::UNO_QUERY ); + if ( rScriptDocument.isDocument() && xContainer.is() ) + { + uno::Reference< container::XContainerListener > xContainerListener( this ); + xContainer->addContainerListener( xContainerListener ); + } + } + catch( uno::Exception& ) {} + } + void removeContainerListener( const ScriptDocument& rScriptDocument, const String& aLibName ) + { + try + { + uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, FALSE ), uno::UNO_QUERY ); + if ( rScriptDocument.isDocument() && xContainer.is() ) + { + uno::Reference< container::XContainerListener > xContainerListener( this ); + xContainer->removeContainerListener( xContainerListener ); + } + } + catch( uno::Exception& ) {} + } + + // XEventListener + virtual void SAL_CALL disposing( const lang::EventObject& ) throw( uno::RuntimeException ) {} + + // XContainerListener + virtual void SAL_CALL elementInserted( const container::ContainerEvent& Event ) throw( uno::RuntimeException ) + { + rtl::OUString sModuleName; + if( mpShell && ( Event.Accessor >>= sModuleName ) ) + mpShell->FindBasWin( mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, TRUE, FALSE ); + } + virtual void SAL_CALL elementReplaced( const container::ContainerEvent& ) throw( com::sun::star::uno::RuntimeException ) { } + virtual void SAL_CALL elementRemoved( const container::ContainerEvent& Event ) throw( com::sun::star::uno::RuntimeException ) + { + rtl::OUString sModuleName; + if( mpShell && ( Event.Accessor >>= sModuleName ) ) + { + IDEBaseWindow* pWin = mpShell->FindWindow( mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, BASICIDE_TYPE_MODULE, TRUE ); + if( pWin ) + mpShell->RemoveWindow( pWin, FALSE, TRUE ); + } + } + +}; TYPEINIT1( BasicIDEShell, SfxViewShell ); @@ -121,6 +189,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFrame* pFrame_, SfxViewShell* /* pOldShell m_bAppBasicModified( FALSE ), m_aNotifier( *this ) { + m_xLibListener = new ContainerListenerImpl( this ); Init(); GnBasicIDEShellCount++; } @@ -212,6 +281,12 @@ __EXPORT BasicIDEShell::~BasicIDEShell() delete pTabBar; delete pObjectCatalog; DestroyModulWindowLayout(); + + ContainerListenerImpl* pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() ); + // Destroy all ContainerListeners for Basic Container. + if ( pListener ) + pListener->removeContainerListener( m_aCurDocument, m_aCurLibName ); + // MI: Das gab einen GPF im SDT beim Schliessen da dann der ViewFrame die // ObjSh loslaesst. Es wusste auch keiner mehr wozu das gut war. // GetViewFrame()->GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_DYING ) ); @@ -828,9 +903,22 @@ void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, BOOL bDestroy, BOOL b { pWindow_->AddStatus( BASWIN_TOBEKILLED ); pWindow_->Hide(); - StarBASIC::Stop(); - // Es kommt kein Notify... - pWindow_->BasicStopped(); + // In normal mode stop basic in windows to be deleted + // In VBA stop basic only if the running script is trying to delete + // its parent module + bool bStop = true; + if ( pWindow_->GetDocument().isInVBAMode() ) + { + SbModule* pMod = StarBASIC::GetActiveModule(); + if ( !pMod || ( pMod && ( pMod->GetName() != pWindow_->GetName() ) ) ) + bStop = false; + } + if ( bStop ) + { + StarBASIC::Stop(); + // Es kommt kein Notify... + pWindow_->BasicStopped(); + } aIDEWindowTable.Insert( nKey, pWindow_ ); // wieder einhaegen } } @@ -918,7 +1006,19 @@ void BasicIDEShell::SetCurLib( const ScriptDocument& rDocument, String aLibName, { if ( !bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName ) ) { + ContainerListenerImpl* pListener = NULL; + + if ( rDocument.isInVBAMode() ) + pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() ); + + if ( pListener ) + pListener->removeContainerListener( m_aCurDocument, m_aCurLibName ); + m_aCurDocument = rDocument; + + if ( pListener ) + pListener->addContainerListener( m_aCurDocument, aLibName ); + m_aCurLibName = aLibName; if ( bUpdateWindows ) UpdateWindows(); diff --git a/basctl/source/basicide/basidesh.src b/basctl/source/basicide/basidesh.src index f0c0727cd22f..556211f690af 100644 --- a/basctl/source/basicide/basidesh.src +++ b/basctl/source/basicide/basidesh.src @@ -636,6 +636,22 @@ String RID_STR_TRANSLATION_DEFAULT { Text [ en-US ] = "[Default Language]" ; }; +String RID_STR_DOCUMENT_OBJECTS +{ + Text [ en-US ] = "Document Objects" ; +}; +String RID_STR_USERFORMS +{ + Text [ en-US ] = "Forms" ; +}; +String RID_STR_NORMAL_MODULES +{ + Text [ en-US ] = "Modules" ; +}; +String RID_STR_CLASS_MODULES +{ + Text [ en-US ] = "Class Modules" ; +}; String RID_STR_DLGIMP_CLASH_RENAME diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index a37eb752e2ea..bf13b554a0a6 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -50,10 +50,28 @@ #include #include #include +#include +#include +#include +#include +#include using namespace ::com::sun::star::uno; using namespace ::com::sun::star; +void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName ); + +sal_Int32 lcl_getModuleType( const uno::Reference< container::XNameContainer >& rLib, const String& rModName ) +{ + sal_Int32 nType = com::sun::star::script::ModuleType::Normal; + uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); + if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) ) + { + script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName ); + nType = aModuleInfo.ModuleType; + } + return nType; +} BasicEntry::~BasicEntry() { @@ -88,20 +106,22 @@ BasicEntryDescriptor::BasicEntryDescriptor() { } -BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, BasicEntryType eType ) +BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, BasicEntryType eType ) :m_aDocument( rDocument ) ,m_eLocation( eLocation ) ,m_aLibName( rLibName ) + ,m_aLibSubName( rLibSubName ) ,m_aName( rName ) ,m_eType( eType ) { OSL_ENSURE( m_aDocument.isValid(), "BasicEntryDescriptor::BasicEntryDescriptor: invalid document!" ); } -BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, const String& rMethodName, BasicEntryType eType ) +BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, const String& rMethodName, BasicEntryType eType ) :m_aDocument( rDocument ) ,m_eLocation( eLocation ) ,m_aLibName( rLibName ) + ,m_aLibSubName( rLibSubName ) ,m_aName( rName ) ,m_aMethodName( rMethodName ) ,m_eType( eType ) @@ -117,6 +137,7 @@ BasicEntryDescriptor::BasicEntryDescriptor( const BasicEntryDescriptor& rDesc ) :m_aDocument( rDesc.m_aDocument ) ,m_eLocation( rDesc.m_eLocation ) ,m_aLibName( rDesc.m_aLibName ) + ,m_aLibSubName( rDesc.m_aLibSubName ) ,m_aName( rDesc.m_aName ) ,m_aMethodName( rDesc.m_aMethodName ) ,m_eType( rDesc.m_eType ) @@ -128,6 +149,7 @@ BasicEntryDescriptor& BasicEntryDescriptor::operator=( const BasicEntryDescripto m_aDocument = rDesc.m_aDocument; m_eLocation = rDesc.m_eLocation; m_aLibName = rDesc.m_aLibName; + m_aLibSubName = rDesc.m_aLibSubName; m_aName = rDesc.m_aName; m_aMethodName = rDesc.m_aMethodName; m_eType = rDesc.m_eType; @@ -140,6 +162,7 @@ bool BasicEntryDescriptor::operator==( const BasicEntryDescriptor& rDesc ) const return m_aDocument == rDesc.m_aDocument && m_eLocation == rDesc.m_eLocation && m_aLibName == rDesc.m_aLibName && + m_aLibSubName == rDesc.m_aLibSubName && m_aName == rDesc.m_aName && m_aMethodName == rDesc.m_aMethodName && m_eType == rDesc.m_eType; @@ -284,6 +307,11 @@ void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const { try { + sal_Bool bVBAEnabled = rDocument.isInVBAMode(); + if( bVBAEnabled ) + ImpCreateLibSubEntriesInVBAMode( pLibRootEntry, rDocument, rLibName ); + else + { // get a sorted list of module names Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName ); sal_Int32 nModCount = aModNames.getLength(); @@ -323,6 +351,7 @@ void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const } } } + } catch ( const container::NoSuchElementException& ) { DBG_UNHANDLED_EXCEPTION(); @@ -365,6 +394,139 @@ void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const } } +void BasicTreeListBox::ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName ) +{ + ::std::map< BasicEntryType, ::rtl::OUString > aEntryMap; + aEntryMap.insert( ::std::make_pair( OBJ_TYPE_DOCUMENT_OBJECTS, String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ); + aEntryMap.insert( ::std::make_pair( OBJ_TYPE_USERFORMS, String( IDEResId( RID_STR_USERFORMS ) ) ) ); + aEntryMap.insert( ::std::make_pair( OBJ_TYPE_NORMAL_MODULES, String( IDEResId( RID_STR_NORMAL_MODULES ) ) ) ); + aEntryMap.insert( ::std::make_pair( OBJ_TYPE_CLASS_MODULES, String( IDEResId( RID_STR_CLASS_MODULES ) ) ) ); + + ::std::map< BasicEntryType, ::rtl::OUString >::iterator iter; + for( iter = aEntryMap.begin(); iter != aEntryMap.end(); ++iter ) + { + BasicEntryType eType = iter->first; + ::rtl::OUString aEntryName = iter->second; + SvLBoxEntry* pLibSubRootEntry = FindEntry( pLibRootEntry, aEntryName, eType ); + if( pLibSubRootEntry ) + { + SetEntryBitmaps( pLibSubRootEntry, Image( IDEResId( RID_IMG_MODLIB ) ), Image( IDEResId( RID_IMG_MODLIB_HC ) ) ); + if ( IsExpanded( pLibSubRootEntry ) ) + ImpCreateLibSubSubEntriesInVBAMode( pLibSubRootEntry, rDocument, rLibName ); + } + else + { + pLibSubRootEntry = AddEntry( + aEntryName, + Image( IDEResId( RID_IMG_MODLIB ) ), + Image( IDEResId( RID_IMG_MODLIB_HC ) ), + pLibRootEntry, true, + std::auto_ptr< BasicEntry >( new BasicEntry( eType ) ) ); + } + } +} + +void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const String& rLibName ) +{ + uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, rLibName ); + if( !xLib.is() ) + return; + + try + { + // get a sorted list of module names + Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName ); + sal_Int32 nModCount = aModNames.getLength(); + const ::rtl::OUString* pModNames = aModNames.getConstArray(); + + BasicEntryDescriptor aDesc( GetEntryDescriptor( pLibSubRootEntry ) ); + BasicEntryType eCurrentType( aDesc.GetType() ); + + for ( sal_Int32 i = 0 ; i < nModCount ; i++ ) + { + String aModName = pModNames[ i ]; + BasicEntryType eType = OBJ_TYPE_UNKNOWN; + switch( lcl_getModuleType( xLib, aModName ) ) + { + case script::ModuleType::Document: + eType = OBJ_TYPE_DOCUMENT_OBJECTS; + break; + case script::ModuleType::Form: + eType = OBJ_TYPE_USERFORMS; + break; + case script::ModuleType::Normal: + eType = OBJ_TYPE_NORMAL_MODULES; + break; + case script::ModuleType::Class: + eType = OBJ_TYPE_CLASS_MODULES; + break; + } + if( eType != eCurrentType ) + continue; + + // display a nice friendly name in the ObjectModule tab, + // combining the objectname and module name, e.g. Sheet1 ( Financials ) + String aEntryName( aModName ); + if( eType == OBJ_TYPE_DOCUMENT_OBJECTS ) + { + String sObjName; + lcl_getObjectName( xLib, aModName, sObjName ); + if( sObjName.Len() ) + { + aEntryName.AppendAscii(" (").Append(sObjName).AppendAscii(")"); + } + } + SvLBoxEntry* pModuleEntry = FindEntry( pLibSubRootEntry, aEntryName, OBJ_TYPE_MODULE ); + if ( !pModuleEntry ) + pModuleEntry = AddEntry( + aEntryName, + Image( IDEResId( RID_IMG_MODULE ) ), + Image( IDEResId( RID_IMG_MODULE_HC ) ), + pLibSubRootEntry, false, + std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) ); + + // methods + if ( nMode & BROWSEMODE_SUBS ) + { + Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName ); + sal_Int32 nCount = aNames.getLength(); + const ::rtl::OUString* pNames = aNames.getConstArray(); + + for ( sal_Int32 j = 0 ; j < nCount ; j++ ) + { + String aName = pNames[ j ]; + SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD ); + if ( !pEntry ) + pEntry = AddEntry( + aName, + Image( IDEResId( RID_IMG_MACRO ) ), + Image( IDEResId( RID_IMG_MACRO_HC ) ), + pModuleEntry, false, + std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) ); + } + } + } + } + catch ( const container::NoSuchElementException& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +SvLBoxEntry* BasicTreeListBox::ImpFindEntry( SvLBoxEntry* pParent, const String& rText ) +{ + ULONG nRootPos = 0; + SvLBoxEntry* pEntry = pParent ? FirstChild( pParent ) : GetEntry( nRootPos ); + while ( pEntry ) + { + if ( GetEntryText( pEntry ) == rText ) + return pEntry; + + pEntry = pParent ? NextSibling( pEntry ) : GetEntry( ++nRootPos ); + } + return 0; +} + void BasicTreeListBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ ) { UpdateEntries(); @@ -477,10 +639,11 @@ long BasicTreeListBox::ExpandingHdl() if ( aDocument.isAlive() ) { String aLibName( aDesc.GetLibName() ); + String aLibSubName( aDesc.GetLibSubName() ); String aName( aDesc.GetName() ); String aMethodName( aDesc.GetMethodName() ); - if ( aLibName.Len() && !aName.Len() && !aMethodName.Len() ) + if ( aLibName.Len() && !aLibSubName.Len() && !aName.Len() && !aMethodName.Len() ) { // check password, if library is password protected and not verified ::rtl::OUString aOULibName( aLibName ); @@ -633,7 +796,7 @@ void BasicTreeListBox::SetCurrentEntry( BasicEntryDescriptor& rDesc ) aDesc = BasicEntryDescriptor( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER, String::CreateFromAscii( "Standard" ), - String::CreateFromAscii( "." ), OBJ_TYPE_UNKNOWN ); + String(), String::CreateFromAscii( "." ), OBJ_TYPE_UNKNOWN ); } ScriptDocument aDocument( aDesc.GetDocument() ); OSL_ENSURE( aDocument.isValid(), "BasicTreeListBox::SetCurrentEntry: invalid document!" ); @@ -650,14 +813,24 @@ void BasicTreeListBox::SetCurrentEntry( BasicEntryDescriptor& rDesc ) if ( pLibEntry ) { pCurEntry = pLibEntry; + String aLibSubName( aDesc.GetLibSubName() ); + if( aLibSubName.Len() ) + { + Expand( pLibEntry ); + SvLBoxEntry* pLibSubEntry = ImpFindEntry( pLibEntry, aLibSubName ); + if( pLibSubEntry ) + { + pCurEntry = pLibSubEntry; + } + } String aName( aDesc.GetName() ); if ( aName.Len() ) { - Expand( pLibEntry ); + Expand( pCurEntry ); BasicEntryType eType = OBJ_TYPE_MODULE; if ( aDesc.GetType() == OBJ_TYPE_DIALOG ) eType = OBJ_TYPE_DIALOG; - SvLBoxEntry* pEntry = FindEntry( pLibEntry, aName, eType ); + SvLBoxEntry* pEntry = FindEntry( pCurEntry, aName, eType ); if ( pEntry ) { pCurEntry = pEntry; diff --git a/basctl/source/basicide/bastype2.hxx b/basctl/source/basicide/bastype2.hxx index 401282f7e1bf..4b4d42f477d0 100644 --- a/basctl/source/basicide/bastype2.hxx +++ b/basctl/source/basicide/bastype2.hxx @@ -39,7 +39,7 @@ #include #include "basobj.hxx" -enum BasicEntryType { OBJ_TYPE_UNKNOWN, OBJ_TYPE_DOCUMENT, OBJ_TYPE_LIBRARY, OBJ_TYPE_MODULE, OBJ_TYPE_DIALOG, OBJ_TYPE_METHOD }; +enum BasicEntryType { OBJ_TYPE_UNKNOWN, OBJ_TYPE_DOCUMENT, OBJ_TYPE_LIBRARY, OBJ_TYPE_MODULE, OBJ_TYPE_DIALOG, OBJ_TYPE_METHOD, OBJ_TYPE_DOCUMENT_OBJECTS, OBJ_TYPE_USERFORMS, OBJ_TYPE_NORMAL_MODULES, OBJ_TYPE_CLASS_MODULES }; #define BROWSEMODE_MODULES 0x01 #define BROWSEMODE_SUBS 0x02 @@ -98,14 +98,15 @@ class BasicEntryDescriptor ScriptDocument m_aDocument; LibraryLocation m_eLocation; String m_aLibName; + String m_aLibSubName; // for vba entry: Document Objects, Class Modules, Forms and Normal Modules String m_aName; String m_aMethodName; BasicEntryType m_eType; public: BasicEntryDescriptor(); - BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, BasicEntryType eType ); - BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, const String& rMethodName, BasicEntryType eType ); + BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, BasicEntryType eType ); + BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, const String& rMethodName, BasicEntryType eType ); virtual ~BasicEntryDescriptor(); BasicEntryDescriptor( const BasicEntryDescriptor& rDesc ); @@ -122,6 +123,9 @@ public: const String& GetLibName() const { return m_aLibName; } void SetLibName( const String& aLibName ) { m_aLibName = aLibName; } + const String& GetLibSubName() const { return m_aLibSubName; } + void SetLibSubName( const String& aLibSubName ) { m_aLibSubName = aLibSubName; } + const String& GetName() const { return m_aName; } void SetName( const String& aName ) { m_aName = aName; } @@ -161,6 +165,9 @@ protected: void ImpCreateLibEntries( SvLBoxEntry* pShellRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation ); void ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName ); + void ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName ); + void ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const String& rLibName ); + SvLBoxEntry* ImpFindEntry( SvLBoxEntry* pParent, const String& rText ); // DocumentEventListener virtual void onDocumentCreated( const ScriptDocument& _rDocument ); diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx index a0320d89e88a..de9eff56ca24 100644 --- a/basctl/source/basicide/bastype3.cxx +++ b/basctl/source/basicide/bastype3.cxx @@ -131,6 +131,14 @@ void __EXPORT BasicTreeListBox::RequestingChilds( SvLBoxEntry* pEntry ) } } } + else if ( eType == OBJ_TYPE_DOCUMENT_OBJECTS + || eType == OBJ_TYPE_USERFORMS + || eType == OBJ_TYPE_NORMAL_MODULES + || eType == OBJ_TYPE_CLASS_MODULES ) + { + String aLibName( aDesc.GetLibName() ); + ImpCreateLibSubSubEntriesInVBAMode( pEntry, aDocument, aLibName ); + } else { DBG_ERROR( "BasicTreeListBox::RequestingChilds: Unknown Type!" ); } @@ -201,6 +209,7 @@ SbxVariable* BasicTreeListBox::FindVariable( SvLBoxEntry* pEntry ) } SbxVariable* pVar = 0; + bool bDocumentObjects = false; if ( aEntries.Count() ) { for ( USHORT n = 0; n < aEntries.Count(); n++ ) @@ -223,6 +232,12 @@ SbxVariable* BasicTreeListBox::FindVariable( SvLBoxEntry* pEntry ) case OBJ_TYPE_MODULE: { DBG_ASSERT( pVar && pVar->IsA( TYPE(StarBASIC) ), "FindVariable: Ungueltiges Basic" ); + // extract the module name from the string like "Sheet1 (Example1)" + if( bDocumentObjects ) + { + sal_uInt16 nIndex = 0; + aName = aName.GetToken( 0, ' ', nIndex ); + } pVar = ((StarBASIC*)pVar)->FindModule( aName ); } break; @@ -237,6 +252,15 @@ SbxVariable* BasicTreeListBox::FindVariable( SvLBoxEntry* pEntry ) // sbx dialogs removed } break; + case OBJ_TYPE_DOCUMENT_OBJECTS: + bDocumentObjects = true; + case OBJ_TYPE_USERFORMS: + case OBJ_TYPE_NORMAL_MODULES: + case OBJ_TYPE_CLASS_MODULES: + { + // skip, to find the child entry. + continue; + } default: { DBG_ERROR( "FindVariable: Unbekannter Typ!" ); @@ -257,12 +281,13 @@ BasicEntryDescriptor BasicTreeListBox::GetEntryDescriptor( SvLBoxEntry* pEntry ) ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() ); LibraryLocation eLocation = LIBRARY_LOCATION_UNKNOWN; String aLibName; + String aLibSubName; String aName; String aMethodName; BasicEntryType eType = OBJ_TYPE_UNKNOWN; if ( !pEntry ) - return BasicEntryDescriptor( aDocument, eLocation, aLibName, aName, aMethodName, eType ); + return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType ); EntryArray aEntries; @@ -329,6 +354,15 @@ BasicEntryDescriptor BasicTreeListBox::GetEntryDescriptor( SvLBoxEntry* pEntry ) eType = pBE->GetType(); } break; + case OBJ_TYPE_DOCUMENT_OBJECTS: + case OBJ_TYPE_USERFORMS: + case OBJ_TYPE_NORMAL_MODULES: + case OBJ_TYPE_CLASS_MODULES: + { + aLibSubName = GetEntryText( pLE ); + eType = pBE->GetType(); + } + break; default: { DBG_ERROR( "GetEntryDescriptor: Unbekannter Typ!" ); @@ -342,7 +376,7 @@ BasicEntryDescriptor BasicTreeListBox::GetEntryDescriptor( SvLBoxEntry* pEntry ) } } - return BasicEntryDescriptor( aDocument, eLocation, aLibName, aName, aMethodName, eType ); + return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType ); } USHORT BasicTreeListBox::ConvertType( BasicEntryType eType ) @@ -424,6 +458,14 @@ bool BasicTreeListBox::IsValidEntry( SvLBoxEntry* pEntry ) bIsValid = BasicIDE::HasMethod( aDocument, aLibName, aName, aMethodName ); } break; + case OBJ_TYPE_DOCUMENT_OBJECTS: + case OBJ_TYPE_USERFORMS: + case OBJ_TYPE_NORMAL_MODULES: + case OBJ_TYPE_CLASS_MODULES: + { + bIsValid = true; + } + break; default: ; } diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index af42503a5dae..53f33dfc7e89 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -57,6 +57,7 @@ #include #endif #include +#include using namespace ::com::sun::star::uno; using namespace ::com::sun::star; @@ -584,7 +585,29 @@ void __EXPORT BasicIDETabBar::Command( const CommandEvent& rCEvt ) aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE ); aPopup.RemoveDisabledEntries(); } + + // disable to delete or remove object modules in IDE + BasicManager* pBasMgr = aDocument.getBasicManager(); + if ( pBasMgr ) + { + StarBASIC* pBasic = pBasMgr->GetLib( aOULibName ); + if( pBasic ) + { + IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable(); + IDEBaseWindow* pWin = aIDEWindowTable.Get( GetCurPageId() ); + if( pWin && pWin->ISA( ModulWindow ) ) + { + SbModule* pActiveModule = (SbModule*)pBasic->FindModule( pWin->GetName() ); + if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::Document ) ) + { + aPopup.EnableItem( SID_BASICIDE_DELETECURRENT, FALSE ); + aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE ); } + } + } + } + } + SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx index f3e41e60d34b..41a5fa488950 100644 --- a/basctl/source/basicide/macrodlg.cxx +++ b/basctl/source/basicide/macrodlg.cxx @@ -382,7 +382,15 @@ SbMethod* MacroChooser::CreateMacro() SbModule* pModule = 0; String aModName( aDesc.GetName() ); if ( aModName.Len() ) + { + // extract the module name from the string like "Sheet1 (Example1)" + if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ) + { + sal_uInt16 nIndex = 0; + aModName = aModName.GetToken( 0, ' ', nIndex ); + } pModule = pBasic->FindModule( aModName ); + } else if ( pBasic->GetModules()->Count() ) pModule = (SbModule*)pBasic->GetModules()->Get( 0 ); @@ -710,6 +718,12 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton ) BasicManager* pBasMgr = aDocument.getBasicManager(); String aLib( aDesc.GetLibName() ); String aMod( aDesc.GetName() ); + // extract the module name from the string like "Sheet1 (Example1)" + if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ) + { + sal_uInt16 nIndex = 0; + aMod = aMod.GetToken( 0, ' ', nIndex ); + } String aSub( aDesc.GetMethodName() ); SfxMacroInfoItem aInfoItem( SID_BASICIDE_ARG_MACROINFO, pBasMgr, aLib, aMod, aSub, String() ); if ( pButton == &aEditButton ) diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 478d56546f41..0f66a6ebe120 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -84,7 +84,7 @@ BOOL __EXPORT ExtBasicTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& if ( pEntry ) { USHORT nDepth = GetModel()->GetDepth( pEntry ); - if ( nDepth == 2 ) + if ( nDepth >= 2 ) { BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) ); ScriptDocument aDocument( aDesc.GetDocument() ); @@ -162,7 +162,7 @@ DragDropMode __EXPORT ExtBasicTreeListBox::NotifyStartDrag( TransferDataContaine if ( pEntry ) { USHORT nDepth = GetModel()->GetDepth( pEntry ); - if ( nDepth == 2 ) + if ( nDepth >= 2 ) { nMode_ = SV_DRAGDROP_CTRL_COPY; BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) ); @@ -210,7 +210,7 @@ BOOL __EXPORT ExtBasicTreeListBox::NotifyAcceptDrop( SvLBoxEntry* pEntry ) // don't drop on a library, which is not loaded, readonly or password protected // or which already has a module/dialog with this name - if ( bValid && ( nDepth == 1 || nDepth == 2 ) ) + if ( bValid && ( nDepth > 0 ) ) { // get source module/dialog name BasicEntryDescriptor aSourceDesc( GetEntryDescriptor( pSelected ) ); @@ -348,7 +348,7 @@ BOOL __EXPORT ExtBasicTreeListBox::NotifyCopyingMoving( SvLBoxEntry* pTarget, Sv rpNewParent = pTarget; rNewChildPos = 0; } - else if ( nDepth == 2 ) + else if ( nDepth >= 2 ) { // Target = Modul/Dialog => Modul/Dialog unter das uebergeordnete Basic haengen... rpNewParent = GetParent( pTarget ); @@ -623,20 +623,29 @@ void ObjectPage::CheckButtons() { // enable/disable edit button SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry(); + BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) ); + ScriptDocument aDocument( aDesc.GetDocument() ); + ::rtl::OUString aOULibName( aDesc.GetLibName() ); + String aLibSubName( aDesc.GetLibSubName() ); + sal_Bool bVBAEnabled = aDocument.isInVBAMode(); + USHORT nMode = aBasicBox.GetMode(); + USHORT nDepth = pCurEntry ? aBasicBox.GetModel()->GetDepth( pCurEntry ) : 0; - if ( nDepth == 2 ) + if ( nDepth >= 2 ) + { + if( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( nDepth == 2 ) ) + aEditButton.Disable(); + else aEditButton.Enable(); + } else aEditButton.Disable(); // enable/disable new module/dialog buttons - BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) ); LibraryLocation eLocation( aDesc.GetLocation() ); BOOL bReadOnly = FALSE; - if ( nDepth == 1 || nDepth == 2 ) + if ( nDepth > 0 ) { - ScriptDocument aDocument( aDesc.GetDocument() ); - ::rtl::OUString aOULibName( aDesc.GetLibName() ); Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) || @@ -657,8 +666,13 @@ void ObjectPage::CheckButtons() } // enable/disable delete button - if ( nDepth == 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE ) + if ( nDepth >= 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE ) + { + if( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( ( nDepth == 2 ) || aLibSubName.Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ) ) + aDelButton.Disable(); + else aDelButton.Enable(); + } else aDelButton.Disable(); } @@ -685,13 +699,20 @@ IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton ) SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry(); DBG_ASSERT( pCurEntry, "Entry?!" ); - if ( aBasicBox.GetModel()->GetDepth( pCurEntry ) == 2 ) + if ( aBasicBox.GetModel()->GetDepth( pCurEntry ) >= 2 ) { BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) ); if ( pDispatcher ) { + String aModName( aDesc.GetName() ); + // extract the module name from the string like "Sheet1 (Example1)" + if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ) + { + sal_uInt16 nIndex = 0; + aModName = aModName.GetToken( 0, ' ', nIndex ); + } SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), - aDesc.GetName(), aBasicBox.ConvertType( aDesc.GetType() ) ); + aModName, aBasicBox.ConvertType( aDesc.GetType() ) ); pDispatcher->Execute( SID_BASICIDE_SHOWSBX, SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); } } @@ -973,14 +994,14 @@ SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument, try { ::rtl::OUString sModuleCode; + // the module has existed + if( rDocument.hasModule( aLibName, aModName ) ) + return NULL; rDocument.createModule( aLibName, aModName, bMain, sModuleCode ); BasicManager* pBasMgr = rDocument.getBasicManager(); - if ( pBasMgr ) - { - StarBASIC* pBasic = pBasMgr->GetLib( aLibName ); + StarBASIC* pBasic = pBasMgr? pBasMgr->GetLib( aLibName ) : 0; if ( pBasic ) pModule = pBasic->FindModule( aModName ); - } SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, BASICIDE_TYPE_MODULE ); BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; @@ -1002,14 +1023,27 @@ SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument, { if ( !rBasicBox.IsExpanded( pLibEntry ) ) rBasicBox.Expand( pLibEntry ); - SvLBoxEntry* pEntry = rBasicBox.FindEntry( pLibEntry, aModName, OBJ_TYPE_MODULE ); + SvLBoxEntry* pSubRootEntry = pLibEntry; + if( pBasic && rDocument.isInVBAMode() ) + { + // add the new module in the "Modules" entry + SvLBoxEntry* pLibSubEntry = rBasicBox.FindEntry( pLibEntry, String( IDEResId( RID_STR_NORMAL_MODULES ) ) , OBJ_TYPE_NORMAL_MODULES ); + if( pLibSubEntry ) + { + if( !rBasicBox.IsExpanded( pLibSubEntry ) ) + rBasicBox.Expand( pLibSubEntry ); + pSubRootEntry = pLibSubEntry; + } + } + + SvLBoxEntry* pEntry = rBasicBox.FindEntry( pSubRootEntry, aModName, OBJ_TYPE_MODULE ); if ( !pEntry ) { pEntry = rBasicBox.AddEntry( aModName, Image( IDEResId( RID_IMG_MODULE ) ), Image( IDEResId( RID_IMG_MODULE_HC ) ), - pLibEntry, false, + pSubRootEntry, false, std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) ); DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" ); } diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index dd10a00e2bde..f246e1613dd8 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -53,6 +53,8 @@ #include #include #include +#include +#include /** === end UNO includes === **/ #include @@ -139,6 +141,9 @@ namespace basctl using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::document::XEventBroadcaster; using ::com::sun::star::document::XEmbeddedScripts; + using ::com::sun::star::script::ModuleInfo; + using ::com::sun::star::script::XVBAModuleInfo; + using ::com::sun::star::script::XVBACompat; /** === end UNO using === **/ namespace MacroExecMode = ::com::sun::star::document::MacroExecMode; namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag; @@ -272,6 +277,7 @@ namespace basctl // versions with the same signature/semantics as in ScriptDocument itself bool isReadOnly() const; + bool isInVBAMode() const; BasicManager* getBasicManager() const; Reference< XModel > @@ -444,6 +450,18 @@ namespace basctl return bIsReadOnly; } + bool ScriptDocument_Impl::isInVBAMode() const + { + bool bResult = false; + if ( !isApplication() ) + { + Reference< XVBACompat > xVBACompat( getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); + if ( xVBACompat.is() ) + bResult = xVBACompat->getVBACompatModeOn(); + } + return bResult; + } + //-------------------------------------------------------------------- BasicManager* ScriptDocument_Impl::getBasicManager() const { @@ -462,6 +480,8 @@ namespace basctl { OSL_ENSURE( isValid(), "ScriptDocument_Impl::getDocument: invalid state!" ); OSL_ENSURE( isDocument(), "ScriptDocument_Impl::getDocument: for documents only!" ); + if ( !isDocument() ) + OSL_TRACE("**** BAHHHH!!!*****"); if ( !isValid() || !isDocument() ) return NULL; @@ -671,6 +691,16 @@ namespace basctl } // insert element by new name in container + if ( _eType == E_SCRIPTS ) + { + Reference< XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); + if ( xVBAModuleInfo->hasModuleInfo( _rOldName ) ) + { + ModuleInfo sModuleInfo = xVBAModuleInfo->getModuleInfo( _rOldName ); + xVBAModuleInfo->removeModuleInfo( _rOldName ); + xVBAModuleInfo->insertModuleInfo( _rNewName, sModuleInfo ); + } + } xLib->insertByName( _rNewName, aElement ); return true; } @@ -735,8 +765,7 @@ namespace basctl Reference< XNameContainer > xLib( getOrCreateLibrary( E_SCRIPTS, _rLibName ), UNO_QUERY_THROW ); if ( !xLib->hasByName( _rModName ) ) return false; - - xLib->replaceByName( _rModName, makeAny( _rModuleCode ) ); + xLib->replaceByName( _rModName, makeAny( _rModuleCode ) ); return true; } catch( const Exception& ) @@ -1351,6 +1380,11 @@ namespace basctl return m_pImpl->isApplication(); } + bool ScriptDocument::isInVBAMode() const + { + return m_pImpl->isInVBAMode(); + } + //-------------------------------------------------------------------- BasicManager* ScriptDocument::getBasicManager() const { diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 326098976d87..65059f3b759b 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -205,7 +205,7 @@ BOOL DlgEditor::RemarkDialog() //---------------------------------------------------------------------------- -DlgEditor::DlgEditor() +DlgEditor::DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ) :pHScroll(NULL) ,pVScroll(NULL) ,pDlgEdModel(NULL) @@ -227,6 +227,7 @@ DlgEditor::DlgEditor() ,bCreateOK(TRUE) ,bDialogModelChanged(FALSE) ,mnPaintGuard(0) + ,m_xDocument( xModel ) { pDlgEdModel = new DlgEdModel(); pDlgEdModel->GetItemPool().FreezeIdRanges(); diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 5af7519f85f0..fcade49d1c8b 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -74,6 +74,22 @@ TYPEINIT1(DlgEdObj, SdrUnoObj); DBG_NAME(DlgEdObj); //---------------------------------------------------------------------------- +MapMode lcl_getMapModeForForm( DlgEdForm* pForm ) +{ + MapMode aMode( MAP_APPFONT ); //Default + try + { + uno::Reference< beans::XPropertySet > xProps( pForm ? pForm->GetUnoControlModel() : NULL, uno::UNO_QUERY_THROW ); + sal_Bool bVBAForm = sal_False; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VBAForm") ) ) >>= bVBAForm; + if ( bVBAForm ) + aMode = MapMode( MAP_100TH_MM ); + } + catch ( Exception& ) + { + } + return aMode; +} DlgEdObj::DlgEdObj() :SdrUnoObj(String(), sal_False) @@ -194,8 +210,9 @@ bool DlgEdObj::TransformSdrToControlCoordinates( } // convert pixel to logic units - aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_APPFONT ) ); - aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_APPFONT ) ); + MapMode aConvMode = lcl_getMapModeForForm( pForm ); + aPos = pDevice->PixelToLogic( aPos, aConvMode ); + aSize = pDevice->PixelToLogic( aSize, aConvMode ); // set out parameters nXOut = aPos.Width(); @@ -242,10 +259,10 @@ bool DlgEdObj::TransformSdrToFormCoordinates( aSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset; aSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset; } - + MapMode aConvMode = lcl_getMapModeForForm( pForm ); // convert pixel to logic units - aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_APPFONT ) ); - aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_APPFONT ) ); + aPos = pDevice->PixelToLogic( aPos, aConvMode ); + aSize = pDevice->PixelToLogic( aSize, aConvMode ); // set out parameters nXOut = aPos.Width(); @@ -287,9 +304,10 @@ bool DlgEdObj::TransformControlToSdrCoordinates( DBG_ASSERT( pDevice, "DlgEdObj::TransformControlToSdrCoordinates: missing default device!" ); if ( !pDevice ) return false; - aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_APPFONT ) ); - aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_APPFONT ) ); - aFormPos = pDevice->LogicToPixel( aFormPos, MapMode( MAP_APPFONT ) ); + MapMode aConvMode = lcl_getMapModeForForm( pForm ); + aPos = pDevice->LogicToPixel( aPos, aConvMode ); + aSize = pDevice->LogicToPixel( aSize, aConvMode ); + aFormPos = pDevice->LogicToPixel( aFormPos, aConvMode ); // add form position aPos.Width() += aFormPos.Width(); @@ -333,14 +351,16 @@ bool DlgEdObj::TransformFormToSdrCoordinates( DBG_ASSERT( pDevice, "DlgEdObj::TransformFormToSdrCoordinates: missing default device!" ); if ( !pDevice ) return false; - aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_APPFONT ) ); - aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_APPFONT ) ); // take window borders into account DlgEdForm* pForm = NULL; if ( !lcl_getDlgEdForm( this, pForm ) ) return false; + MapMode aConvMode = lcl_getMapModeForForm( pForm ); + aPos = pDevice->LogicToPixel( aPos, aConvMode ); + aSize = pDevice->LogicToPixel( aSize, aConvMode ); + // take window borders into account Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY ); DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" ); diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx index cf21d3488dd3..07bc2dfa3149 100644 --- a/basctl/source/inc/basidesh.hxx +++ b/basctl/source/inc/basidesh.hxx @@ -46,6 +46,7 @@ #include #endif +#include //---------------------------------------------------------------------------- @@ -105,6 +106,8 @@ friend bool BasicIDE::RemoveDialog( const ScriptDocument& rDocument, const Strin BOOL m_bAppBasicModified; ::basctl::DocumentEventNotifier m_aNotifier; +friend class ContainerListenerImpl; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xLibListener; #if _SOLAR__PRIVATE void Init(); diff --git a/basctl/source/inc/dlged.hxx b/basctl/source/inc/dlged.hxx index 1444bab59c65..f49d684cbe80 100644 --- a/basctl/source/inc/dlged.hxx +++ b/basctl/source/inc/dlged.hxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -128,9 +129,11 @@ protected: BOOL bDialogModelChanged; Timer aMarkTimer; long mnPaintGuard; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocument; + DlgEditor(); // not implemented public: - DlgEditor(); + DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ); ~DlgEditor(); void SetWindow( Window* pWindow ); diff --git a/basctl/source/inc/scriptdocument.hxx b/basctl/source/inc/scriptdocument.hxx index 34d1a72963ce..9439c05f7249 100644 --- a/basctl/source/inc/scriptdocument.hxx +++ b/basctl/source/inc/scriptdocument.hxx @@ -212,6 +212,7 @@ namespace basctl */ bool isAlive() const; + bool isInVBAMode() const; /// returns the BasicManager associated with this instance BasicManager* getBasicManager() const; -- cgit From dce859e723f91c9f693a75d146c26dea22634304 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 12:44:46 +0000 Subject: npower13_objectmodule: #i109734# object module stuff new files --- basic/inc/basic/sbobjmod.hxx | 96 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 basic/inc/basic/sbobjmod.hxx diff --git a/basic/inc/basic/sbobjmod.hxx b/basic/inc/basic/sbobjmod.hxx new file mode 100644 index 000000000000..ad83e4fbc44b --- /dev/null +++ b/basic/inc/basic/sbobjmod.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sbobjmod.hxx,v $ + * + * $Revision: 1.4 $ + * + * last change: $Author: $ $Date: 2007/08/27 16:31:39 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _SB_OBJMOD_HXX +#define _SB_OBJMOD_HXX + +#include +#include +#include +#include +#include +#include + +namespace css = ::com::sun::star; + +// Basic-Module for excel object. + +class SbObjModule : public SbModule +{ + SbObjModule( const SbObjModule& ); + SbObjModule(); +public: + TYPEINFO(); + SbObjModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVbaCompatible ); + virtual SbxVariable* Find( const XubString& rName, SbxClassType t ); + SbxVariable* GetObject(); + void SetUnoObject( const com::sun::star::uno::Any& aObj )throw ( com::sun::star::uno::RuntimeException ) ; +}; + +class SbUserFormModule : public SbObjModule +{ + css::uno::Reference m_DialogListener; + css::uno::Reference m_xDialog; + css::uno::Reference m_xModel; + String sFormName; + bool mbInit; + SbUserFormModule( const SbUserFormModule& ); + SbUserFormModule(); + +protected: + virtual void InitObject(); +public: + TYPEINFO(); + SbUserFormModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat ); + virtual SbxVariable* Find( const XubString& rName, SbxClassType t ); + void ResetApiObj(); + void Unload(); + void load(); + void triggerMethod( const String& ); + void triggerMethod( const String&, css::uno::Sequence< css::uno::Any >& ); + void triggerActivateEvent(); + void triggerDeActivateEvent(); + void triggerInitializeEvent(); + void triggerTerminateEvent(); +}; + +#ifndef __SB_SBOBJMODULEREF_HXX +#define __SB_SBOBJMODULEREF_HXX + +SV_DECL_IMPL_REF(SbObjModule); + +#endif +#endif + -- cgit From 6984c82b9c3d47502de87cdf5f950c382768ac77 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 12:44:46 +0000 Subject: npower13_objectmodule: #i109734# object module stuff new files --- offapi/com/sun/star/script/XVBACompat.idl | 49 ++++++++++++++++++ offapi/com/sun/star/script/XVBAModuleInfo.idl | 73 +++++++++++++++++++++++++++ udkapi/com/sun/star/script/ModuleInfo.idl | 55 ++++++++++++++++++++ udkapi/com/sun/star/script/ModuleType.idl | 58 +++++++++++++++++++++ 4 files changed, 235 insertions(+) create mode 100644 offapi/com/sun/star/script/XVBACompat.idl create mode 100644 offapi/com/sun/star/script/XVBAModuleInfo.idl create mode 100644 udkapi/com/sun/star/script/ModuleInfo.idl create mode 100644 udkapi/com/sun/star/script/ModuleType.idl diff --git a/offapi/com/sun/star/script/XVBACompat.idl b/offapi/com/sun/star/script/XVBACompat.idl new file mode 100644 index 000000000000..09da54eb27cd --- /dev/null +++ b/offapi/com/sun/star/script/XVBACompat.idl @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: XLibraryContainer.idl,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_script_XVBACompat_idl__ +#define __com_sun_star_script_XVBACompat_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif + +//============================================================================= + +module com { module sun { module star { module script { + +interface XVBACompat: com::sun::star::uno::XInterface +{ + +//============================================================================= + [attribute ] boolean VBACompatModeOn; + +}; }; }; }; +}; +#endif diff --git a/offapi/com/sun/star/script/XVBAModuleInfo.idl b/offapi/com/sun/star/script/XVBAModuleInfo.idl new file mode 100644 index 000000000000..f9c4e64223c3 --- /dev/null +++ b/offapi/com/sun/star/script/XVBAModuleInfo.idl @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: XLibraryContainer.idl,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_script_XVBACompat_idl__ +#define __com_sun_star_script_XVBACompat_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif +#ifndef __com_sun_star_script_ModuleInfo_idl__ +#include +#endif +#ifndef __com_sun_star_lang_IllegalArgumentException_idl__ +#include +#endif +#ifndef __com_sun_star_container_ElementExistException_idl__ +#include +#endif +#ifndef __com_sun_star_lang_WrappedTargetException_idl__ +#include +#endif +#ifndef __com_sun_star_container_NoSuchElementException_idl__ +#include +#endif + +//============================================================================= + +module com { module sun { module star { module script { + +interface XVBAModuleInfo: com::sun::star::uno::XInterface +{ + + com::sun::star::script::ModuleInfo getModuleInfo( [in] string ModuleName ) + raises( com::sun::star::container::NoSuchElementException, + com::sun::star::lang::WrappedTargetException ); + boolean hasModuleInfo( [in] string ModuleName ); + void insertModuleInfo( [in] string ModuleName, + [in] com::sun::star::script::ModuleInfo ModuleInfo ) + raises( com::sun::star::lang::IllegalArgumentException, + com::sun::star::container::ElementExistException, + com::sun::star::lang::WrappedTargetException ); + void removeModuleInfo( [in] string ModuleName ) + raises( com::sun::star::container::NoSuchElementException, + com::sun::star::lang::WrappedTargetException ); +}; }; }; }; +}; +#endif diff --git a/udkapi/com/sun/star/script/ModuleInfo.idl b/udkapi/com/sun/star/script/ModuleInfo.idl new file mode 100644 index 000000000000..ea7684692e8e --- /dev/null +++ b/udkapi/com/sun/star/script/ModuleInfo.idl @@ -0,0 +1,55 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ModuleInfo.idl,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef __com_sun_star_script_ModuleInfo_idl__ +#define __com_sun_star_script_ModuleInfo_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif + +//============================================================================= +module com { module sun { module star { module script { +struct ModuleInfo +{ + com::sun::star::uno::XInterface ModuleObject; + short ModuleType; +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/udkapi/com/sun/star/script/ModuleType.idl b/udkapi/com/sun/star/script/ModuleType.idl new file mode 100644 index 000000000000..adf51e0dc6f1 --- /dev/null +++ b/udkapi/com/sun/star/script/ModuleType.idl @@ -0,0 +1,58 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ModuleType.idl,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef __com_sun_star_script_ModuleType_idl__ +#define __com_sun_star_script_ModuleType_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif + +//============================================================================= +module com { module sun { module star { module script { +published constants ModuleType +{ + const long Unknown = 0; + const long Normal = 1; + const long Class = 2; + const long Form = 3; + const long Document = 4; +}; + +//============================================================================= + +}; }; }; }; + +#endif -- cgit From 9f7b39fd2ef894846e9d4532272edeb2c11cc208 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 15:04:15 +0000 Subject: npower14miscfixes: #i109706# move back msvbahelper to the filter module --- vbahelper/inc/vbahelper/msvbahelper.hxx | 55 --- vbahelper/source/vbahelper/makefile.mk | 1 - vbahelper/source/vbahelper/msvbahelper.cxx | 381 --------------------- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 2 +- .../source/vbahelper/vbacommandbarcontrol.cxx | 2 +- vbahelper/util/makefile.mk | 1 + 6 files changed, 3 insertions(+), 439 deletions(-) delete mode 100644 vbahelper/inc/vbahelper/msvbahelper.hxx delete mode 100644 vbahelper/source/vbahelper/msvbahelper.cxx diff --git a/vbahelper/inc/vbahelper/msvbahelper.hxx b/vbahelper/inc/vbahelper/msvbahelper.hxx deleted file mode 100644 index 898c44c349bc..000000000000 --- a/vbahelper/inc/vbahelper/msvbahelper.hxx +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _MSVBAHELPER_HXX -#define _MSVBAHELPER_HXX - -#include -#include - -namespace ooo { namespace vba -{ - class VBAHELPER_DLLPUBLIC VBAMacroResolvedInfo - { - SfxObjectShell* mpDocContext; - bool mbFound; - String msResolvedMacro; - public: - VBAMacroResolvedInfo() : mpDocContext(NULL), mbFound( false ){} - void SetResolved( bool bRes ) { mbFound = bRes; } - bool IsResolved() { return mbFound; } - void SetMacroDocContext(SfxObjectShell* pShell ) { mpDocContext = pShell; } - SfxObjectShell* MacroDocContext() { return mpDocContext; } - String ResolvedMacro() { return msResolvedMacro; } - void SetResolvedMacro(const String& sMacro ) { msResolvedMacro = sMacro; } - }; - - VBAHELPER_DLLPUBLIC String makeMacroURL( const String& sMacroName ); - VBAHELPER_DLLPUBLIC VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUString& sMod, bool bSearchGlobalTemplates = false ); - VBAHELPER_DLLPUBLIC sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArgs, com::sun::star::uno::Any& aRet, const com::sun::star::uno::Any& aCaller ); -} } - -#endif diff --git a/vbahelper/source/vbahelper/makefile.mk b/vbahelper/source/vbahelper/makefile.mk index 88f8f53bd5bf..791a3ebdcb76 100644 --- a/vbahelper/source/vbahelper/makefile.mk +++ b/vbahelper/source/vbahelper/makefile.mk @@ -36,7 +36,6 @@ VISIBILITY_HIDDEN=TRUE .INCLUDE : settings.mk SLOFILES=\ - $(SLO)$/msvbahelper.obj \ $(SLO)$/vbahelper.obj \ $(SLO)$/vbapropvalue.obj \ $(SLO)$/vbacommandbars.obj \ diff --git a/vbahelper/source/vbahelper/msvbahelper.cxx b/vbahelper/source/vbahelper/msvbahelper.cxx deleted file mode 100644 index f0d721529b2c..000000000000 --- a/vbahelper/source/vbahelper/msvbahelper.cxx +++ /dev/null @@ -1,381 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define VBAHELPER_DLLIMPLEMENTATION -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::com::sun::star; - -const static rtl::OUString sUrlPart0 = rtl::OUString::createFromAscii( "vnd.sun.star.script:"); -const static rtl::OUString sUrlPart1 = rtl::OUString::createFromAscii( "?language=Basic&location=document"); - -namespace ooo { namespace vba { - -String makeMacroURL( const String& sMacroName ) -{ - return sUrlPart0.concat( sMacroName ).concat( sUrlPart1 ) ; -} - -SfxObjectShell* findShellForUrl( const rtl::OUString& sMacroURLOrPath ) -{ - SfxObjectShell* pFoundShell=NULL; - SfxObjectShell* pShell = SfxObjectShell::GetFirst(); - INetURLObject aObj; - aObj.SetURL( sMacroURLOrPath ); - bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID; - rtl::OUString aURL; - if ( bIsURL ) - aURL = sMacroURLOrPath; - else - { - osl::FileBase::getFileURLFromSystemPath( sMacroURLOrPath, aURL ); - aObj.SetURL( aURL ); - } - OSL_TRACE("Trying to find shell for url %s", rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() ); - while ( pShell ) - { - - uno::Reference< frame::XModel > xModel = pShell->GetModel(); - // are we searching for a template? if so we have to cater for the - // fact that in openoffice a document opened from a template is always - // a new document :/ - if ( xModel.is() ) - { - OSL_TRACE("shell 0x%x has model with url %s and we look for %s", pShell - , rtl::OUStringToOString( xModel->getURL(), RTL_TEXTENCODING_UTF8 ).getStr() - , rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() - ); - if ( sMacroURLOrPath.endsWithIgnoreAsciiCaseAsciiL( ".dot", 4 ) ) - { - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( xModel, uno::UNO_QUERY ); - if( xDocInfoSupp.is() ) - { - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); - rtl::OUString sCurrName = xDocProps->getTemplateName(); - if( sMacroURLOrPath.lastIndexOf( sCurrName ) >= 0 ) - { - pFoundShell = pShell; - break; - } - } - } - else - { - if ( aURL.equals( xModel->getURL() ) ) - { - pFoundShell = pShell; - break; - } - } - } - pShell = SfxObjectShell::GetNext( *pShell ); - } - return pFoundShell; -} - -// sMod can be empty ( but we really need the library to search in ) -// if sMod is empty and a macro is found then sMod is updated -bool hasMacro( SfxObjectShell* pShell, const String& sLibrary, String& sMod, const String& sMacro ) -{ - bool bFound = false; - if ( sLibrary.Len() && sMacro.Len() ) - { - OSL_TRACE("** Searching for %s.%s in library %s" - ,rtl::OUStringToOString( sMod, RTL_TEXTENCODING_UTF8 ).getStr() - ,rtl::OUStringToOString( sMacro, RTL_TEXTENCODING_UTF8 ).getStr() - ,rtl::OUStringToOString( sLibrary, RTL_TEXTENCODING_UTF8 ).getStr() ); - BasicManager* pBasicMgr = pShell-> GetBasicManager(); - if ( pBasicMgr ) - { - StarBASIC* pBasic = pBasicMgr->GetLib( sLibrary ); - if ( !pBasic ) - { - USHORT nId = pBasicMgr->GetLibId( sLibrary ); - pBasicMgr->LoadLib( nId ); - pBasic = pBasicMgr->GetLib( sLibrary ); - } - if ( pBasic ) - { - if ( sMod.Len() ) // we wish to find the macro is a specific module - { - SbModule* pModule = pBasic->FindModule( sMod ); - if ( pModule ) - { - SbxArray* pMethods = pModule->GetMethods(); - if ( pMethods ) - { - SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( sMacro, SbxCLASS_METHOD ) ); - if ( pMethod ) - bFound = true; - } - } - } - else if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sMacro, SbxCLASS_METHOD ) ) ) - { - if( SbModule* pModule = pMethod->GetModule() ) - { - sMod = pModule->GetName(); - bFound = true; - } - } - } - } - } - return bFound; -} -void parseMacro( const rtl::OUString& sMacro, String& sContainer, String& sModule, String& sProcedure ) -{ - sal_Int32 nMacroDot = sMacro.lastIndexOf( '.' ); - - if ( nMacroDot != -1 ) - { - sProcedure = sMacro.copy( nMacroDot + 1 ); - - sal_Int32 nContainerDot = sMacro.lastIndexOf( '.', nMacroDot - 1 ); - if ( nContainerDot != -1 ) - { - sModule = sMacro.copy( nContainerDot + 1, nMacroDot - nContainerDot - 1 ); - sContainer = sMacro.copy( 0, nContainerDot ); - } - else - sModule = sMacro.copy( 0, nMacroDot ); - } - else - sProcedure = sMacro; -} - -VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUString& MacroName, bool bSearchGlobalTemplates ) -{ - VBAMacroResolvedInfo aRes; - if ( !pShell ) - return aRes; - aRes.SetMacroDocContext( pShell ); - // parse the macro name - sal_Int32 nDocSepIndex = MacroName.indexOfAsciiL( "!", 1 ); - String sMacroUrl = MacroName; - - String sContainer; - String sModule; - String sProcedure; - - if( nDocSepIndex > 0 ) - { - // macro specified by document name - // find document shell for document name and call ourselves - // recursively - - // assume for now that the document name is *this* document - String sDocUrlOrPath = MacroName.copy( 0, nDocSepIndex ); - sMacroUrl = MacroName.copy( nDocSepIndex + 1 ); - OSL_TRACE("doc search, current shell is 0x%x", pShell ); - SfxObjectShell* pFoundShell = findShellForUrl( sDocUrlOrPath ); - OSL_TRACE("doc search, after find, found shell is 0x%x", pFoundShell ); - aRes = resolveVBAMacro( pFoundShell, sMacroUrl ); - } - else - { - // macro is contained in 'this' document ( or code imported from a template - // where that template is a global template or perhaps the template this - // document is created from ) - - // macro format = Container.Module.Procedure - parseMacro( MacroName, sContainer, sModule, sProcedure ); - uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY); - uno::Reference< container::XNameContainer > xPrjNameCache; - if ( xSF.is() ) - xPrjNameCache.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAProjectNameProvider" ) ) ), uno::UNO_QUERY ); - - std::vector< rtl::OUString > sSearchList; - - if ( sContainer.Len() > 0 ) - { - // get the Project associated with the Container - if ( xPrjNameCache.is() ) - { - if ( xPrjNameCache->hasByName( sContainer ) ) - { - rtl::OUString sProject; - xPrjNameCache->getByName( sContainer ) >>= sProject; - sContainer = sProject; - } - } - sSearchList.push_back( sContainer ); // First Lib to search - } - else - { - // Ok, if we have no Container specified then we need to search them in order, this document, template this document created from, global templates, - // get the name of Project/Library for 'this' document - rtl::OUString sThisProject; - BasicManager* pBasicMgr = pShell-> GetBasicManager(); - if ( pBasicMgr ) - { - if ( pBasicMgr->GetName().Len() ) - sThisProject = pBasicMgr->GetName(); - else // cater for the case where VBA is not enabled - sThisProject = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ); - } - sSearchList.push_back( sThisProject ); // First Lib to search - if ( xPrjNameCache.is() ) - { - // is this document created from a template? - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( pShell->GetModel(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); - - rtl::OUString sCreatedFrom = xDocProps->getTemplateURL(); - if ( sCreatedFrom.getLength() ) - { - INetURLObject aObj; - aObj.SetURL( sCreatedFrom ); - bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID; - rtl::OUString aURL; - if ( bIsURL ) - aURL = sCreatedFrom; - else - { - osl::FileBase::getFileURLFromSystemPath( sCreatedFrom, aURL ); - aObj.SetURL( aURL ); - } - sCreatedFrom = aObj.GetLastName(); - } - - sal_Int32 nIndex = sCreatedFrom.lastIndexOf( '.' ); - if ( nIndex != -1 ) - sCreatedFrom = sCreatedFrom.copy( 0, nIndex ); - - rtl::OUString sPrj; - if ( sCreatedFrom.getLength() && xPrjNameCache->hasByName( sCreatedFrom ) ) - { - xPrjNameCache->getByName( sCreatedFrom ) >>= sPrj; - // Make sure we don't double up with this project - if ( !sPrj.equals( sThisProject ) ) - sSearchList.push_back( sPrj ); - } - - // get list of global template Names - uno::Sequence< rtl::OUString > sTemplateNames = xPrjNameCache->getElementNames(); - sal_Int32 nLen = sTemplateNames.getLength(); - for ( sal_Int32 index = 0; ( bSearchGlobalTemplates && index < nLen ); ++index ) - { - - if ( !sCreatedFrom.equals( sTemplateNames[ index ] ) ) - { - if ( xPrjNameCache->hasByName( sTemplateNames[ index ] ) ) - { - xPrjNameCache->getByName( sTemplateNames[ index ] ) >>= sPrj; - // Make sure we don't double up with this project - if ( !sPrj.equals( sThisProject ) ) - sSearchList.push_back( sPrj ); - } - } - - } - } - } - std::vector< rtl::OUString >::iterator it_end = sSearchList.end(); - for ( std::vector< rtl::OUString >::iterator it = sSearchList.begin(); it != it_end; ++it ) - { - bool bRes = hasMacro( pShell, *it, sModule, sProcedure ); - if ( bRes ) - { - aRes.SetResolved( true ); - aRes.SetMacroDocContext( pShell ); - sContainer = *it; - break; - } - } - } - aRes.SetResolvedMacro( sProcedure.Insert( '.', 0 ).Insert( sModule, 0).Insert( '.', 0 ).Insert( sContainer, 0 ) ); - - return aRes; -} - -// Treat the args as possible inouts ( convertion at bottom of method ) -sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Sequence< uno::Any >& aArgs, uno::Any& /*aRet*/, const uno::Any& aCaller ) -{ - sal_Bool bRes = sal_False; - if ( !pShell ) - return bRes; - rtl::OUString sUrl = makeMacroURL( sMacroName ); - - uno::Sequence< sal_Int16 > aOutArgsIndex; - uno::Sequence< uno::Any > aOutArgs; - - try - { - uno::Reference< script::provider::XScriptProvider > xScriptProvider; - uno::Reference< script::provider::XScriptProviderSupplier > xSPS( pShell->GetModel(), uno::UNO_QUERY_THROW ); - - xScriptProvider.set( xSPS->getScriptProvider(), uno::UNO_QUERY_THROW ); - - uno::Reference< script::provider::XScript > xScript( xScriptProvider->getScript( sUrl ), uno::UNO_QUERY_THROW ); - - if ( aCaller.hasValue() ) - { - uno::Reference< beans::XPropertySet > xProps( xScript, uno::UNO_QUERY ); - if ( xProps.is() ) - { - uno::Sequence< uno::Any > aCallerHack(1); - aCallerHack[ 0 ] = aCaller; - xProps->setPropertyValue( rtl::OUString::createFromAscii( "Caller" ), uno::makeAny( aCallerHack ) ); - } - } - - - xScript->invoke( aArgs, aOutArgsIndex, aOutArgs ); - - sal_Int32 nLen = aOutArgs.getLength(); - // convert any out params to seem like they were inouts - if ( nLen ) - { - for ( sal_Int32 index=0; index < nLen; ++index ) - { - sal_Int32 nOutIndex = aOutArgsIndex[ index ]; - aArgs[ nOutIndex ] = aOutArgs[ index ]; - } - } - - bRes = sal_True; - } - catch ( uno::Exception& e ) - { - bRes = sal_False; - } - return bRes; -} -} } // vba // ooo diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 7f8e563cbab6..54b635d2f08d 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -34,7 +34,7 @@ #include #include "vbacommandbars.hxx" -#include +#include // start basic includes #include diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx index e081a723db04..a4bb3adc7dbf 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx @@ -27,7 +27,7 @@ #include "vbacommandbarcontrol.hxx" #include "vbacommandbarcontrols.hxx" #include -#include +#include using namespace com::sun::star; using namespace ooo::vba; diff --git a/vbahelper/util/makefile.mk b/vbahelper/util/makefile.mk index 09f3866c5439..7af48db00aff 100644 --- a/vbahelper/util/makefile.mk +++ b/vbahelper/util/makefile.mk @@ -56,6 +56,7 @@ SHL1STDLIBS= \ $(SVLLIB) \ $(VCLLIB) \ $(SVTOOLLIB) \ + $(MSFILTERLIB) \ $(TKLIB) SHL1DEPN= -- cgit From c5fc57de562850a7d2f708e3936296d24677012d Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 15:04:15 +0000 Subject: npower14miscfixes: #i109706# move back msvbahelper to the filter module --- filter/inc/filter/msfilter/msvbahelper.hxx | 55 +++++ filter/source/msfilter/makefile.mk | 3 +- filter/source/msfilter/msvbahelper.cxx | 382 +++++++++++++++++++++++++++++ 3 files changed, 439 insertions(+), 1 deletion(-) create mode 100644 filter/inc/filter/msfilter/msvbahelper.hxx create mode 100644 filter/source/msfilter/msvbahelper.cxx diff --git a/filter/inc/filter/msfilter/msvbahelper.hxx b/filter/inc/filter/msfilter/msvbahelper.hxx new file mode 100644 index 000000000000..540097c054dc --- /dev/null +++ b/filter/inc/filter/msfilter/msvbahelper.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _MSVBAHELPER_HXX +#define _MSVBAHELPER_HXX + +#include +#include "filter/msfilter/msfilterdllapi.h" + +namespace ooo { namespace vba +{ + class MSFILTER_DLLPUBLIC VBAMacroResolvedInfo + { + SfxObjectShell* mpDocContext; + bool mbFound; + String msResolvedMacro; + public: + VBAMacroResolvedInfo() : mpDocContext(NULL), mbFound( false ){} + void SetResolved( bool bRes ) { mbFound = bRes; } + bool IsResolved() { return mbFound; } + void SetMacroDocContext(SfxObjectShell* pShell ) { mpDocContext = pShell; } + SfxObjectShell* MacroDocContext() { return mpDocContext; } + String ResolvedMacro() { return msResolvedMacro; } + void SetResolvedMacro(const String& sMacro ) { msResolvedMacro = sMacro; } + }; + + MSFILTER_DLLPUBLIC String makeMacroURL( const String& sMacroName ); + MSFILTER_DLLPUBLIC VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUString& sMod, bool bSearchGlobalTemplates = false ); + MSFILTER_DLLPUBLIC sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArgs, com::sun::star::uno::Any& aRet, const com::sun::star::uno::Any& aCaller ); +} } + +#endif diff --git a/filter/source/msfilter/makefile.mk b/filter/source/msfilter/makefile.mk index 6056213ddecf..954009185a50 100644 --- a/filter/source/msfilter/makefile.mk +++ b/filter/source/msfilter/makefile.mk @@ -51,7 +51,8 @@ SLOFILES= \ $(SLO)$/mscodec.obj \ $(SLO)$/msfiltertracer.obj \ $(SLO)$/svdfppt.obj \ - $(SLO)$/svxmsbas2.obj + $(SLO)$/svxmsbas2.obj \ + $(SLO)$/msvbahelper.obj \ SHL1TARGET= msfilter$(DLLPOSTFIX) SHL1IMPLIB= i$(TARGET) diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx new file mode 100644 index 000000000000..97529c22eae6 --- /dev/null +++ b/filter/source/msfilter/msvbahelper.cxx @@ -0,0 +1,382 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_filter.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace ::com::sun::star; + +const static rtl::OUString sUrlPart0 = rtl::OUString::createFromAscii( "vnd.sun.star.script:"); +const static rtl::OUString sUrlPart1 = rtl::OUString::createFromAscii( "?language=Basic&location=document"); + +namespace ooo { namespace vba { + +String makeMacroURL( const String& sMacroName ) +{ + return sUrlPart0.concat( sMacroName ).concat( sUrlPart1 ) ; +} + +SfxObjectShell* findShellForUrl( const rtl::OUString& sMacroURLOrPath ) +{ + SfxObjectShell* pFoundShell=NULL; + SfxObjectShell* pShell = SfxObjectShell::GetFirst(); + INetURLObject aObj; + aObj.SetURL( sMacroURLOrPath ); + bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID; + rtl::OUString aURL; + if ( bIsURL ) + aURL = sMacroURLOrPath; + else + { + osl::FileBase::getFileURLFromSystemPath( sMacroURLOrPath, aURL ); + aObj.SetURL( aURL ); + } + OSL_TRACE("Trying to find shell for url %s", rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() ); + while ( pShell ) + { + + uno::Reference< frame::XModel > xModel = pShell->GetModel(); + // are we searching for a template? if so we have to cater for the + // fact that in openoffice a document opened from a template is always + // a new document :/ + if ( xModel.is() ) + { + OSL_TRACE("shell 0x%x has model with url %s and we look for %s", pShell + , rtl::OUStringToOString( xModel->getURL(), RTL_TEXTENCODING_UTF8 ).getStr() + , rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() + ); + if ( sMacroURLOrPath.endsWithIgnoreAsciiCaseAsciiL( ".dot", 4 ) ) + { + uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( xModel, uno::UNO_QUERY ); + if( xDocInfoSupp.is() ) + { + uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); + uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); + rtl::OUString sCurrName = xDocProps->getTemplateName(); + if( sMacroURLOrPath.lastIndexOf( sCurrName ) >= 0 ) + { + pFoundShell = pShell; + break; + } + } + } + else + { + if ( aURL.equals( xModel->getURL() ) ) + { + pFoundShell = pShell; + break; + } + } + } + pShell = SfxObjectShell::GetNext( *pShell ); + } + return pFoundShell; +} + +// sMod can be empty ( but we really need the library to search in ) +// if sMod is empty and a macro is found then sMod is updated +bool hasMacro( SfxObjectShell* pShell, const String& sLibrary, String& sMod, const String& sMacro ) +{ + bool bFound = false; + if ( sLibrary.Len() && sMacro.Len() ) + { + OSL_TRACE("** Searching for %s.%s in library %s" + ,rtl::OUStringToOString( sMod, RTL_TEXTENCODING_UTF8 ).getStr() + ,rtl::OUStringToOString( sMacro, RTL_TEXTENCODING_UTF8 ).getStr() + ,rtl::OUStringToOString( sLibrary, RTL_TEXTENCODING_UTF8 ).getStr() ); + BasicManager* pBasicMgr = pShell-> GetBasicManager(); + if ( pBasicMgr ) + { + StarBASIC* pBasic = pBasicMgr->GetLib( sLibrary ); + if ( !pBasic ) + { + USHORT nId = pBasicMgr->GetLibId( sLibrary ); + pBasicMgr->LoadLib( nId ); + pBasic = pBasicMgr->GetLib( sLibrary ); + } + if ( pBasic ) + { + if ( sMod.Len() ) // we wish to find the macro is a specific module + { + SbModule* pModule = pBasic->FindModule( sMod ); + if ( pModule ) + { + SbxArray* pMethods = pModule->GetMethods(); + if ( pMethods ) + { + SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( sMacro, SbxCLASS_METHOD ) ); + if ( pMethod ) + bFound = true; + } + } + } + else if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sMacro, SbxCLASS_METHOD ) ) ) + { + if( SbModule* pModule = pMethod->GetModule() ) + { + sMod = pModule->GetName(); + bFound = true; + } + } + } + } + } + return bFound; +} +void parseMacro( const rtl::OUString& sMacro, String& sContainer, String& sModule, String& sProcedure ) +{ + sal_Int32 nMacroDot = sMacro.lastIndexOf( '.' ); + + if ( nMacroDot != -1 ) + { + sProcedure = sMacro.copy( nMacroDot + 1 ); + + sal_Int32 nContainerDot = sMacro.lastIndexOf( '.', nMacroDot - 1 ); + if ( nContainerDot != -1 ) + { + sModule = sMacro.copy( nContainerDot + 1, nMacroDot - nContainerDot - 1 ); + sContainer = sMacro.copy( 0, nContainerDot ); + } + else + sModule = sMacro.copy( 0, nMacroDot ); + } + else + sProcedure = sMacro; +} + +VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUString& MacroName, bool bSearchGlobalTemplates ) +{ + VBAMacroResolvedInfo aRes; + if ( !pShell ) + return aRes; + aRes.SetMacroDocContext( pShell ); + // parse the macro name + sal_Int32 nDocSepIndex = MacroName.indexOfAsciiL( "!", 1 ); + String sMacroUrl = MacroName; + + String sContainer; + String sModule; + String sProcedure; + + if( nDocSepIndex > 0 ) + { + // macro specified by document name + // find document shell for document name and call ourselves + // recursively + + // assume for now that the document name is *this* document + String sDocUrlOrPath = MacroName.copy( 0, nDocSepIndex ); + sMacroUrl = MacroName.copy( nDocSepIndex + 1 ); + OSL_TRACE("doc search, current shell is 0x%x", pShell ); + SfxObjectShell* pFoundShell = findShellForUrl( sDocUrlOrPath ); + OSL_TRACE("doc search, after find, found shell is 0x%x", pFoundShell ); + aRes = resolveVBAMacro( pFoundShell, sMacroUrl ); + } + else + { + // macro is contained in 'this' document ( or code imported from a template + // where that template is a global template or perhaps the template this + // document is created from ) + + // macro format = Container.Module.Procedure + parseMacro( MacroName, sContainer, sModule, sProcedure ); + uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY); + uno::Reference< container::XNameContainer > xPrjNameCache; + if ( xSF.is() ) + xPrjNameCache.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAProjectNameProvider" ) ) ), uno::UNO_QUERY ); + + std::vector< rtl::OUString > sSearchList; + + if ( sContainer.Len() > 0 ) + { + // get the Project associated with the Container + if ( xPrjNameCache.is() ) + { + if ( xPrjNameCache->hasByName( sContainer ) ) + { + rtl::OUString sProject; + xPrjNameCache->getByName( sContainer ) >>= sProject; + sContainer = sProject; + } + } + sSearchList.push_back( sContainer ); // First Lib to search + } + else + { + // Ok, if we have no Container specified then we need to search them in order, this document, template this document created from, global templates, + // get the name of Project/Library for 'this' document + rtl::OUString sThisProject; + BasicManager* pBasicMgr = pShell-> GetBasicManager(); + if ( pBasicMgr ) + { + if ( pBasicMgr->GetName().Len() ) + sThisProject = pBasicMgr->GetName(); + else // cater for the case where VBA is not enabled + sThisProject = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ); + } + sSearchList.push_back( sThisProject ); // First Lib to search + if ( xPrjNameCache.is() ) + { + // is this document created from a template? + uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( pShell->GetModel(), uno::UNO_QUERY_THROW ); + uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); + uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); + + rtl::OUString sCreatedFrom = xDocProps->getTemplateURL(); + if ( sCreatedFrom.getLength() ) + { + INetURLObject aObj; + aObj.SetURL( sCreatedFrom ); + bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID; + rtl::OUString aURL; + if ( bIsURL ) + aURL = sCreatedFrom; + else + { + osl::FileBase::getFileURLFromSystemPath( sCreatedFrom, aURL ); + aObj.SetURL( aURL ); + } + sCreatedFrom = aObj.GetLastName(); + } + + sal_Int32 nIndex = sCreatedFrom.lastIndexOf( '.' ); + if ( nIndex != -1 ) + sCreatedFrom = sCreatedFrom.copy( 0, nIndex ); + + rtl::OUString sPrj; + if ( sCreatedFrom.getLength() && xPrjNameCache->hasByName( sCreatedFrom ) ) + { + xPrjNameCache->getByName( sCreatedFrom ) >>= sPrj; + // Make sure we don't double up with this project + if ( !sPrj.equals( sThisProject ) ) + sSearchList.push_back( sPrj ); + } + + // get list of global template Names + uno::Sequence< rtl::OUString > sTemplateNames = xPrjNameCache->getElementNames(); + sal_Int32 nLen = sTemplateNames.getLength(); + for ( sal_Int32 index = 0; ( bSearchGlobalTemplates && index < nLen ); ++index ) + { + + if ( !sCreatedFrom.equals( sTemplateNames[ index ] ) ) + { + if ( xPrjNameCache->hasByName( sTemplateNames[ index ] ) ) + { + xPrjNameCache->getByName( sTemplateNames[ index ] ) >>= sPrj; + // Make sure we don't double up with this project + if ( !sPrj.equals( sThisProject ) ) + sSearchList.push_back( sPrj ); + } + } + + } + } + } + std::vector< rtl::OUString >::iterator it_end = sSearchList.end(); + for ( std::vector< rtl::OUString >::iterator it = sSearchList.begin(); it != it_end; ++it ) + { + bool bRes = hasMacro( pShell, *it, sModule, sProcedure ); + if ( bRes ) + { + aRes.SetResolved( true ); + aRes.SetMacroDocContext( pShell ); + sContainer = *it; + break; + } + } + } + aRes.SetResolvedMacro( sProcedure.Insert( '.', 0 ).Insert( sModule, 0).Insert( '.', 0 ).Insert( sContainer, 0 ) ); + + return aRes; +} + +// Treat the args as possible inouts ( convertion at bottom of method ) +sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Sequence< uno::Any >& aArgs, uno::Any& /*aRet*/, const uno::Any& aCaller ) +{ + sal_Bool bRes = sal_False; + if ( !pShell ) + return bRes; + rtl::OUString sUrl = makeMacroURL( sMacroName ); + + uno::Sequence< sal_Int16 > aOutArgsIndex; + uno::Sequence< uno::Any > aOutArgs; + + try + { + uno::Reference< script::provider::XScriptProvider > xScriptProvider; + uno::Reference< script::provider::XScriptProviderSupplier > xSPS( pShell->GetModel(), uno::UNO_QUERY_THROW ); + + xScriptProvider.set( xSPS->getScriptProvider(), uno::UNO_QUERY_THROW ); + + uno::Reference< script::provider::XScript > xScript( xScriptProvider->getScript( sUrl ), uno::UNO_QUERY_THROW ); + + if ( aCaller.hasValue() ) + { + uno::Reference< beans::XPropertySet > xProps( xScript, uno::UNO_QUERY ); + if ( xProps.is() ) + { + uno::Sequence< uno::Any > aCallerHack(1); + aCallerHack[ 0 ] = aCaller; + xProps->setPropertyValue( rtl::OUString::createFromAscii( "Caller" ), uno::makeAny( aCallerHack ) ); + } + } + + + xScript->invoke( aArgs, aOutArgsIndex, aOutArgs ); + + sal_Int32 nLen = aOutArgs.getLength(); + // convert any out params to seem like they were inouts + if ( nLen ) + { + for ( sal_Int32 index=0; index < nLen; ++index ) + { + sal_Int32 nOutIndex = aOutArgsIndex[ index ]; + aArgs[ nOutIndex ] = aOutArgs[ index ]; + } + } + + bRes = sal_True; + } + catch ( uno::Exception& e ) + { + bRes = sal_False; + } + return bRes; +} +} } // vba // ooo -- cgit From 6b5831d19fcb6eef490521badec23f460bb01958 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 16:13:21 +0000 Subject: npower13_objectmodule: #i109734# resolve macros after basic is loaded, fix error with 'Me' rtlfunc --- sc/source/filter/excel/xiescher.cxx | 6 +++--- sc/source/filter/excel/xlescher.cxx | 15 +++++++++++---- sc/source/filter/inc/xlescher.hxx | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index e963495a3f4b..adb4a5d34107 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -486,14 +486,14 @@ void XclImpDrawObjBase::ProcessSdrObject( SdrObject& rSdrObj ) const { if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) ) { - pInfo->SetMacro( XclControlHelper::GetScMacroName( maMacroName ) ); + pInfo->SetMacro( XclControlHelper::GetScMacroName( maMacroName, GetDocShell() ) ); pInfo->SetHlink( maHyperlink ); } } #else if( mbSimpleMacro && (maMacroName.Len() > 0) ) if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) ) - pInfo->SetMacro( XclControlHelper::GetScMacroName( maMacroName ) ); + pInfo->SetMacro( XclControlHelper::GetScMacroName( maMacroName, GetDocShell() ) ); #endif // call virtual function for object type specific processing @@ -1939,7 +1939,7 @@ void XclImpTbxObjBase::SetDffProperties( const DffPropSet& rDffPropSet ) bool XclImpTbxObjBase::FillMacroDescriptor( ScriptEventDescriptor& rDescriptor ) const { - return XclControlHelper::FillMacroDescriptor( rDescriptor, DoGetEventType(), GetMacroName() ); + return XclControlHelper::FillMacroDescriptor( rDescriptor, DoGetEventType(), GetMacroName(), GetDocShell() ); } void XclImpTbxObjBase::ConvertFont( ScfPropertySet& rPropSet ) const diff --git a/sc/source/filter/excel/xlescher.cxx b/sc/source/filter/excel/xlescher.cxx index 5d74346608fd..882340b4220e 100644 --- a/sc/source/filter/excel/xlescher.cxx +++ b/sc/source/filter/excel/xlescher.cxx @@ -35,6 +35,7 @@ #include "document.hxx" #include "xistream.hxx" #include "xlescher.hxx" +#include using ::rtl::OUString; using ::com::sun::star::uno::Reference; @@ -298,10 +299,16 @@ Reference< XControlModel > XclControlHelper::GetControlModel( Reference< XShape #define EXC_MACRONAME_PRE "vnd.sun.star.script:Standard." #define EXC_MACRONAME_SUF "?language=Basic&location=document" -OUString XclControlHelper::GetScMacroName( const String& rXclMacroName ) +OUString XclControlHelper::GetScMacroName( const String& rXclMacroName, SfxObjectShell* pDocShell ) { + String sTmp( rXclMacroName ); if( rXclMacroName.Len() > 0 ) - return CREATE_OUSTRING( EXC_MACRONAME_PRE ) + rXclMacroName + CREATE_OUSTRING( EXC_MACRONAME_SUF ); + { + ooo::vba::VBAMacroResolvedInfo aMacro = ooo::vba::resolveVBAMacro( pDocShell, rXclMacroName, false ); + if ( aMacro.IsResolved() ) + return ooo::vba::makeMacroURL( aMacro.ResolvedMacro() ); + + } return OUString(); } @@ -335,14 +342,14 @@ spTbxListenerData[] = #define EXC_MACROSCRIPT "Script" bool XclControlHelper::FillMacroDescriptor( ScriptEventDescriptor& rDescriptor, - XclTbxEventType eEventType, const String& rXclMacroName ) + XclTbxEventType eEventType, const String& rXclMacroName, SfxObjectShell* pShell ) { if( rXclMacroName.Len() > 0 ) { rDescriptor.ListenerType = OUString::createFromAscii( spTbxListenerData[ eEventType ].mpcListenerType ); rDescriptor.EventMethod = OUString::createFromAscii( spTbxListenerData[ eEventType ].mpcEventMethod ); rDescriptor.ScriptType = CREATE_OUSTRING( EXC_MACROSCRIPT ); - rDescriptor.ScriptCode = GetScMacroName( rXclMacroName ); + rDescriptor.ScriptCode = GetScMacroName( rXclMacroName, pShell ); return true; } return false; diff --git a/sc/source/filter/inc/xlescher.hxx b/sc/source/filter/inc/xlescher.hxx index f60d6d3a5ee5..698faa966fd3 100644 --- a/sc/source/filter/inc/xlescher.hxx +++ b/sc/source/filter/inc/xlescher.hxx @@ -429,7 +429,7 @@ public: GetControlModel( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); /** Returns the Calc macro name from an Excel macro name. */ - static ::rtl::OUString GetScMacroName( const String& rXclMacroName ); + static ::rtl::OUString GetScMacroName( const String& rXclMacroName, SfxObjectShell* pShell = NULL ); /** Returns the Excel macro name from a Calc macro name. */ static String GetXclMacroName( const ::rtl::OUString& rScMacroName ); @@ -437,7 +437,7 @@ public: static bool FillMacroDescriptor( ::com::sun::star::script::ScriptEventDescriptor& rDescriptor, XclTbxEventType eEventType, - const String& rXclMacroName ); + const String& rXclMacroName, SfxObjectShell* pShell = NULL ); /** Tries to extract an Excel macro name from the passed macro descriptor. */ static String ExtractFromMacroDescriptor( const ::com::sun::star::script::ScriptEventDescriptor& rDescriptor, -- cgit From c0ae58c88aa461c9c26cddb89b071151b2d41361 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 16:13:21 +0000 Subject: npower13_objectmodule: #i109734# resolve macros after basic is loaded, fix error with 'Me' rtlfunc --- basic/source/runtime/methods1.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index 3a234b78e1df..dbdeee8197c2 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -2598,7 +2598,6 @@ RTLFUNC(Me) SbxVariableRef refVar = rPar.Get(0); if( pClassModuleObject == NULL ) { - StarBASIC::Error( SbERR_INVALID_USAGE_OBJECT ); SbObjModule* pMod = PTR_CAST(SbObjModule,pActiveModule); if ( pMod ) refVar->PutObject( pMod ); -- cgit From b4cfc7121b263041c586fe3c3ed894f3a5494e7c Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 3 Mar 2010 12:59:39 +0000 Subject: npower13_objectmodule: tweak IDE to only run macros from cursor in VBA mode --- basctl/source/basicide/baside2.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index bed5aa96dc28..4f31af11be6f 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -336,7 +336,8 @@ BOOL ModulWindow::BasicExecute() AddStatus( BASWIN_RUNNINGBASIC ); USHORT nStart, nEnd, nCurMethodStart = 0; TextSelection aSel = GetEditView()->GetSelection(); - nCurMethodStart = ( aSel.GetStart().GetPara() + 1 ); + if ( aDocument.isInVBAMode() ) + nCurMethodStart = ( aSel.GetStart().GetPara() + 1 ); SbMethod* pMethod = 0; // erstes Macro, sonst blind "Main" (ExtSearch?) for ( USHORT nMacro = 0; nMacro < xModule->GetMethods()->Count(); nMacro++ ) @@ -344,16 +345,20 @@ BOOL ModulWindow::BasicExecute() SbMethod* pM = (SbMethod*)xModule->GetMethods()->Get( nMacro ); DBG_ASSERT( pM, "Method?" ); pM->GetLineRange( nStart, nEnd ); - if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd ) + if ( ( aDocument.isInVBAMode() && ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd ) ) || ( !aDocument.isInVBAMode() && !pMethod ) ) { pMethod = pM; break; } } if ( !pMethod ) - return ( BasicIDE::ChooseMacro( uno::Reference< frame::XModel >(), FALSE, rtl::OUString() ).getLength() > 0 ) ? TRUE : FALSE; - - else + { + if ( aDocument.isInVBAMode() ) + return ( BasicIDE::ChooseMacro( uno::Reference< frame::XModel >(), FALSE, rtl::OUString() ).getLength() > 0 ) ? TRUE : FALSE; + else + pMethod = (SbMethod*)xModule->Find( String( RTL_CONSTASCII_USTRINGPARAM( "Main" ) ), SbxCLASS_METHOD ); + } + if ( pMethod ) { pMethod->SetDebugFlags( aStatus.nBasicFlags ); BasicDLL::SetDebugMode( TRUE ); -- cgit From b38c23a63a189072a6275bb791fcfa55edfdc2fd Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 3 Mar 2010 16:12:54 +0000 Subject: npower13_objectmodule: clean up IDE changes --- basctl/source/basicide/baside3.cxx | 11 +---- basctl/source/basicide/basides1.cxx | 10 +---- basctl/source/basicide/basides2.cxx | 19 ++++----- basctl/source/basicide/basidesh.cxx | 14 +++++-- basctl/source/basicide/bastype2.cxx | 69 +++++++++++++++---------------- basctl/source/basicide/scriptdocument.cxx | 2 - basctl/source/dlged/dlged.cxx | 3 +- basctl/source/dlged/dlgedobj.cxx | 40 +++++------------- basctl/source/inc/dlged.hxx | 5 +-- 9 files changed, 66 insertions(+), 107 deletions(-) diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index c5628451ac8f..f4a3c1d48fc7 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -82,7 +82,6 @@ #include #include #include -#include using namespace comphelper; using namespace ::com::sun::star; @@ -113,16 +112,8 @@ DialogWindow::DialogWindow( Window* pParent, const ScriptDocument& rDocument, St { InitSettings( TRUE, TRUE, TRUE ); - pEditor = new DlgEditor( rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); + pEditor = new DlgEditor(); pEditor->SetWindow( this ); - // set vba mode on DialogModel ( allows it to work in 100thmm instead of MAP_APPFONT ) - if ( rDocument.isDocument() && rDocument.getDocument().is() ) - { - uno::Reference< script::XVBACompat > xDocVBAMode( rDocument.getLibraryContainer( E_SCRIPTS ), uno::UNO_QUERY ); - uno::Reference< script::XVBACompat > xDialogModelVBAMode( xDialogModel, uno::UNO_QUERY ); - if ( xDocVBAMode.is() && xDialogModelVBAMode.is() ) - xDialogModelVBAMode->setVBACompatModeOn( xDocVBAMode->getVBACompatModeOn() ); - } pEditor->SetDialog( xDialogModel ); // Undo einrichten diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index ded495d416be..31391297f564 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -1198,18 +1198,10 @@ IDEBaseWindow* BasicIDEShell::FindWindow( const ScriptDocument& rDocument, const // return any non-suspended window return pWin; } - else if ( pWin->IsDocument( rDocument ) ) - { - OSL_TRACE("FindWindow pWin->GetLibName() %s rLibName %s", - rtl::OUStringToOString( pWin->GetLibName(), RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( rLibName, RTL_TEXTENCODING_UTF8 ).getStr() ); - OSL_TRACE("pWin->pWin->IsA( TYPE( ModulWindow ) %d && nType %d = BASICIDE_TYPE_MODULE %d", pWin->IsA( TYPE( ModulWindow ) ), nType, BASICIDE_TYPE_MODULE ); - OSL_TRACE("pWin->pWin->IsA( TYPE( DialogWindow ) %d && nType %d = BASICIDE_TYPE_DIALOG %d", pWin->IsA( TYPE( DialogWindow ) ), nType, BASICIDE_TYPE_DIALOG ); - if ( pWin->GetLibName() == rLibName && pWin->GetName() == rName && + else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rName && ( ( pWin->IsA( TYPE( ModulWindow ) ) && nType == BASICIDE_TYPE_MODULE ) || ( pWin->IsA( TYPE( DialogWindow ) ) && nType == BASICIDE_TYPE_DIALOG ) ) ) return pWin; - } } pWin = aIDEWindowTable.Next(); } diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index 8da483e209d4..c6f6a77a9446 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -301,21 +301,18 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const } DBG_ASSERT( nKey, "CreateBasWin: Kein Key- Fenster nicht gefunden!" ); } - if( nKey ) + if( nKey && xLib.is() && rDocument.isInVBAMode() ) { - if( xLib.is() ) + // display a nice friendly name in the ObjectModule tab, + // combining the objectname and module name, e.g. Sheet1 ( Financials ) + String sObjName; + lcl_getObjectName( xLib, rModName, sObjName ); + if( sObjName.Len() ) { - // display a nice friendly name in the ObjectModule tab, - // combining the objectname and module name, e.g. Sheet1 ( Financials ) - String sObjName; - lcl_getObjectName( xLib, rModName, sObjName ); - if( sObjName.Len() ) - { - aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")"); - } + aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")"); } - pTabBar->InsertPage( (USHORT)nKey, aModName ); } + pTabBar->InsertPage( (USHORT)nKey, aModName ); pTabBar->Sort(); pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar ); if ( !pCurWin ) diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index 9e698af58917..608cc51c1ff3 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -1008,17 +1008,23 @@ void BasicIDEShell::SetCurLib( const ScriptDocument& rDocument, String aLibName, { ContainerListenerImpl* pListener = NULL; - if ( rDocument.isInVBAMode() ) - pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() ); + pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() ); if ( pListener ) pListener->removeContainerListener( m_aCurDocument, m_aCurLibName ); m_aCurDocument = rDocument; - if ( pListener ) - pListener->addContainerListener( m_aCurDocument, aLibName ); + if ( m_aCurDocument.isInVBAMode() ) + { + if ( !pListener ) + { + pListener = new ContainerListenerImpl( this ); + m_xLibListener = pListener; + } + pListener->addContainerListener( m_aCurDocument, aLibName ); + } m_aCurLibName = aLibName; if ( bUpdateWindows ) UpdateWindows(); diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index bf13b554a0a6..6009ad9f2385 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -307,51 +307,50 @@ void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const { try { - sal_Bool bVBAEnabled = rDocument.isInVBAMode(); - if( bVBAEnabled ) + if( rDocument.isInVBAMode() ) ImpCreateLibSubEntriesInVBAMode( pLibRootEntry, rDocument, rLibName ); else { - // get a sorted list of module names - Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName ); - sal_Int32 nModCount = aModNames.getLength(); - const ::rtl::OUString* pModNames = aModNames.getConstArray(); + // get a sorted list of module names + Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName ); + sal_Int32 nModCount = aModNames.getLength(); + const ::rtl::OUString* pModNames = aModNames.getConstArray(); - for ( sal_Int32 i = 0 ; i < nModCount ; i++ ) - { - String aModName = pModNames[ i ]; - SvLBoxEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJ_TYPE_MODULE ); - if ( !pModuleEntry ) - pModuleEntry = AddEntry( - aModName, - Image( IDEResId( RID_IMG_MODULE ) ), - Image( IDEResId( RID_IMG_MODULE_HC ) ), - pLibRootEntry, false, - std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) ); - - // methods - if ( nMode & BROWSEMODE_SUBS ) + for ( sal_Int32 i = 0 ; i < nModCount ; i++ ) { - Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName ); - sal_Int32 nCount = aNames.getLength(); - const ::rtl::OUString* pNames = aNames.getConstArray(); - - for ( sal_Int32 j = 0 ; j < nCount ; j++ ) + String aModName = pModNames[ i ]; + SvLBoxEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJ_TYPE_MODULE ); + if ( !pModuleEntry ) + pModuleEntry = AddEntry( + aModName, + Image( IDEResId( RID_IMG_MODULE ) ), + Image( IDEResId( RID_IMG_MODULE_HC ) ), + pLibRootEntry, false, + std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) ); + + // methods + if ( nMode & BROWSEMODE_SUBS ) { - String aName = pNames[ j ]; - SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD ); - if ( !pEntry ) - pEntry = AddEntry( - aName, - Image( IDEResId( RID_IMG_MACRO ) ), - Image( IDEResId( RID_IMG_MACRO_HC ) ), - pModuleEntry, false, - std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) ); + Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName ); + sal_Int32 nCount = aNames.getLength(); + const ::rtl::OUString* pNames = aNames.getConstArray(); + + for ( sal_Int32 j = 0 ; j < nCount ; j++ ) + { + String aName = pNames[ j ]; + SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD ); + if ( !pEntry ) + pEntry = AddEntry( + aName, + Image( IDEResId( RID_IMG_MACRO ) ), + Image( IDEResId( RID_IMG_MACRO_HC ) ), + pModuleEntry, false, + std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) ); + } } } } } - } catch ( const container::NoSuchElementException& ) { DBG_UNHANDLED_EXCEPTION(); diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index f246e1613dd8..edb04f352855 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -480,8 +480,6 @@ namespace basctl { OSL_ENSURE( isValid(), "ScriptDocument_Impl::getDocument: invalid state!" ); OSL_ENSURE( isDocument(), "ScriptDocument_Impl::getDocument: for documents only!" ); - if ( !isDocument() ) - OSL_TRACE("**** BAHHHH!!!*****"); if ( !isValid() || !isDocument() ) return NULL; diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 65059f3b759b..326098976d87 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -205,7 +205,7 @@ BOOL DlgEditor::RemarkDialog() //---------------------------------------------------------------------------- -DlgEditor::DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ) +DlgEditor::DlgEditor() :pHScroll(NULL) ,pVScroll(NULL) ,pDlgEdModel(NULL) @@ -227,7 +227,6 @@ DlgEditor::DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star:: ,bCreateOK(TRUE) ,bDialogModelChanged(FALSE) ,mnPaintGuard(0) - ,m_xDocument( xModel ) { pDlgEdModel = new DlgEdModel(); pDlgEdModel->GetItemPool().FreezeIdRanges(); diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index fcade49d1c8b..5af7519f85f0 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -74,22 +74,6 @@ TYPEINIT1(DlgEdObj, SdrUnoObj); DBG_NAME(DlgEdObj); //---------------------------------------------------------------------------- -MapMode lcl_getMapModeForForm( DlgEdForm* pForm ) -{ - MapMode aMode( MAP_APPFONT ); //Default - try - { - uno::Reference< beans::XPropertySet > xProps( pForm ? pForm->GetUnoControlModel() : NULL, uno::UNO_QUERY_THROW ); - sal_Bool bVBAForm = sal_False; - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VBAForm") ) ) >>= bVBAForm; - if ( bVBAForm ) - aMode = MapMode( MAP_100TH_MM ); - } - catch ( Exception& ) - { - } - return aMode; -} DlgEdObj::DlgEdObj() :SdrUnoObj(String(), sal_False) @@ -210,9 +194,8 @@ bool DlgEdObj::TransformSdrToControlCoordinates( } // convert pixel to logic units - MapMode aConvMode = lcl_getMapModeForForm( pForm ); - aPos = pDevice->PixelToLogic( aPos, aConvMode ); - aSize = pDevice->PixelToLogic( aSize, aConvMode ); + aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_APPFONT ) ); + aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_APPFONT ) ); // set out parameters nXOut = aPos.Width(); @@ -259,10 +242,10 @@ bool DlgEdObj::TransformSdrToFormCoordinates( aSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset; aSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset; } - MapMode aConvMode = lcl_getMapModeForForm( pForm ); + // convert pixel to logic units - aPos = pDevice->PixelToLogic( aPos, aConvMode ); - aSize = pDevice->PixelToLogic( aSize, aConvMode ); + aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_APPFONT ) ); + aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_APPFONT ) ); // set out parameters nXOut = aPos.Width(); @@ -304,10 +287,9 @@ bool DlgEdObj::TransformControlToSdrCoordinates( DBG_ASSERT( pDevice, "DlgEdObj::TransformControlToSdrCoordinates: missing default device!" ); if ( !pDevice ) return false; - MapMode aConvMode = lcl_getMapModeForForm( pForm ); - aPos = pDevice->LogicToPixel( aPos, aConvMode ); - aSize = pDevice->LogicToPixel( aSize, aConvMode ); - aFormPos = pDevice->LogicToPixel( aFormPos, aConvMode ); + aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_APPFONT ) ); + aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_APPFONT ) ); + aFormPos = pDevice->LogicToPixel( aFormPos, MapMode( MAP_APPFONT ) ); // add form position aPos.Width() += aFormPos.Width(); @@ -351,16 +333,14 @@ bool DlgEdObj::TransformFormToSdrCoordinates( DBG_ASSERT( pDevice, "DlgEdObj::TransformFormToSdrCoordinates: missing default device!" ); if ( !pDevice ) return false; + aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_APPFONT ) ); + aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_APPFONT ) ); // take window borders into account DlgEdForm* pForm = NULL; if ( !lcl_getDlgEdForm( this, pForm ) ) return false; - MapMode aConvMode = lcl_getMapModeForForm( pForm ); - aPos = pDevice->LogicToPixel( aPos, aConvMode ); - aSize = pDevice->LogicToPixel( aSize, aConvMode ); - // take window borders into account Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY ); DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" ); diff --git a/basctl/source/inc/dlged.hxx b/basctl/source/inc/dlged.hxx index f49d684cbe80..1444bab59c65 100644 --- a/basctl/source/inc/dlged.hxx +++ b/basctl/source/inc/dlged.hxx @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -129,11 +128,9 @@ protected: BOOL bDialogModelChanged; Timer aMarkTimer; long mnPaintGuard; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocument; - DlgEditor(); // not implemented public: - DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ); + DlgEditor(); ~DlgEditor(); void SetWindow( Window* pWindow ); -- cgit From 92226d16f811d29618f505fffae3051710c1eadf Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 3 Mar 2010 16:17:49 +0000 Subject: npower13_objectmodule: disable IDE changes --- basctl/source/basicide/scriptdocument.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index edb04f352855..6d175674a63d 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -453,12 +453,14 @@ namespace basctl bool ScriptDocument_Impl::isInVBAMode() const { bool bResult = false; +#ifdef FUTURE_VBA_CWS if ( !isApplication() ) { Reference< XVBACompat > xVBACompat( getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); if ( xVBACompat.is() ) bResult = xVBACompat->getVBACompatModeOn(); } +#endif return bResult; } -- cgit From 3227fc50dc89c295f31bdca8eead66798058c915 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 3 Mar 2010 16:47:55 +0000 Subject: npower13_objectmodule: some cleanup --- sc/source/ui/docshell/docsh5.cxx | 61 +++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 06d7cab0d14d..763febfb9def 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -877,39 +877,36 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec new ScUndoCopyTab( this, aSrcList, aDestList ) ); } - StarBASIC* pStarBASIC = GetBasic(); - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - if ( GetBasicManager()->GetName().Len() > 0 ) - { - aLibName = GetBasicManager()->GetName(); - pStarBASIC = GetBasicManager()->GetLib( aLibName ); - } BOOL bVbaEnabled = aDocument.IsInVBAMode(); - SCTAB nTabToUse = nDestTab; - - if ( nDestTab == SC_TAB_APPEND ) - nTabToUse = aDocument.GetMaxTableNumber() - 1; - - if ( bVbaEnabled ) - { - String sCodeName; - String sSource; - com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = GetBasicContainer(); - com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; - if( xLibContainer.is() ) - { - com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); - aLibAny >>= xLib; - } - if( xLib.is() ) - { - rtl::OUString sRTLSource; - xLib->getByName( sSrcCodeName ) >>= sRTLSource; - sSource = sRTLSource; - } - VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); - } - } + if ( bVbaEnabled ) + { + StarBASIC* pStarBASIC = GetBasic(); + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( GetBasicManager()->GetName().Len() > 0 ) + { + aLibName = GetBasicManager()->GetName(); + pStarBASIC = GetBasicManager()->GetLib( aLibName ); + } + SCTAB nTabToUse = nDestTab; + if ( nDestTab == SC_TAB_APPEND ) + nTabToUse = aDocument.GetMaxTableNumber() - 1; + String sCodeName; + String sSource; + com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = GetBasicContainer(); + com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + if( xLib.is() ) + { + rtl::OUString sRTLSource; + xLib->getByName( sSrcCodeName ) >>= sRTLSource; + sSource = sRTLSource; + } + VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); + } Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) ); } -- cgit From 5463a4524594257bbbec5d953d97ab668310493e Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 3 Mar 2010 16:47:55 +0000 Subject: npower13_objectmodule: some cleanup --- vbahelper/source/vbahelper/vbaglobalbase.cxx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/vbahelper/source/vbahelper/vbaglobalbase.cxx b/vbahelper/source/vbahelper/vbaglobalbase.cxx index 2bb9d2f4a7ad..c7c33b93b1a3 100644 --- a/vbahelper/source/vbahelper/vbaglobalbase.cxx +++ b/vbahelper/source/vbahelper/vbaglobalbase.cxx @@ -85,14 +85,8 @@ VbaGlobalsBase::createInstanceWithArguments( const ::rtl::OUString& ServiceSpeci { uno::Reference< uno::XInterface > xReturn; - OSL_TRACE("VbaGlobalsBase::createInstanceWithArguments(%s)", rtl::OUStringToOString( ServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); if ( hasServiceName( ServiceSpecifier ) ) - { - OSL_TRACE("VbaGlobalsBase::hasServiceName(%s) - true", rtl::OUStringToOString( ServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); xReturn = mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( ServiceSpecifier, Arguments, mxContext ); - } - else - OSL_TRACE("VbaGlobalsBase::hasServiceName(%s) - false", rtl::OUStringToOString( ServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); return xReturn; } -- cgit From e8a31aab0a174873306d78df361c3646c7e4215d Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 3 Mar 2010 18:23:05 +0000 Subject: npower13_objectmodule: #i109734# re-instate listening for module creation/delete ( useful generally I think ) --- basctl/source/basicide/basidesh.cxx | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index 608cc51c1ff3..036127e1c844 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -1006,26 +1006,17 @@ void BasicIDEShell::SetCurLib( const ScriptDocument& rDocument, String aLibName, { if ( !bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName ) ) { - ContainerListenerImpl* pListener = NULL; - - pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() ); + ContainerListenerImpl* pListener = pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() ); if ( pListener ) pListener->removeContainerListener( m_aCurDocument, m_aCurLibName ); m_aCurDocument = rDocument; - if ( m_aCurDocument.isInVBAMode() ) - { - if ( !pListener ) - { + pListener->addContainerListener( m_aCurDocument, aLibName ); - pListener = new ContainerListenerImpl( this ); - m_xLibListener = pListener; - } - pListener->addContainerListener( m_aCurDocument, aLibName ); - } m_aCurLibName = aLibName; + if ( bUpdateWindows ) UpdateWindows(); -- cgit From 7580076aad41973fe754d6543aa97f9405a9d5ce Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 3 Mar 2010 18:36:44 +0000 Subject: npower13_objectmodule: #i109734# smooth out logic for tab copy ( and associated creation of new basic module ) --- sc/source/core/data/documen2.cxx | 55 +++++++++++++++++++++------------------- sc/source/ui/docshell/docsh5.cxx | 2 +- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index ce3bf4df3490..138b55f0794c 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1107,38 +1107,41 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, } if (!bValid) nRetVal = 0; - SfxObjectShell* pDestShell = pSrcDoc ? pSrcDoc->GetDocumentShell() : NULL; - StarBASIC* pStarBASIC = pDestShell ? pDestShell->GetBasic() : NULL; - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - if ( pDestShell && pDestShell->GetBasicManager()->GetName().Len() > 0 ) - { - aLibName = pDestShell->GetBasicManager()->GetName(); - pStarBASIC = pDestShell->GetBasicManager()->GetLib( aLibName ); - } - BOOL bVbaEnabled = IsInVBAMode(); - if ( bVbaEnabled && pDestShell ) + if ( bVbaEnabled ) { - String sCodeName; - String sSource; - com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = pDestShell->GetBasicContainer(); - com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; - if( xLibContainer.is() ) + SfxObjectShell* pSrcShell = pSrcDoc ? pSrcDoc->GetDocumentShell() : NULL; + if ( pSrcShell ) { - com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); - aLibAny >>= xLib; - } + StarBASIC* pStarBASIC = pSrcShell ? pSrcShell->GetBasic() : NULL; + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( pSrcShell && pSrcShell->GetBasicManager()->GetName().Len() > 0 ) + { + aLibName = pSrcShell->GetBasicManager()->GetName(); + pStarBASIC = pSrcShell->GetBasicManager()->GetLib( aLibName ); + } - if( xLib.is() ) - { - String sSrcCodeName; - pSrcDoc->GetCodeName( nSrcPos, sSrcCodeName ); - rtl::OUString sRTLSource; - xLib->getByName( sSrcCodeName ) >>= sRTLSource; - sSource = sRTLSource; + String sCodeName; + String sSource; + com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = pSrcShell->GetBasicContainer(); + com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + + if( xLib.is() ) + { + String sSrcCodeName; + pSrcDoc->GetCodeName( nSrcPos, sSrcCodeName ); + rtl::OUString sRTLSource; + xLib->getByName( sSrcCodeName ) >>= sRTLSource; + sSource = sRTLSource; + } + VBA_InsertModule( *this, nDestPos, sCodeName, sSource ); } - VBA_InsertModule( *this, nDestPos, sCodeName, sSource ); } return nRetVal; diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 763febfb9def..02d4a523f7e2 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -907,7 +907,7 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec } VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); } - + } Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) ); } else -- cgit From 7fc422304638160f35fae67a02c0c07307ec6012 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 3 Mar 2010 19:59:09 +0000 Subject: npower13_objectmodule: #i109734# fix a couple of problems, a) introduce lazy init of xModule for ModuleWindow ( needed because we get the module added before basic is updated ), b) fix compile warning, c) make sure elementRemoved really does try to remove the ModuleWindow --- basctl/source/basicide/baside2.cxx | 64 ++++++++++++++++++++++--------------- basctl/source/basicide/baside2.hxx | 1 + basctl/source/basicide/basidesh.cxx | 4 +-- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 4f31af11be6f..c71ddeed788c 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -205,21 +205,27 @@ ModulWindow::ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDoc pLayout = pParent; aXEditorWindow.Show(); - BasicManager* pBasMgr = rDocument.getBasicManager(); - if ( pBasMgr ) + SetBackground(); +} + +SbModuleRef ModulWindow::XModule() +{ + if ( !xModule.Is() ) { - StarBASIC* pBasic = pBasMgr->GetLib( aLibName ); - if ( pBasic ) + BasicManager* pBasMgr = GetDocument().getBasicManager(); + if ( pBasMgr ) { - xBasic = pBasic; - xModule = (SbModule*)pBasic->FindModule( aName ); + StarBASIC* pBasic = pBasMgr->GetLib( GetLibName() ); + if ( pBasic ) + { + xBasic = pBasic; + xModule = (SbModule*)pBasic->FindModule( GetName() ); + } } } - - SetBackground(); + return xModule; } - __EXPORT ModulWindow::~ModulWindow() { DBG_DTOR( ModulWindow, 0 ); @@ -269,7 +275,7 @@ void ModulWindow::CheckCompileBasic() { DBG_CHKTHIS( ModulWindow, 0 ); - if ( xModule.Is() ) + if ( XModule().Is() ) { // Zur Laufzeit wird niemals compiliert! BOOL bRunning = StarBASIC::IsRunning(); @@ -325,7 +331,7 @@ BOOL ModulWindow::BasicExecute() CheckCompileBasic(); - if ( xModule.Is() && xModule->IsCompiled() && !aStatus.bError ) + if ( XModule().Is() && xModule->IsCompiled() && !aStatus.bError ) { if ( GetBreakPoints().Count() ) aStatus.nBasicFlags = aStatus.nBasicFlags | SbDEBUG_BREAK; @@ -345,10 +351,18 @@ BOOL ModulWindow::BasicExecute() SbMethod* pM = (SbMethod*)xModule->GetMethods()->Get( nMacro ); DBG_ASSERT( pM, "Method?" ); pM->GetLineRange( nStart, nEnd ); - if ( ( aDocument.isInVBAMode() && ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd ) ) || ( !aDocument.isInVBAMode() && !pMethod ) ) + if ( aDocument.isInVBAMode() ) + { + if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd ) + { + pMethod = pM; + break; + } + } + else if ( !pMethod || ( nStart < nCurMethodStart ) ) { pMethod = pM; - break; + nCurMethodStart = nStart; } } if ( !pMethod ) @@ -384,7 +398,7 @@ BOOL ModulWindow::CompileBasic() CheckCompileBasic(); BOOL bIsCompiled = FALSE; - if ( xModule.Is() ) + if ( XModule().Is() ) bIsCompiled = xModule->IsCompiled(); return bIsCompiled; @@ -561,11 +575,11 @@ BOOL ModulWindow::ImportDialog() BOOL ModulWindow::ToggleBreakPoint( ULONG nLine ) { - DBG_ASSERT( xModule.Is(), "Kein Modul!" ); + DBG_ASSERT( XModule().Is(), "Kein Modul!" ); BOOL bNewBreakPoint = FALSE; - if ( xModule.Is() ) + if ( XModule().Is() ) { CheckCompileBasic(); if ( aStatus.bError ) @@ -607,9 +621,9 @@ BOOL ModulWindow::ToggleBreakPoint( ULONG nLine ) void ModulWindow::UpdateBreakPoint( const BreakPoint& rBrk ) { - DBG_ASSERT( xModule.Is(), "Kein Modul!" ); + DBG_ASSERT( XModule().Is(), "Kein Modul!" ); - if ( xModule.Is() ) + if ( XModule().Is() ) { CheckCompileBasic(); @@ -833,9 +847,9 @@ void ModulWindow::BasicRemoveWatch() void ModulWindow::EditMacro( const String& rMacroName ) { DBG_CHKTHIS( ModulWindow, 0 ); - DBG_ASSERT( xModule.Is(), "Kein Modul!" ); + DBG_ASSERT( XModule().Is(), "Kein Modul!" ); - if ( xModule.Is() ) + if ( XModule().Is() ) { CheckCompileBasic(); @@ -905,12 +919,12 @@ BOOL __EXPORT ModulWindow::AllowUndo() void __EXPORT ModulWindow::UpdateData() { DBG_CHKTHIS( ModulWindow, 0 ); - DBG_ASSERT( xModule.Is(), "Kein Modul!" ); + DBG_ASSERT( XModule().Is(), "Kein Modul!" ); // UpdateData wird gerufen, wenn sich der Source von aussen // geaendert hat. // => Keine Unterbrechungen erwuenscht! - if ( xModule.Is() ) + if ( XModule().Is() ) { SetModule( xModule->GetSource32() ); @@ -1231,7 +1245,7 @@ void __EXPORT ModulWindow::GoOnTop() String ModulWindow::GetSbModuleName() { String aModuleName; - if ( xModule.Is() ) + if ( XModule().Is() ) aModuleName = xModule->GetName(); return aModuleName; } @@ -1353,7 +1367,7 @@ USHORT __EXPORT ModulWindow::GetSearchOptions() void __EXPORT ModulWindow::BasicStarted() { - if ( xModule.Is() ) + if ( XModule().Is() ) { aStatus.bIsRunning = TRUE; BreakPointList& rList = GetBreakPoints(); @@ -1384,7 +1398,7 @@ BasicEntryDescriptor ModulWindow::CreateEntryDescriptor() LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName ); String aModName( GetName() ); String aLibSubName; - if( xBasic.Is() && aDocument.isInVBAMode() && xModule.Is() ) + if( xBasic.Is() && aDocument.isInVBAMode() && XModule().Is() ) { switch( xModule->GetModuleType() ) { diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 6d35f0a027a8..0bcf4a87476b 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -357,6 +357,7 @@ private: void AssertValidEditEngine(); sal_Int32 FormatAndPrint( Printer* pPrinter, sal_Int32 nPage = -1 ); + SbModuleRef XModule(); protected: virtual void Resize(); virtual void GetFocus(); diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index 036127e1c844..9a5204ff36cf 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -147,7 +147,7 @@ public: { IDEBaseWindow* pWin = mpShell->FindWindow( mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, BASICIDE_TYPE_MODULE, TRUE ); if( pWin ) - mpShell->RemoveWindow( pWin, FALSE, TRUE ); + mpShell->RemoveWindow( pWin, TRUE, TRUE ); } } @@ -1006,7 +1006,7 @@ void BasicIDEShell::SetCurLib( const ScriptDocument& rDocument, String aLibName, { if ( !bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName ) ) { - ContainerListenerImpl* pListener = pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() ); + ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() ); if ( pListener ) pListener->removeContainerListener( m_aCurDocument, m_aCurLibName ); -- cgit From ce38eff222baa68d1eb31c4e72da381453d9fd0f Mon Sep 17 00:00:00 2001 From: npower Developer Date: Fri, 5 Mar 2010 20:14:25 +0000 Subject: npower13_objectmodule: wae fixes --- basic/source/classes/sbxmod.cxx | 7 +++---- basic/source/uno/namecont.cxx | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index fceda108bbd8..622083bd58cc 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1561,10 +1561,9 @@ class FormObjEventListenerImpl : public EventListener_BASE public: FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent ) : mpUserForm( pUserForm ), mxComponent( xComponent) , mbDisposed( false ), mbOpened( sal_False ), mbActivated( sal_False ), mbShowing( sal_False ) { - if ( mxComponent.is() ); + if ( mxComponent.is() ) { uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; - //uno::Reference< awt::XWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; OSL_TRACE("*********** Registering the listener"); xList->addTopWindowListener( this ); } @@ -1604,7 +1603,7 @@ public: } //liuchen 2009-7-21, support Excel VBA Form_QueryClose event - virtual void SAL_CALL windowClosing( const lang::EventObject& e ) throw (uno::RuntimeException) + virtual void SAL_CALL windowClosing( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { #if IN_THE_FUTURE uno::Reference< awt::XDialog > xDialog( e.Source, uno::UNO_QUERY ); @@ -1694,7 +1693,7 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun ) Sequence< Any > aArguments; triggerMethod( aMethodToRun, aArguments ); } -void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& aArguments) +void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& /*aArguments*/) { OSL_TRACE("*** trigger %s ***", rtl::OUStringToOString( aMethodToRun, RTL_TEXTENCODING_UTF8 ).getStr() ); // Search method diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index 05134620f173..7b1839089bf9 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -326,12 +326,13 @@ DBG_NAME( SfxLibraryContainer ) // Ctor SfxLibraryContainer::SfxLibraryContainer( void ) : LibraryContainerHelper( maMutex ) + , mbVBACompat( sal_False ) , maModifiable( *this, maMutex ) , maNameContainer( getCppuType( (Reference< XNameAccess >*) NULL ) ) , mbOldInfoFormat( sal_False ) , mbOasis2OOoFormat( sal_False ) , mpBasMgr( NULL ) - , mbOwnBasMgr( sal_False ), mbVBACompat( sal_False ) + , mbOwnBasMgr( sal_False ) { DBG_CTOR( SfxLibraryContainer, NULL ); -- cgit From e19003d128d4bc415e88a8c83c2665abb90b079b Mon Sep 17 00:00:00 2001 From: npower Developer Date: Fri, 5 Mar 2010 20:14:25 +0000 Subject: npower13_objectmodule: wae fixes --- filter/source/msfilter/svxmsbas.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/filter/source/msfilter/svxmsbas.cxx b/filter/source/msfilter/svxmsbas.cxx index 0b42fe7e4843..3b32b951c16a 100644 --- a/filter/source/msfilter/svxmsbas.cxx +++ b/filter/source/msfilter/svxmsbas.cxx @@ -356,7 +356,6 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, DBG_ERRORFILE( "SvxImportMSVBasic::ImportCode_Impl - unknown module type" ); break; } - static ::rtl::OUString sVBAOption( RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ); static ::rtl::OUString sClassOption( RTL_CONSTASCII_USTRINGPARAM( "Option ClassModule\n" ) ); if ( !bAsComment ) { -- cgit From 9f499571a0c9956800be594af064e3ae7832f2ac Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 8 Mar 2010 23:24:53 +0000 Subject: npower13objectmodules: clean build breaks vbahelper/filter --- vbahelper/prj/build.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vbahelper/prj/build.lst b/vbahelper/prj/build.lst index 0db5274b7ad3..20001db859c8 100644 --- a/vbahelper/prj/build.lst +++ b/vbahelper/prj/build.lst @@ -1,4 +1,4 @@ -vba vbahelper : oovbaapi basic sfx2 svx cppuhelper vcl comphelper svtools tools sal NULL +vba vbahelper : oovbaapi basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal NULL vba vbahelper usr1 - all vba_mkout NULL #vba vbahelper\inc nmake - all vba_inc NULL vba vbahelper\source\vbahelper nmake - all vba_vbahelper NULL -- cgit From a0147bb5d9e421d6458722196cef6d4caf2cf2fe Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 8 Mar 2010 23:24:53 +0000 Subject: npower13objectmodules: clean build breaks vbahelper/filter --- filter/prj/build.lst | 2 +- filter/source/msfilter/makefile.mk | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/filter/prj/build.lst b/filter/prj/build.lst index b4be1c83e63e..bed99e401b7f 100644 --- a/filter/prj/build.lst +++ b/filter/prj/build.lst @@ -1,4 +1,4 @@ -fl filter : vbahelper l10n svtools unotools xmloff cppu tools cppuhelper sal svx javaunohelper XPDF:xpdf jvmaccess canvas SAXON:saxon LIBXSLT:libxslt NULL +fl filter : l10n svtools unotools xmloff cppu tools cppuhelper sal svx javaunohelper XPDF:xpdf jvmaccess canvas SAXON:saxon LIBXSLT:libxslt NULL fl filter usr1 - all fl_mkout NULL fl filter\prj get - all fl_prj NULL fl filter\inc nmake - all fl_inc NULL diff --git a/filter/source/msfilter/makefile.mk b/filter/source/msfilter/makefile.mk index 954009185a50..7780529b5580 100644 --- a/filter/source/msfilter/makefile.mk +++ b/filter/source/msfilter/makefile.mk @@ -60,7 +60,6 @@ SHL1OBJS= $(SLOFILES) SHL1USE_EXPORTS=name SHL1STDLIBS= \ $(EDITENGLIB) \ - $(VBAHELPERLIB) \ $(SVXCORELIB) \ $(SFX2LIB) \ $(XMLOFFLIB) \ -- cgit From caca8795c922c99729d2547c38277f46a7241453 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 9 Mar 2010 10:00:03 +0000 Subject: npower13objectmodules: wae (wntmsci12.pro) --- basic/inc/basic/sbmod.hxx | 8 ++++---- basic/source/classes/sbxmod.cxx | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index 81548198726b..ba468b252d2a 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -64,7 +64,7 @@ protected: SbiImage* pImage; // the Image SbiBreakpoints* pBreaks; // Breakpoints SbClassData* pClassData; - bool mbVBACompat; + BOOL mbVBACompat; INT32 mnType; SbxObjectRef pDocObject; // an impl object ( used by Document Modules ) bool bIsProxyModule; @@ -92,7 +92,7 @@ protected: public: SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMOD,2); TYPEINFO(); - SbModule( const String&, bool bCompat = false ); + SbModule( const String&, BOOL bCompat = FALSE ); virtual void SetParent( SbxObject* ); virtual void Clear(); @@ -128,8 +128,8 @@ public: BOOL LoadBinaryData( SvStream& ); BOOL ExceedsLegacyModuleSize(); void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const; - bool IsVBACompat(); - void SetVBACompat( bool bCompat ); + BOOL IsVBACompat(); + void SetVBACompat( BOOL bCompat ); INT32 GetModuleType() { return mnType; } void SetModuleType( INT32 nType ) { mnType = nType; } bool GetIsProxyModule() { return bIsProxyModule; } diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 622083bd58cc..87855035eb2e 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -159,7 +159,7 @@ bool UnlockControllerHack( StarBASIC* pBasic ) // Ein BASIC-Modul hat EXTSEARCH gesetzt, damit die im Modul enthaltenen // Elemente von anderen Modulen aus gefunden werden koennen. -SbModule::SbModule( const String& rName, bool bVBACompat ) +SbModule::SbModule( const String& rName, BOOL bVBACompat ) : SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("StarBASICModule") ) ), pImage( NULL ), pBreaks( NULL ), pClassData( NULL ), mbVBACompat( bVBACompat ), pDocObject( NULL ), bIsProxyModule( false ) { @@ -609,12 +609,12 @@ void ClearUnoObjectsInRTL_Impl( StarBASIC* pBasic ) if( ((StarBASIC*)p) != pBasic ) ClearUnoObjectsInRTL_Impl_Rek( (StarBASIC*)p ); } -bool SbModule::IsVBACompat() +BOOL SbModule::IsVBACompat() { return mbVBACompat; } -void SbModule::SetVBACompat( bool bCompat ) +void SbModule::SetVBACompat( BOOL bCompat ) { mbVBACompat = bCompat; } -- cgit From d9cc9a33542bee1e661f4b8edbc1a56175a01120 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 11 Mar 2010 11:16:48 +0000 Subject: sdfindall: #i46270# remove find all button in draw/impress --- svx/source/dialog/srchdlg.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 5f3aa24394a3..01dc2c0591cc 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -831,6 +831,18 @@ void SvxSearchDialog::CalculateDelta_Impl() pMoreBtn->AddWindow( &aNoFormatBtn ); } + if (bDrawApp || bImpressApp) + { + // "Find All" button is hidden--align "Find" vertically to the + // search listbox + Point aNewPt(aSearchBtn.GetPosPixel()); + const Size aBtnSz(aSearchBtn.GetSizePixel()); + const Size aLBSz(aSearchLB.GetSizePixel()); + const int nOff((aLBSz.Height() - aBtnSz.Height()) / 2); + aNewPt.Y() = aSearchLB.GetPosPixel().Y() + nOff; + aSearchBtn.SetPosPixel(aNewPt); + } + if ( bDrawApp ) { // Draw App: "Regular expressions" and "Search for Styles" check boxes are hidden @@ -1016,6 +1028,8 @@ void SvxSearchDialog::Init_Impl( int bSearchPattern ) if ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_DRAW ) { + aSearchAllBtn.Hide(); + aRegExpBtn.Hide(); aLayoutBtn.Hide(); -- cgit From 27aa543a8a2fac7aa1367cc7a378a34077d3308e Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Thu, 11 Mar 2010 17:56:43 +0100 Subject: bugs fixed for build on macOS --- svtools/inc/svtools/accessibletable.hxx | 1 - svtools/source/table/gridtablerenderer.cxx | 2 ++ svtools/source/table/tablecontrol_impl.cxx | 16 +++++++--------- svtools/source/uno/svtxgridcontrol.cxx | 4 ++-- toolkit/source/controls/grid/defaultgriddatamodel.cxx | 2 +- toolkit/source/controls/grid/gridcolumn.cxx | 9 +++++---- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/svtools/inc/svtools/accessibletable.hxx b/svtools/inc/svtools/accessibletable.hxx index e13a0afe9469..cce4990aa758 100755 --- a/svtools/inc/svtools/accessibletable.hxx +++ b/svtools/inc/svtools/accessibletable.hxx @@ -34,7 +34,6 @@ #include #include #include -#include // ============================================================================ diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 7e721832c04c..4518cb2c0512 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -108,6 +108,7 @@ namespace svt { namespace table _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); _rDevice.Pop(); + (void)_rStyle; (void)_bIsColHeaderArea; (void)_bIsRowHeaderArea; } @@ -254,6 +255,7 @@ namespace svt { namespace table // TODO: active? selected? (void)_bActive; (void)_bSelected; + (void)_rStyle; //at the moment no special paint for selected row header _rDevice.Pop(); } diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 9bc8644276f1..d738d4312d46 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -1117,8 +1117,6 @@ namespace svt { namespace table ::com::sun::star::uno::Any rCellData; if(!aCellData.empty() && iter != aCellData.begin()+m_nLeftColumn+nActualCols) { - TableSize nPartlyVisibleCols = impl_getVisibleColumns(false); - TableSize nPartlyVisibleRows = impl_getVisibleRows(false); rCellData = *iter; ++iter; Size siz = m_rAntiImpl.GetSizePixel(); @@ -2099,9 +2097,9 @@ namespace svt { namespace table { m_nResizingColumn = m_nCurColumn; PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn); - sal_Int32 colWidth = pColumn->getWidth(); - //impl_ni_getAccVisibleColWidths(); - int newColWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + //sal_Int32 colWidth = pColumn->getWidth(); + ////impl_ni_getAccVisibleColWidths(); + //int newColWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); if(m_aVisibleColumnWidthsPixel[m_nResizingColumn-m_nLeftColumn]-1 == rPoint.X() && pColumn->isResizable()) { m_pDataWindow->CaptureMouse(); @@ -2118,7 +2116,7 @@ namespace svt { namespace table PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn); int maxWidth = pColumn->getMaxWidth(); int minWidth = pColumn->getMinWidth(); - int colWidth = pColumn->getWidth(); + //int colWidth = pColumn->getWidth(); int resizeCol = m_nResizingColumn-m_nLeftColumn; //new position of mouse int actX = rPoint.X(); @@ -2234,9 +2232,9 @@ namespace svt { namespace table //-------------------------------------------------------------------- rtl::OUString TableControl_Impl::impl_convertToString(::com::sun::star::uno::Any value) { - sal_Int32 nInt; - sal_Bool bBool; - double fDouble; + sal_Int32 nInt = 0; + sal_Bool bBool = false; + double fDouble = 0; ::rtl::OUString sNewString; ::rtl::OUString sConvertString; if(value >>= sConvertString) diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index ce04078687b1..8a6f8f350e49 100755 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -216,7 +216,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_TEXTCOLOR: { - com::sun::star::util::Color colorText; + sal_Int32 colorText = 0xFFFFFF; if( aValue >>= colorText ) { m_pTableModel->setTextColor(colorText); @@ -225,7 +225,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_VERTICALALIGN: { - com::sun::star::style::VerticalAlignment vAlign; + com::sun::star::style::VerticalAlignment vAlign(com::sun::star::style::VerticalAlignment(0)); if( aValue >>= vAlign ) { switch( vAlign ) diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index c564618336af..2d695a9bad0a 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -30,7 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" -#include "DefaultGridDataModel.hxx" +#include "defaultgriddatamodel.hxx" #include #include #include diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index e8dadc527fbd..6ae502de7157 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -52,9 +52,10 @@ namespace toolkit GridColumn::GridColumn() : identifier(Any()) -,horizontalAlign(HorizontalAlignment(0)) -,columnWidth(4) +,columnWidth(10) ,bResizeable(true) +,horizontalAlign(HorizontalAlignment(0)) + { } @@ -162,13 +163,13 @@ void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star: bResizeable = value; } //--------------------------------------------------------------------- -HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() +HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) { return horizontalAlign; } //--------------------------------------------------------------------- -void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) +void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) { horizontalAlign = align; } -- cgit From 1d16fb039da5285a5a884ea2fffe0e2c85608cb4 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Thu, 11 Mar 2010 17:56:43 +0100 Subject: bugs fixed for build on macOS --- offapi/com/sun/star/awt/grid/DefaultGridColumnModel.idl | 1 + offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl | 2 ++ offapi/com/sun/star/awt/grid/GridColumn.idl | 6 ++++-- offapi/com/sun/star/awt/grid/GridColumnEvent.idl | 2 ++ offapi/com/sun/star/awt/grid/GridDataEvent.idl | 2 ++ offapi/com/sun/star/awt/grid/GridInvalidDataException.idl | 6 ++++-- offapi/com/sun/star/awt/grid/GridInvalidModelException.idl | 7 ++++--- offapi/com/sun/star/awt/grid/UnoControlGrid.idl | 3 ++- offapi/com/sun/star/awt/grid/UnoControlGridModel.idl | 6 ++++-- offapi/com/sun/star/awt/grid/XGridCell.idl | 2 +- offapi/com/sun/star/awt/grid/XGridCellRenderer.idl | 5 ++--- offapi/com/sun/star/awt/grid/XGridColumn.idl | 5 +++-- offapi/com/sun/star/awt/grid/XGridColumnListener.idl | 8 +++++--- offapi/com/sun/star/awt/grid/XGridColumnModel.idl | 8 +++++--- offapi/com/sun/star/awt/grid/XGridControl.idl | 14 ++++---------- offapi/com/sun/star/awt/grid/XGridControlListener.idl | 6 +++--- offapi/com/sun/star/awt/grid/XGridDataListener.idl | 6 ++++-- offapi/com/sun/star/awt/grid/XGridDataModel.idl | 4 +++- offapi/com/sun/star/awt/grid/XGridSelection.idl | 2 +- 19 files changed, 56 insertions(+), 39 deletions(-) diff --git a/offapi/com/sun/star/awt/grid/DefaultGridColumnModel.idl b/offapi/com/sun/star/awt/grid/DefaultGridColumnModel.idl index 67e5b7572de3..4697bb7d0162 100644 --- a/offapi/com/sun/star/awt/grid/DefaultGridColumnModel.idl +++ b/offapi/com/sun/star/awt/grid/DefaultGridColumnModel.idl @@ -41,6 +41,7 @@ //============================================================================= /** If you do not want to implement the XGridColumnModel yourself, use this service. + @since OOo 3.3.0 */ service DefaultGridColumnModel { diff --git a/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl b/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl index 40a77668887c..91e9728edfc1 100644 --- a/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl +++ b/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl @@ -41,6 +41,8 @@ //============================================================================= /** If you do not want to implement the XGridDataModel yourself, use this service. + + @since OOo 3.3.0 */ service DefaultGridDataModel { diff --git a/offapi/com/sun/star/awt/grid/GridColumn.idl b/offapi/com/sun/star/awt/grid/GridColumn.idl index 90db6f82b258..e5386ca95f93 100644 --- a/offapi/com/sun/star/awt/grid/GridColumn.idl +++ b/offapi/com/sun/star/awt/grid/GridColumn.idl @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: UnoControlEdit.idl,v $ - * $Revision: 1.9 $ + * $RCSfile: UnoControlGridColumn.idl,v $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -41,6 +41,8 @@ //============================================================================= /** Represents a column as used by the DefaultGridColumnModel + + @since OOo 3.3.0 */ service GridColumn { diff --git a/offapi/com/sun/star/awt/grid/GridColumnEvent.idl b/offapi/com/sun/star/awt/grid/GridColumnEvent.idl index c6c5ac646cdf..ee63d9873a61 100644 --- a/offapi/com/sun/star/awt/grid/GridColumnEvent.idl +++ b/offapi/com/sun/star/awt/grid/GridColumnEvent.idl @@ -52,6 +52,8 @@ module com { module sun { module star { module awt { module grid { @see XGridColumnModel @see XGridControl @see XGridColumnListener + + @since OOo 3.3.0 */ struct GridColumnEvent: com::sun::star::lang::EventObject { diff --git a/offapi/com/sun/star/awt/grid/GridDataEvent.idl b/offapi/com/sun/star/awt/grid/GridDataEvent.idl index c280f30e0ba6..57be78914fe6 100644 --- a/offapi/com/sun/star/awt/grid/GridDataEvent.idl +++ b/offapi/com/sun/star/awt/grid/GridDataEvent.idl @@ -46,6 +46,8 @@ module com { module sun { module star { module awt { module grid { @see XGridDataModel @see XGridControl @see XGridDataListener + + @sonce OOo 3.3.0 */ struct GridDataEvent: com::sun::star::lang::EventObject { diff --git a/offapi/com/sun/star/awt/grid/GridInvalidDataException.idl b/offapi/com/sun/star/awt/grid/GridInvalidDataException.idl index 499da967c3f1..af1f90dfdc8b 100644 --- a/offapi/com/sun/star/awt/grid/GridInvalidDataException.idl +++ b/offapi/com/sun/star/awt/grid/GridInvalidDataException.idl @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: ExpandVetoException.idl,v $ - * $Revision: 1.3 $ + * $RCSfile: GridInvalidDataException.idl,v $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -43,6 +43,8 @@ module com { module sun { module star { module awt { module grid { /** Exception is thrown to indicate that set data is invalid, e.g. type of data is unknown or data count doesn't match with column count. + + @since OOo 3.3.0 */ exception GridInvalidDataException : com::sun::star::uno::RuntimeException { diff --git a/offapi/com/sun/star/awt/grid/GridInvalidModelException.idl b/offapi/com/sun/star/awt/grid/GridInvalidModelException.idl index 2f0d36bdb495..9d96daf624bb 100644 --- a/offapi/com/sun/star/awt/grid/GridInvalidModelException.idl +++ b/offapi/com/sun/star/awt/grid/GridInvalidModelException.idl @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: ExpandVetoException.idl,v $ - * $Revision: 1.3 $ + * $RCSfile: GridInvalidModelException.idl,v $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -42,6 +42,8 @@ module com { module sun { module star { module awt { module grid { //============================================================================= /** Exception is thrown when data or column model isn't set. + + @since OOo 3.3.0 */ exception GridInvalidModelException : com::sun::star::uno::RuntimeException { @@ -53,4 +55,3 @@ exception GridInvalidModelException : com::sun::star::uno::RuntimeException }; }; }; }; }; #endif - \ No newline at end of file diff --git a/offapi/com/sun/star/awt/grid/UnoControlGrid.idl b/offapi/com/sun/star/awt/grid/UnoControlGrid.idl index d45bf024afb1..6d8eabaefc54 100644 --- a/offapi/com/sun/star/awt/grid/UnoControlGrid.idl +++ b/offapi/com/sun/star/awt/grid/UnoControlGrid.idl @@ -6,7 +6,7 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: UnoControlEdit.idl,v $ + * $RCSfile: UnoControlGrid.idl,v $ * $Revision: 1.9 $ * * This file is part of OpenOffice.org. @@ -69,6 +69,7 @@ The XGridSelection interface provides a bunch of methods to set and get selection for the grid control.

+ @since OOo 3.3.0 */ service UnoControlGrid { diff --git a/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl b/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl index 97238f8a163b..12017dcea5be 100644 --- a/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl +++ b/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: UnoControlEditModel.idl,v $ - * $Revision: 1.16 $ + * $RCSfile: UnoControlGridModel.idl,v $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -53,6 +53,8 @@ module com { module sun { module star { module awt { module grid { //============================================================================= /** specifies the standard model of a UnoControlGridModel. + + @since OOo 3.3.0 */ service UnoControlGridModel { diff --git a/offapi/com/sun/star/awt/grid/XGridCell.idl b/offapi/com/sun/star/awt/grid/XGridCell.idl index 40f55109e24c..4bd1a99baf42 100644 --- a/offapi/com/sun/star/awt/grid/XGridCell.idl +++ b/offapi/com/sun/star/awt/grid/XGridCell.idl @@ -42,7 +42,7 @@ module com { module sun { module star { module awt { module grid { //============================================================================= -interface XGridCell: com::sun::star::uno::XInterface +interface XGridCell { [attribute] string Value; diff --git a/offapi/com/sun/star/awt/grid/XGridCellRenderer.idl b/offapi/com/sun/star/awt/grid/XGridCellRenderer.idl index 88fd77697876..86599f2f47ba 100644 --- a/offapi/com/sun/star/awt/grid/XGridCellRenderer.idl +++ b/offapi/com/sun/star/awt/grid/XGridCellRenderer.idl @@ -40,10 +40,9 @@ module com { module sun { module star { module awt { module grid { //============================================================================= -/** gives access to the items of a list box and makes it possible to - register item and action event listeners. +/** renderer for cells */ -interface XGridCellRenderer: com::sun::star::uno::XInterface +interface XGridCellRenderer { //------------------------------------------------------------------------- diff --git a/offapi/com/sun/star/awt/grid/XGridColumn.idl b/offapi/com/sun/star/awt/grid/XGridColumn.idl index 45dcc258fb08..898b429598ff 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumn.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumn.idl @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: XGridColumn.idl,v $ - * $Revision: 1.8 $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -43,8 +43,9 @@ module com { module sun { module star { module awt { module grid { //============================================================================= /** The XGridColumn defines the properties and behavior of a column in a grid control + @since OOo 3.3.0 */ -interface XGridColumn: com::sun::star::uno::XInterface +interface XGridColumn { /** Specifies the an idendifier of the colomn.**/ [attribute] any Identifier; diff --git a/offapi/com/sun/star/awt/grid/XGridColumnListener.idl b/offapi/com/sun/star/awt/grid/XGridColumnListener.idl index 09a2b602e800..2cad804a0b8e 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumnListener.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumnListener.idl @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: XListBox.idl,v $ - * $Revision: 1.8 $ + * $RCSfile: XGridColumnListener.idl,v $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -49,8 +49,10 @@ module com { module sun { module star { module awt { module grid {

Usually you must not implement this interface yourself, but you must notify it correctly if you implement the XGridColumnModel yourself

. + + @since OOo 3.3.0 */ -interface XGridColumnListener: com::sun::star::uno::XInterface +interface XGridColumnListener { /** Invoked after a column was added to the column model. diff --git a/offapi/com/sun/star/awt/grid/XGridColumnModel.idl b/offapi/com/sun/star/awt/grid/XGridColumnModel.idl index fad0ce190d69..fa63661185b5 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumnModel.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumnModel.idl @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: XListBox.idl,v $ - * $Revision: 1.8 $ + * $RCSfile: XGridColumnModel.idl,v $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -45,8 +45,10 @@ module com { module sun { module star { module awt { module grid { retrieve the column structure that is displayed in the actual control. If you do not need your own model implementation, you can also use the DefaultGridColumnModel. + + @since OOo 3.3.0 */ -interface XGridColumnModel: com::sun::star::uno::XInterface +interface XGridColumnModel { /** Specifies whether column selection is allowed */ diff --git a/offapi/com/sun/star/awt/grid/XGridControl.idl b/offapi/com/sun/star/awt/grid/XGridControl.idl index 7fe015925213..5c6168cae47f 100644 --- a/offapi/com/sun/star/awt/grid/XGridControl.idl +++ b/offapi/com/sun/star/awt/grid/XGridControl.idl @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: XListBox.idl,v $ - * $Revision: 1.8 $ + * $RCSfile: XGridControl.idl,v $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -44,6 +44,8 @@ module com { module sun { module star { module awt { module grid { /** An interface to a control that displays a tabular data. @see UnoControlGrid + + @since OOo 3.3.0 */ interface XGridControl: XGridSelection { @@ -62,14 +64,6 @@ interface XGridControl: XGridSelection */ void setToolTip( [in] sequence< string > textForTooltip, [in] sequence< long > columnsForTooltip); - /** registers a listener for mouse events. - */ - //[oneway] void addMouseListener( [in] com::sun::star::awt::XMouseListener listener ); - - /** unregisters a listener for mouse events. - */ - //[oneway] void removeMouseListener( [in] com::sun::star::awt::XMouseListener listener ); - }; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/XGridControlListener.idl b/offapi/com/sun/star/awt/grid/XGridControlListener.idl index c7fa1fd41e2f..bd64873d70cf 100644 --- a/offapi/com/sun/star/awt/grid/XGridControlListener.idl +++ b/offapi/com/sun/star/awt/grid/XGridControlListener.idl @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: XListBox.idl,v $ - * $Revision: 1.8 $ + * $RCSfile: XGridControlListener.idl,v $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -40,7 +40,7 @@ module com { module sun { module star { module awt { module grid { //============================================================================= -interface XGridControlListener: com::sun::star::uno::XInterface +interface XGridControlListener { }; diff --git a/offapi/com/sun/star/awt/grid/XGridDataListener.idl b/offapi/com/sun/star/awt/grid/XGridDataListener.idl index ce6479496034..905b5f61f8d3 100644 --- a/offapi/com/sun/star/awt/grid/XGridDataListener.idl +++ b/offapi/com/sun/star/awt/grid/XGridDataListener.idl @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: XListBox.idl,v $ - * $Revision: 1.8 $ + * $RCSfile: XGridDataListener.idl,v $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -49,6 +49,8 @@ module com { module sun { module star { module awt { module grid {

Usually you must not implement this interface yourself, but you must notify it correctly if you implement the XGridDataModel yourself

. + + @since OOo 3.3.0 */ interface XGridDataListener: com::sun::star::lang::XEventListener { diff --git a/offapi/com/sun/star/awt/grid/XGridDataModel.idl b/offapi/com/sun/star/awt/grid/XGridDataModel.idl index ba00552db37b..ad8849cc743a 100644 --- a/offapi/com/sun/star/awt/grid/XGridDataModel.idl +++ b/offapi/com/sun/star/awt/grid/XGridDataModel.idl @@ -7,7 +7,7 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: XListBox.idl,v $ + * $RCSfile: XGridDataModel.idl,v $ * * This file is part of OpenOffice.org. * @@ -44,6 +44,8 @@ module com { module sun { module star { module awt { module grid { retrieve the content data that is displayed in the actual control. If you do not need your own model implementation, you can also use the DefaultGridDataModel. + + @since OOo 3.3.0 */ interface XGridDataModel: ::com::sun::star::lang::XComponent { diff --git a/offapi/com/sun/star/awt/grid/XGridSelection.idl b/offapi/com/sun/star/awt/grid/XGridSelection.idl index b567b7570ddc..972fce979e8a 100644 --- a/offapi/com/sun/star/awt/grid/XGridSelection.idl +++ b/offapi/com/sun/star/awt/grid/XGridSelection.idl @@ -42,7 +42,7 @@ module com { module sun { module star { module awt { module grid { /** This interfaces provides access to the selection of row for UnoControlGrid. */ -interface XGridSelection: com::sun::star::uno::XInterface +interface XGridSelection { /** Returns the lowest index of the selection. @returns -- cgit From b5e60257b01d6df6b7e8357419fa65b60d7f4f4a Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 12 Mar 2010 12:49:14 +0100 Subject: changes in XGridColumnListener --- offapi/com/sun/star/awt/grid/XGridColumnListener.idl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/offapi/com/sun/star/awt/grid/XGridColumnListener.idl b/offapi/com/sun/star/awt/grid/XGridColumnListener.idl index 09a2b602e800..53b0e66baa20 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumnListener.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumnListener.idl @@ -52,15 +52,15 @@ module com { module sun { module star { module awt { module grid { */ interface XGridColumnListener: com::sun::star::uno::XInterface { - /** - Invoked after a column was added to the column model. - */ - void columnAdded( [in] GridColumnEvent event ); - - /** - Invoked after a column was removed from the column model. - */ - void columnRemoved( [in] GridColumnEvent event ); + // /** + // Invoked after a column was added to the column model. + //*/ + //void columnAdded( [in] GridColumnEvent event ); + // + // /** + // Invoked after a column was removed from the column model. + //*/ + //void columnRemoved( [in] GridColumnEvent event ); /** Invoked after a column was modified. -- cgit From 775be31b8148eed368b440c49613cfb1917a027e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 15 Mar 2010 17:00:24 +0100 Subject: sw33bf03: #i110144#: sw: ascii export: add space after list label --- sw/source/filter/ascii/ascatr.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx index 02408f971140..abb842acb3f4 100644 --- a/sw/source/filter/ascii/ascatr.cxx +++ b/sw/source/filter/ascii/ascatr.cxx @@ -172,7 +172,14 @@ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) SwASC_AttrIter aAttrIter( (SwASCWriter&)rWrt, rNd, nStrPos ); if( !nStrPos && rWrt.bExportPargraphNumbering ) - rWrt.Strm().WriteUnicodeOrByteText( rNd.GetNumString() ); + { + String numString( rNd.GetNumString() ); + if (numString.Len()) + { + numString.Append(' '); + rWrt.Strm().WriteUnicodeOrByteText(numString); + } + } String aStr( rNd.GetTxt() ); if( rWrt.bASCII_ParaAsBlanc ) -- cgit From a4f0aa4ea560aefd0eba9dd59ad63d7d91087864 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 16 Mar 2010 17:07:56 +0100 Subject: sw33bf03: #i110140#: sw: ~SwTxtFld: unregister at field format --- sw/source/core/txtnode/atrfld.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 68c779f9914b..9ac53456e7ef 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -268,6 +268,11 @@ SwTxtFld::SwTxtFld( SwFmtFld& rAttr, xub_StrLen nStartPos ) SwTxtFld::~SwTxtFld( ) { + SwFmtFld & rFmtFld( static_cast(GetAttr()) ); + if (this == rFmtFld.pTxtAttr) + { + rFmtFld.pTxtAttr = 0; // #i110140# invalidate! + } } /************************************************************************* -- cgit From b9ba6b35bf4a2a3ef5f85e4cca6ac6e8818161f1 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 16 Mar 2010 17:15:38 +0100 Subject: sw33bf03: #i110140#: SwFldFmt::Modify: apply patch by cmc --- sw/source/core/txtnode/atrfld.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 9ac53456e7ef..13695778c6a8 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -160,14 +160,16 @@ void SwFmtFld::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) if( !pTxtAttr ) return; + // don't do anything, especially not expand! + if( pNew && pNew->Which() == RES_OBJECTDYING ) + return; + SwTxtNode* pTxtNd = (SwTxtNode*)&pTxtAttr->GetTxtNode(); ASSERT( pTxtNd, "wo ist denn mein Node?" ); if( pNew ) { switch( pNew->Which() ) { - case RES_OBJECTDYING: - return; // don't do anything, especially not expand! case RES_TXTATR_FLDCHG: // "Farbe hat sich geaendert !" // this, this fuer "nur Painten" @@ -192,6 +194,8 @@ void SwFmtFld::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) case RES_FMT_CHG: pTxtNd->Modify( pOld, pNew ); return; + default: + break; } } -- cgit From 3421215984f3c0a5fcbadc070524f93dc6b89923 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 17 Mar 2010 13:44:55 +0100 Subject: sw33bf03: #i109921#: sw: unnecessary null checks: apply patch by cmc --- sw/source/core/frmedt/feshview.cxx | 5 +---- sw/source/ui/uno/unotxvw.cxx | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index af2e8d1c7677..d435bfb194d9 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -238,10 +238,7 @@ BOOL SwFEShell::SelectObj( const Point& rPt, BYTE nFlag, SdrObject *pObj ) if( bForget ) { pDView->UnmarkAll(); - if ( pTmpObj ) - pDView->MarkObj( pTmpObj, Imp()->GetPageView(), bAddSelect, bEnterGroup ); - else - pDView->MarkObj( rPt, MINMOVE ); + pDView->MarkObj( pTmpObj, Imp()->GetPageView(), bAddSelect, bEnterGroup ); break; } } diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 73c89873819b..556f6bd26997 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -908,12 +908,12 @@ void SAL_CALL SwXTextView::setRubyList( -----------------------------------------------------------------------*/ SfxObjectShellRef SwXTextView::BuildTmpSelectionDoc( SfxObjectShellRef& /*rRef*/ ) { - SwWrtShell* pOldSh = &m_pView->GetWrtShell(); - SfxPrinter *pPrt = pOldSh->getIDocumentDeviceAccess()->getPrinter( false ); + SwWrtShell& rOldSh = m_pView->GetWrtShell(); + SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess()->getPrinter( false ); SwDocShell* pDocSh; SfxObjectShellRef xDocSh( pDocSh = new SwDocShell( /*pPrtDoc, */SFX_CREATE_MODE_STANDARD ) ); xDocSh->DoInitNew( 0 ); - pOldSh->FillPrtDoc(pDocSh->GetDoc(), pPrt); + rOldSh.FillPrtDoc(pDocSh->GetDoc(), pPrt); SfxViewFrame* pDocFrame = SfxViewFrame::CreateViewFrame( *xDocSh, 0, TRUE ); SwView* pDocView = (SwView*) pDocFrame->GetViewShell(); pDocView->AttrChangedNotify( &pDocView->GetWrtShell() );//Damit SelectShell gerufen wird. @@ -922,22 +922,19 @@ SfxObjectShellRef SwXTextView::BuildTmpSelectionDoc( SfxObjectShellRef& /*rRef*/ IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess(); SfxPrinter* pTempPrinter = pIDDA->getPrinter( true ); - if( pOldSh ) - { - const SwPageDesc& rCurPageDesc = pOldSh->GetPageDesc(pOldSh->GetCurPageDesc()); - - IDocumentDeviceAccess* pIDDA_old = pOldSh->getIDocumentDeviceAccess(); + const SwPageDesc& rCurPageDesc = rOldSh.GetPageDesc(rOldSh.GetCurPageDesc()); - if( pIDDA_old->getPrinter( false ) ) - { - pIDDA->setJobsetup( *pIDDA_old->getJobsetup() ); - //#69563# if it isn't the same printer then the pointer has been invalidated! - pTempPrinter = pIDDA->getPrinter( true ); - } + IDocumentDeviceAccess* pIDDA_old = rOldSh.getIDocumentDeviceAccess(); - pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue()); + if( pIDDA_old->getPrinter( false ) ) + { + pIDDA->setJobsetup( *pIDDA_old->getJobsetup() ); + //#69563# if it isn't the same printer then the pointer has been invalidated! + pTempPrinter = pIDDA->getPrinter( true ); } + pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue()); + return xDocSh; } -- cgit From 99d003c030ec5d547c452efdc42be3a3fa6810fa Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Mon, 22 Mar 2010 11:17:10 +0100 Subject: recent changes for grid control --- svtools/inc/svtools/accessibletable.hxx | 3 +- svtools/inc/svtools/table/tablecontrol.hxx | 16 +- svtools/inc/svtools/table/tabledatawindow.hxx | 10 +- svtools/source/table/gridtablerenderer.cxx | 22 +- svtools/source/table/tablecontrol.cxx | 66 +++- svtools/source/table/tablecontrol_impl.cxx | 335 ++++++++--------- svtools/source/table/tablecontrol_impl.hxx | 14 +- svtools/source/table/tabledatawindow.cxx | 10 +- svtools/source/uno/svtxgridcontrol.cxx | 407 ++++++++++++++------- svtools/source/uno/svtxgridcontrol.hxx | 33 +- svtools/source/uno/unocontroltablemodel.cxx | 93 +---- svtools/source/uno/unocontroltablemodel.hxx | 5 +- toolkit/inc/toolkit/helper/listenermultiplexer.hxx | 10 +- toolkit/inc/toolkit/helper/property.hxx | 1 + .../controls/grid/defaultgridcolumnmodel.cxx | 170 +++++---- .../controls/grid/defaultgridcolumnmodel.hxx | 20 +- .../source/controls/grid/defaultgriddatamodel.cxx | 7 +- toolkit/source/controls/grid/gridcolumn.cxx | 79 +++- toolkit/source/controls/grid/gridcolumn.hxx | 12 +- toolkit/source/controls/grid/gridcontrol.cxx | 58 ++- toolkit/source/controls/grid/gridcontrol.hxx | 7 +- toolkit/source/helper/listenermultiplexer.cxx | 5 + toolkit/source/helper/property.cxx | 5 +- vcl/inc/vcl/vclevent.hxx | 1 + 24 files changed, 794 insertions(+), 595 deletions(-) diff --git a/svtools/inc/svtools/accessibletable.hxx b/svtools/inc/svtools/accessibletable.hxx index e13a0afe9469..86bd2cbbcea1 100755 --- a/svtools/inc/svtools/accessibletable.hxx +++ b/svtools/inc/svtools/accessibletable.hxx @@ -34,7 +34,6 @@ #include #include #include -#include // ============================================================================ @@ -128,6 +127,8 @@ public: virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const = 0; virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0; virtual std::vector& GetSelectedRows() = 0; + virtual void RemoveSelectedRow(sal_Int32 _nRowPos) = 0; + virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) = 0; }; // ---------------------------------------------------------------------------- diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 59720cfd0602..b3aeb9d587e3 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -67,12 +67,13 @@ namespace svt { namespace table class TableControl : public Control, public IAccessibleTable { private: - DECL_LINK( ImplMouseButtonDownHdl, MouseEvent* ); - DECL_LINK( ImplMouseButtonUpHdl, MouseEvent* ); + DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); TableControl_Impl* m_pImpl; ::com::sun::star::uno::Sequence< sal_Int32 >& m_nCols; ::com::sun::star::uno::Sequence< ::rtl::OUString >& m_aText; + Link m_aSelectHdl; + bool m_bSelectionChanged; public: ::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable; @@ -152,16 +153,19 @@ namespace svt { namespace table } virtual void Resize(); + virtual void Select(); + void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } + const Link& GetSelectHdl() const { return m_aSelectHdl; } + /**invalidates the table if table has been changed e.g. new row added */ - void InvalidateDataWindow(RowPos _nRowStart, bool _bRemoved); + void InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved); /**gets the vector, which contains the selected rows */ std::vector& GetSelectedRows(); /**after removing a row, updates the vector which contains the selected rows if the row, which should be removed, is selected, it will be erased from the vector */ - void removeSelectedRow(RowPos _nRowPos); SelectionEngine* getSelEngine(); TableDataWindow* getDataWindow(); @@ -209,10 +213,12 @@ namespace svt { namespace table virtual sal_Bool HasColHeader(); virtual sal_Bool isAccessibleAlive( ) const; virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue ); - + virtual void RemoveSelectedRow(RowPos _nRowPos); + virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos); ::com::sun::star::uno::Sequence< sal_Int32 >& getColumnsForTooltip(); ::com::sun::star::uno::Sequence< ::rtl::OUString >& getTextForTooltip(); void setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols); + void selectionChanged(bool _bChanged); protected: /// retrieves the XAccessible implementation associated with the GridControl instance diff --git a/svtools/inc/svtools/table/tabledatawindow.hxx b/svtools/inc/svtools/table/tabledatawindow.hxx index 564680a39347..1cf98300d790 100644 --- a/svtools/inc/svtools/table/tabledatawindow.hxx +++ b/svtools/inc/svtools/table/tabledatawindow.hxx @@ -51,15 +51,11 @@ namespace svt { namespace table friend class TableFunctionSet; private: TableControl_Impl& m_rTableControl; - Link m_aMouseButtonDownHdl; - Link m_aMouseButtonUpHdl; - + Link m_aSelectHdl; public: TableDataWindow( TableControl_Impl& _rTableControl ); - inline void SetMouseButtonDownHdl( const Link& rLink ) { m_aMouseButtonDownHdl = rLink; } - inline const Link& GetMouseButtonDownHdl() const { return m_aMouseButtonDownHdl; } - inline void SetMouseButtonUpHdl( const Link& rLink ) { m_aMouseButtonUpHdl = rLink; } - inline const Link& GetMouseButtonUpHdl() const { return m_aMouseButtonUpHdl; } + inline void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } + inline const Link& GetSelectHdl() const { return m_aSelectHdl; } // Window overridables virtual void Paint( const Rectangle& rRect ); diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 7e721832c04c..313a5e842547 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -80,11 +80,7 @@ namespace svt { namespace table // fill the rows with alternating background colors _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); - //default background and line color is white - //background and lines should have same color, that's means lines aren't visible - //in case line color isn't set and background color is set, this should be changed Color background = m_pImpl->rModel.getHeaderBackgroundColor(); - //Color background = _rStyle.GetBackgroundColor(); Color line = m_pImpl->rModel.getLineColor(); //default background and line color is white //background and lines should have same color, that's means lines aren't visible @@ -102,7 +98,6 @@ namespace svt { namespace table _rDevice.SetFillColor(background); } _rDevice.DrawRect( _rArea ); - // delimiter lines at bottom/right _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); @@ -147,7 +142,10 @@ namespace svt { namespace table nHorFlag = TEXT_DRAW_CENTER; else if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2) nHorFlag = TEXT_DRAW_RIGHT; - _rDevice.DrawText( _rArea, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + Rectangle aRect(_rArea); + aRect.Left()+=4; aRect.Right()-=4; + aRect.Top()+=4; aRect.Bottom()-=4; + _rDevice.DrawText( aRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); _rDevice.Pop(); @@ -250,7 +248,10 @@ namespace svt { namespace table nHorFlag = TEXT_DRAW_CENTER; else if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2) nHorFlag = TEXT_DRAW_RIGHT; - _rDevice.DrawText( _rArea, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + Rectangle aRect(_rArea); + aRect.Left()+=4; aRect.Right()-=4; + aRect.Top()+=4; aRect.Bottom()-=4; + _rDevice.DrawText( aRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); // TODO: active? selected? (void)_bActive; (void)_bSelected; @@ -374,8 +375,6 @@ namespace svt { namespace table Rectangle aRect( _rArea ); ++aRect.Left(); --aRect.Right(); aRect.Top(); aRect.Bottom(); - - String sText; if(_bSelected) { _rDevice.SetTextColor(_rStyle.GetHighlightTextColor()); @@ -394,7 +393,10 @@ namespace svt { namespace table nHorFlag = TEXT_DRAW_CENTER; else if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 2) nHorFlag = TEXT_DRAW_RIGHT; - _rDevice.DrawText( aRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + Rectangle textRect(_rArea); + textRect.Left()+=4; textRect.Right()-=4; + textRect.Top()+=4; textRect.Bottom()-=4; + _rDevice.DrawText( textRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); } _rDevice.Pop(); diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 427f65557e52..635008d94f94 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -69,15 +69,16 @@ namespace svt { namespace table ,m_pImpl( new TableControl_Impl( *this ) ) ,m_nCols(*( new ::com::sun::star::uno::Sequence< sal_Int32 >(0) )) ,m_aText(*( new ::com::sun::star::uno::Sequence< ::rtl::OUString >(0) )) + ,m_bSelectionChanged(false) { - m_pImpl->getDataWindow()->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) ); - m_pImpl->getDataWindow()->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) ); + m_pImpl->getDataWindow()->SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) ); m_pAccessTable.reset(new ::svt::table::AccessibleTableControl_Impl()); } //-------------------------------------------------------------------- TableControl::~TableControl() { + ImplCallEventListeners( VCLEVENT_OBJECT_DYING ); DELETEZ( m_pImpl ); if ( m_pAccessTable->m_pAccessible ) { @@ -107,6 +108,14 @@ namespace svt { namespace table { if ( !m_pImpl->getInputHandler()->KeyInput( *m_pImpl, rKEvt ) ) Control::KeyInput( rKEvt ); + else + { + if(m_bSelectionChanged) + { + Select(); + m_bSelectionChanged = false; + } + } } //-------------------------------------------------------------------- void TableControl::Resize() @@ -163,13 +172,21 @@ namespace svt { namespace table return m_pImpl->goTo( _nColPos, _nRowPos ); } //-------------------------------------------------------------------- - void TableControl::InvalidateDataWindow(RowPos _nRowStart, bool _bRemoved) + void TableControl::InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved) { Rectangle _rRect; if(_bRemoved) - return m_pImpl->invalidateRows(_nRowStart, _rRect); + m_pImpl->invalidateRows(_nRowStart, _rRect); else - return m_pImpl->invalidateRow(_nRowStart, _rRect); + { + if(m_bSelectionChanged) + { + m_pImpl->invalidateSelectedRegion(_nRowStart, _nRowEnd, _rRect); + m_bSelectionChanged = false; + } + else + m_pImpl->invalidateRow(_nRowStart, _rRect); + } } //-------------------------------------------------------------------- std::vector& TableControl::GetSelectedRows() @@ -177,7 +194,7 @@ namespace svt { namespace table return m_pImpl->getSelectedRows(); } //-------------------------------------------------------------------- - void TableControl::removeSelectedRow(RowPos _nRowPos) + void TableControl::RemoveSelectedRow(RowPos _nRowPos) { m_pImpl->removeSelectedRow(_nRowPos); } @@ -188,20 +205,6 @@ namespace svt { namespace table return m_pImpl->getCurrentRow( rPoint ); } - //-------------------------------------------------------------------- - - IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData ) - { - CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData ); - return 1; - } - - IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData ) - { - CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData ); - return 1; - } - SelectionEngine* TableControl::getSelEngine() { return m_pImpl->getSelEngine(); @@ -345,6 +348,13 @@ namespace svt { namespace table } // ----------------------------------------------------------------------------- +::rtl::OUString TableControl::GetAccessibleCellText( sal_Int32 _nRowPos, sal_Int32 _nColPos) +{ + ::com::sun::star::uno::Any cellContent = GetCellContent(_nRowPos, _nColPos); + return m_pImpl->impl_convertToString(cellContent); +} +// ----------------------------------------------------------------------------- + void TableControl::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet, AccessibleTableControlObjType eObjType ) const @@ -553,7 +563,23 @@ void TableControl::setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUSt m_aText = aText; m_nCols = nCols; } +// ----------------------------------------------------------------------- +void TableControl::selectionChanged(bool _bChanged) +{ + m_bSelectionChanged = _bChanged; +} +// ----------------------------------------------------------------------- +IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG ) +{ + Select(); + return 1; +} +// ----------------------------------------------------------------------- +void TableControl::Select() +{ + ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_aSelectHdl, this ); +} //........................................................................ }} // namespace svt::table //........................................................................ diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 9bc8644276f1..aa22a8239375 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -284,8 +284,8 @@ namespace svt { namespace table :m_rTable( _rTable ) ,m_nSuspendFlags( _nSuspendFlags ) { - DBG_ASSERT( ( m_rTable.m_nRequiredInvariants & m_nSuspendFlags ) == m_nSuspendFlags, - "SuspendInvariants: cannot suspend what is already suspended!" ); + //DBG_ASSERT( ( m_rTable.m_nRequiredInvariants & m_nSuspendFlags ) == m_nSuspendFlags, + // "SuspendInvariants: cannot suspend what is already suspended!" ); const_cast< TableControl_Impl& >( m_rTable ).m_nRequiredInvariants &= ~m_nSuspendFlags; } ~SuspendInvariants() @@ -365,7 +365,6 @@ namespace svt { namespace table // m_nColHeaderHeightPixel consistent with the model's value? { TableMetrics nHeaderHeight = m_pModel->hasColumnHeaders() ? m_pModel->getColumnHeaderHeight() : 0; - // nHeaderHeight = m_rAntiImpl.LogicToPixel( Size( 0, nHeaderHeight ), MAP_100TH_MM ).Height(); nHeaderHeight = m_rAntiImpl.LogicToPixel( Size( 0, nHeaderHeight ), MAP_APPFONT ).Height(); if ( nHeaderHeight != m_nColHeaderHeightPixel ) return "column header heights are inconsistent!"; @@ -375,7 +374,6 @@ namespace svt { namespace table if ( !isDummyModel ) { TableMetrics nRowHeight = m_pModel->getRowHeight(); - // nRowHeight = m_rAntiImpl.LogicToPixel( Size( 0, nRowHeight ), MAP_100TH_MM ).Height(); nRowHeight = m_rAntiImpl.LogicToPixel( Size( 0, nRowHeight ), MAP_APPFONT).Height(); if ( nRowHeight != m_nRowHeightPixel ) return "row heights are inconsistent!"; @@ -384,14 +382,12 @@ namespace svt { namespace table // m_nRowHeaderWidthPixel consistent with the model's value? { TableMetrics nHeaderWidth = m_pModel->hasRowHeaders() ? m_pModel->getRowHeaderWidth() : 0; - //nHeaderWidth = m_rAntiImpl.LogicToPixel( Size( nHeaderWidth, 0 ), MAP_100TH_MM ).Width(); nHeaderWidth = m_rAntiImpl.LogicToPixel( Size( nHeaderWidth, 0 ), MAP_APPFONT ).Width(); if ( nHeaderWidth != m_nRowHeaderWidthPixel ) return "row header widths are inconsistent!"; } // TODO: check m_aColumnWidthsPixel and m_aAccColumnWidthsPixel - if ( m_nCursorHidden < 0 ) return "invalid hidden count for the cursor!"; @@ -453,6 +449,7 @@ namespace svt { namespace table ,m_nAnchor (-1 ) ,m_bResizing ( false ) ,m_nResizingColumn ( 0 ) + ,m_bResizingGrid ( false ) #if DBG_UTIL ,m_nRequiredInvariants ( INV_SCROLL_POSITION ) #endif @@ -494,14 +491,10 @@ namespace svt { namespace table TempHideCursor aHideCursor( *this ); - // TODO: revoke as table listener from the model - m_pModel = _pModel; if ( !m_pModel) m_pModel.reset( new EmptyTableModel ); - // TODO: register as table listener - //m_pModel->addTableModelListener(PTableModelListener(m_pTableModelListener)); m_nCurRow = ROW_INVALID; m_nCurColumn = COL_INVALID; @@ -571,11 +564,9 @@ namespace svt { namespace table m_pInputHandler.reset(); m_nColumnCount = m_nRowCount = 0; - //m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_100TH_MM ).Height(); m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_APPFONT ).Height(); if ( m_pModel->hasColumnHeaders() ) - //m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_100TH_MM ).Height(); - m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_APPFONT ).Height(); + m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_APPFONT ).Height(); if ( m_pModel->hasRowHeaders() ) m_nRowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT).Width(); @@ -602,7 +593,7 @@ namespace svt { namespace table m_aColumnWidthsPixel.reserve( colCount ); m_aAccColumnWidthsPixel.reserve( colCount ); long accumulatedPixelWidth = 0; - double gridWidth = m_rAntiImpl.GetSizePixel().Width()-1; + double gridWidth = m_rAntiImpl.GetSizePixel().Width()-4; if(m_pModel->hasRowHeaders()) { TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); @@ -612,10 +603,10 @@ namespace svt { namespace table { sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); gridWidth-=scrollbarWidth; - //m_rAntiImpl.LogicToPixel( Size( scrollbarWidth, 0 ), MAP_APPFONT ).Width(); } double colWidthsSum = 0.0; double colWithoutFixedWidthsSum = 0.0; + double minColWithoutFixedSum = 0.0; for ( ColPos col = 0; col < colCount; ++col ) { PColumnModel pColumn = m_pModel->getColumnModel( col ); @@ -624,74 +615,65 @@ namespace svt { namespace table continue; TableMetrics colWidth = 0; TableMetrics colPrefWidth = pColumn->getPreferredWidth(); + bool bResizable = pColumn->isResizable(); + if(pColumn->getMinWidth() == 0 && bResizable) + { + pColumn->setMinWidth(1); + minColWithoutFixedSum+=m_rAntiImpl.LogicToPixel( Size( 1, 0 ), MAP_APPFONT ).Width(); + } + if(pColumn->getMaxWidth() == 0 && bResizable) + pColumn->setMaxWidth(m_rAntiImpl.LogicToPixel( Size( (int)gridWidth, 0 ), MAP_APPFONT ).Width()); if( colPrefWidth != 0) { - colWidth = colPrefWidth; - pColumn->setWidth(colPrefWidth); + if(m_bResizingGrid) + { + colWidth = pColumn->getWidth(); + pColumn->setPreferredWidth(0); + } + else + { + colWidth = colPrefWidth; + pColumn->setWidth(colPrefWidth); + } } else colWidth = pColumn->getWidth(); long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - if(pColumn->isResizable() && colPrefWidth == 0) + if(bResizable && colPrefWidth == 0) colWithoutFixedWidthsSum+=pixelWidth; colWidthsSum+=pixelWidth; } - if(colWidthsSum < gridWidth) + gridWidth = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; + double scalingFactor = 1.0; + if(m_bResizingGrid) { - gridWidth = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; - double scalingFactor = 1.0; - if(colWithoutFixedWidthsSum>0) + if(gridWidth > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum)) scalingFactor = gridWidth/colWithoutFixedWidthsSum; - long pixelWidth = 0; - for ( ColPos col = 0; col < colCount; ++col ) + } + else + { + if(colWidthsSum < gridWidth) { - PColumnModel pColumn = m_pModel->getColumnModel( col ); - DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); - if ( !pColumn ) - continue; - TableMetrics colWidth = pColumn->getWidth(); - //if(pColumn->getPreferredWidth() != 0) - // colWidth = pColumn->getPreferredWidth(); - if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) - { - colWidth*=scalingFactor; - pColumn->setWidth(colWidth); - } - pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - m_aColumnWidthsPixel.push_back( pixelWidth ); - m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += pixelWidth ); + if(colWithoutFixedWidthsSum>0) + scalingFactor = gridWidth/colWithoutFixedWidthsSum; } - //m_rAntiImpl.SetModel(m_pModel); - } - else + long pixelWidth = 0; + for ( ColPos col = 0; col < colCount; ++col ) { - for ( ColPos col = 0; col < colCount; ++col ) + PColumnModel pColumn = m_pModel->getColumnModel( col ); + DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + if ( !pColumn ) + continue; + TableMetrics colWidth = pColumn->getWidth(); + if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) { - PColumnModel pColumn = m_pModel->getColumnModel( col ); - DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); - if ( !pColumn ) - continue; - - TableMetrics colWidth = pColumn->getWidth(); - DBG_ASSERT( ( colWidth == COLWIDTH_FIT_TO_VIEW ) || ( colWidth > 0 ), - "TableControl_Impl::impl_ni_updateColumnWidths: invalid column width!" ); - - long pixelWidth = 0; - if ( colWidth == COLWIDTH_FIT_TO_VIEW ) - { - // TODO - DBG_ERROR( "TableControl_Impl::impl_ni_updateColumnWidths: COLWIDTH_FIT_TO_VIEW not implemented, yet!" ); - } - else - { - //pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_100TH_MM ).Width(); - pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - } - m_aColumnWidthsPixel.push_back( pixelWidth ); - - m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += pixelWidth ); + colWidth*=scalingFactor; + pColumn->setWidth(colWidth); } + pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + m_aColumnWidthsPixel.push_back( pixelWidth ); + m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += pixelWidth ); } } @@ -925,11 +907,16 @@ namespace svt { namespace table void TableControl_Impl::onResize() { DBG_CHECK_ME(); - if(m_nColumnCount != 0) - impl_ni_updateScrollbars(); - //Rectangle aAllCells; - // impl_getAllVisibleCellsArea( aAllCells ); - //m_pSelEngine->SetVisibleArea(aAllCells); + if(m_nRowCount != 0) + { + if(m_nColumnCount != 0) + { + if(m_bResizingGrid) + impl_ni_updateColumnWidths(); + impl_ni_updateScrollbars(); + m_bResizingGrid = true; + } + } } //-------------------------------------------------------------------- @@ -1061,9 +1048,12 @@ namespace svt { namespace table { if ( _rUpdateRect.GetIntersection( aRowIterator.getRect() ).IsEmpty() ) { - if(m_pModel->hasRowHeaders()) - ++itRowName; - ++it; + if(it < aCellContent.end()-1) + { + if(m_pModel->hasRowHeaders()) + ++itRowName; + ++it; + } continue; } bool isActiveRow = ( aRowIterator.getRow() == getCurRow() ); @@ -1081,7 +1071,8 @@ namespace svt { namespace table if(it != aCellContent.begin()+m_nTopRow+nActualRows) { aCellData = *it; - ++it; + if(it < aCellContent.end()-1) + ++it; } ::std::vector< ::com::sun::star::uno::Any >::iterator iter = aCellData.begin()+m_nLeftColumn; @@ -1096,7 +1087,8 @@ namespace svt { namespace table if(itRowName != aRowHeaderContent.begin()+m_nTopRow+nActualRows) { rowHeaderName = *itRowName; - ++itRowName; + if(itRowName < m_pModel->getRowHeaderName().end()-1) + ++itRowName; } Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); //rStyle.SetBackgroundColor(m_rAntiImpl.getHeaderBackgroundColor()); @@ -1120,7 +1112,8 @@ namespace svt { namespace table TableSize nPartlyVisibleCols = impl_getVisibleColumns(false); TableSize nPartlyVisibleRows = impl_getVisibleRows(false); rCellData = *iter; - ++iter; + if(iter < aCellData.end()-1) + ++iter; Size siz = m_rAntiImpl.GetSizePixel(); ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; if(rCellData>>=xGraphic) @@ -1177,8 +1170,8 @@ namespace svt { namespace table for(std::vector::iterator it=m_nRowSelected.begin(); it!=m_nRowSelected.end();++it) { - invalidateSelectedRow(*it,rCells); - m_pDataWindow->Invalidate(rCells); + invalidateSelectedRegion(*it, *it, rCells); + //m_pDataWindow->Invalidate(rCells); } m_nRowSelected.clear(); } @@ -1189,8 +1182,9 @@ namespace svt { namespace table } else m_nRowSelected.push_back(m_nCurRow); - invalidateSelectedRow(m_nCurRow, rCells); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); ensureVisible(m_nCurColumn,m_nCurRow,false); + m_rAntiImpl.selectionChanged(true); bSuccess = true; } else @@ -1198,8 +1192,6 @@ namespace svt { namespace table if ( m_nCurRow < m_nRowCount - 1 ) { bSuccess = goTo( m_nCurColumn, m_nCurRow + 1 ); - if(m_pSelEngine->GetSelectionMode() == MULTIPLE_SELECTION) - m_nAnchor = m_nCurRow; } } break; @@ -1212,8 +1204,8 @@ namespace svt { namespace table for(std::vector::iterator it=m_nRowSelected.begin(); it!=m_nRowSelected.end();++it) { - invalidateSelectedRow(*it,rCells); - m_pDataWindow->Invalidate(rCells); + invalidateSelectedRegion(*it, *it, rCells); + //m_pDataWindow->Invalidate(rCells); } m_nRowSelected.clear(); } @@ -1221,14 +1213,15 @@ namespace svt { namespace table { --m_nCurRow; m_nRowSelected.push_back(m_nCurRow); - invalidateSelectedRow(m_nCurRow, rCells); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } else { m_nRowSelected.push_back(m_nCurRow); - invalidateSelectedRow(m_nCurRow, rCells); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } ensureVisible(m_nCurColumn,m_nCurRow,false); + m_rAntiImpl.selectionChanged(true); bSuccess = true; } else @@ -1236,8 +1229,6 @@ namespace svt { namespace table if ( m_nCurRow > 0 ) { bSuccess = goTo( m_nCurColumn, m_nCurRow - 1 ); - if(m_pSelEngine->GetSelectionMode() == MULTIPLE_SELECTION) - m_nAnchor = m_nCurRow; } } break; @@ -1303,11 +1294,16 @@ namespace svt { namespace table int pos = getRowSelectedNumber(m_nRowSelected, m_nCurRow); //if current row is selected, it should be deselected, when ALT+SPACE are pressed if(pos>-1) + { m_nRowSelected.erase(m_nRowSelected.begin()+pos); + if(m_nRowSelected.empty() && m_nAnchor != -1) + m_nAnchor = -1; + } //else select the row->put it in the vector else m_nRowSelected.push_back(m_nCurRow); - invalidateSelectedRow(m_nCurRow, rCells); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); + m_rAntiImpl.selectionChanged(true); bSuccess = true; } break; @@ -1325,19 +1321,19 @@ namespace svt { namespace table //there are other selected rows if(m_nRowSelected.size()>0) { - //the anchor wasn't set -> a region is not selected, that's why clear all selection - //and select the current row + // the anchor wasn't set -> a region is not selected, that's why clear all selection + // and select the current row if(m_nAnchor==-1) { for(std::vector::iterator it=m_nRowSelected.begin(); it!=m_nRowSelected.end();++it) { - invalidateSelectedRow(*it,rCells); - m_pDataWindow->Invalidate(rCells); + invalidateSelectedRegion(*it, *it, rCells); + //m_pDataWindow->Invalidate(rCells); } m_nRowSelected.clear(); m_nRowSelected.push_back(m_nCurRow); - invalidateSelectedRow(m_nCurRow, rCells); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } else { @@ -1352,17 +1348,27 @@ namespace svt { namespace table else return bSuccess = true; //if nextRow already selected, deselect it, otherwise select it - if(m_nRowSelected[nextRow] == m_nCurRow) + if(nextRow>-1 && m_nRowSelected[nextRow] == m_nCurRow) { m_nRowSelected.erase(m_nRowSelected.begin()+prevRow); - invalidateSelectedRow(m_nCurRow+1, rCells); + invalidateSelectedRegion(m_nCurRow+1, m_nCurRow+1, rCells); } else { m_nRowSelected.push_back(m_nCurRow); - invalidateSelectedRow(m_nCurRow, rCells); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } } + else + { + if(m_nCurRow>0) + { + m_nRowSelected.push_back(m_nCurRow); + m_nCurRow--; + m_nRowSelected.push_back(m_nCurRow); + invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells); + } + } } } else @@ -1380,12 +1386,13 @@ namespace svt { namespace table else { m_nRowSelected.push_back(m_nCurRow); - invalidateSelectedRow(m_nCurRow, rCells); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } } m_pSelEngine->SetAnchor(TRUE); m_nAnchor = m_nCurRow; ensureVisible(m_nCurColumn, m_nCurRow, false); + m_rAntiImpl.selectionChanged(true); bSuccess = true; } } @@ -1409,12 +1416,12 @@ namespace svt { namespace table for(std::vector::iterator it=m_nRowSelected.begin(); it!=m_nRowSelected.end();++it) { - invalidateSelectedRow(*it,rCells); - m_pDataWindow->Invalidate(rCells); + invalidateSelectedRegion(*it, *it, rCells); + //m_pDataWindow->Invalidate(rCells); } m_nRowSelected.clear(); m_nRowSelected.push_back(m_nCurRow); - invalidateSelectedRow(m_nCurRow, rCells); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } else { @@ -1424,27 +1431,37 @@ namespace svt { namespace table if(prevRow>-1) { //if m_nCurRow isn't the last one, can move down, otherwise not - if(m_nCurRow-1 && m_nRowSelected[nextRow] == m_nCurRow) { m_nRowSelected.erase(m_nRowSelected.begin()+prevRow); - invalidateSelectedRow(m_nCurRow-1, rCells); + invalidateSelectedRegion(m_nCurRow-1, m_nCurRow-1, rCells); } else { m_nRowSelected.push_back(m_nCurRow); - invalidateSelectedRow(m_nCurRow, rCells); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } } + else + { + if(m_nCurRowSetAnchor(TRUE); m_nAnchor = m_nCurRow; ensureVisible(m_nCurColumn, m_nCurRow, false); + m_rAntiImpl.selectionChanged(true); bSuccess = true; } } @@ -1487,6 +1505,7 @@ namespace svt { namespace table m_nAnchor = m_nCurRow; m_pSelEngine->SetAnchor(TRUE); ensureVisible(m_nCurColumn, 0, false); + m_rAntiImpl.selectionChanged(true); bSuccess = true; } } @@ -1510,7 +1529,8 @@ namespace svt { namespace table m_nCurRow = m_nRowCount-1; m_nAnchor = m_nCurRow; m_pSelEngine->SetAnchor(TRUE); - ensureVisible(m_nCurColumn, m_nRowCount, false); + ensureVisible(m_nCurColumn, m_nRowCount-1, false); + m_rAntiImpl.selectionChanged(true); bSuccess = true; } break; @@ -1555,11 +1575,6 @@ namespace svt { namespace table return; } - //DBG_ASSERT( ( _nColumn >= 0 ) && ( _nColumn < m_pModel->getColumnCount() ), - // "TableControl_Impl::impl_getCellRect: invalid column index!" ); - //DBG_ASSERT( ( _nRow >= 0 ) && ( _nRow < m_pModel->getRowCount() ), - // "TableControl_Impl::impl_getCellRect: invalid row index!" ); - Rectangle aAllCells; impl_getAllVisibleCellsArea( aAllCells ); @@ -1573,7 +1588,6 @@ namespace svt { namespace table Rectangle rCellRect; RowPos newRowPos = -2;//-1 is HeaderRow ColPos newColPos = 0; - //To Do: when only row position needed, the second loop isn't necessary, Please proove this!!! for(int i=-1;iInvalidate(_rCellRect); } - //------------------------------------------------------------------------------- - //To Do: not really needed, because in method above one row can be invalidate. Please Prove this!!! - void TableControl_Impl::invalidateSelectedRow(RowPos _nCurRow, Rectangle& _rCellRect) - { - DBG_CHECK_ME(); - Rectangle aAllCells; - impl_getAllVisibleCellsArea( aAllCells ); - _rCellRect.Left() = aAllCells.Left(); - _rCellRect.Right() = aAllCells.Right(); - Rectangle rCells; - impl_getCellRect(m_nCurColumn,_nCurRow,rCells); - _rCellRect.Top()=--rCells.Top(); - _rCellRect.Bottom()=rCells.Bottom(); - m_pDataWindow->Invalidate(_rCellRect); - } //------------------------------------------------------------------------------- //this method is to be called, when a new row is added void TableControl_Impl::invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect) { //DBG_CHECK_ME(); - TempHideCursor aHideCursor( *this ); + if(m_nCurRow < 0) + m_nCurRow = 0; + if(m_nCursorHidden == 2) + --m_nCursorHidden; impl_getAllVisibleCellsArea( _rCellRect ); TableRowGeometry _rRow( *this, _rCellRect, _nRowPos); impl_ni_updateScrollbars(); @@ -1723,28 +1724,6 @@ namespace svt { namespace table //DBG_CHECK_ME(); (void)_nRowStart; (void)_rCellRect; - /*TempHideCursor aHideCursor(*this); - Rectangle aAllCells; - impl_getAllVisibleCellsArea( aAllCells ); - TableRowGeometry _rRow( *this, aAllCells, _nRowStart); - _rCellRect = _rRow.getRect(); - Rectangle rCells1; - impl_getCellRect(m_nCurColumn,m_nRowCount,rCells1); - _rCellRect.Bottom() = rCells1.Bottom();*/ - /*if(_nRowStart != _nRowEnd) - { - TableRowGeometry _rRow( *this, aAllCells, _nRowEnd); - _rCellRect.Bottom() = _rRow.getRect().Bottom(); - } - */ - //_rCellRect.Right() = aAllCells.Right(); - //_rCellRect.Left() = aAllCells.Left(); - //Rectangle rCells1; - //impl_getCellRect(m_nCurColumn,_nRowStart,rCells1); - //_rCellRect.Top()=rCells1.Top(); - //Rectangle rCells2; - //impl_getCellRect(m_nCurColumn,_nRowEnd,rCells2); - //_rCellRect.Bottom()=rCells2.Bottom(); impl_ni_updateScrollbars(); TableSize nVisibleRows = impl_getVisibleRows(true); if(m_nTopRow+nVisibleRows>m_nRowCount && m_nRowCount>=nVisibleRows) @@ -1802,20 +1781,6 @@ namespace svt { namespace table // ensure that the new cell is visible ensureVisible( m_nCurColumn, m_nCurRow, false ); - - // TODO: invalidate all and new column/row header, if present, to enforce - // re-painting them - //if(!m_nRowSelected.empty()) - //{ - // Rectangle rCells; - // for(std::vector::iterator it=m_nRowSelected.begin(); - // it!=m_nRowSelected.end();++it) - // { - // invalidateSelectedRow(*it,rCells); - // } - // m_nRowSelected.clear(); - //} - // TODO: notify listeners about new position return true; } @@ -1986,7 +1951,7 @@ namespace svt { namespace table ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; if(content>>=xGraphic) - aTooltipText=::rtl::OUString::createFromAscii("IMAGE"); + aTooltipText=::rtl::OUString::createFromAscii(""); else aTooltipText = impl_convertToString(content); } @@ -1996,7 +1961,7 @@ namespace svt { namespace table ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; if(content>>=xGraphic) - aTooltipText += ::rtl::OUString::createFromAscii("IMAGE"); + aTooltipText += ::rtl::OUString::createFromAscii(""); else aTooltipText += impl_convertToString(content); } @@ -2034,7 +1999,7 @@ namespace svt { namespace table ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; if(content>>=xGraphic) - aTooltipText = ::rtl::OUString::createFromAscii("IMAGE"); + aTooltipText = ::rtl::OUString::createFromAscii(""); else aTooltipText = text[i] + impl_convertToString(content); } @@ -2047,7 +2012,7 @@ namespace svt { namespace table ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; if(content>>=xGraphic) - aTooltipText +=::rtl::OUString::createFromAscii("IMAGE"); + aTooltipText +=::rtl::OUString::createFromAscii(""); else aTooltipText += impl_convertToString(content); } @@ -2097,6 +2062,7 @@ namespace svt { namespace table //-------------------------------------------------------------------- bool TableControl_Impl::startResizeColumn(const Point& rPoint) { + m_bResizingGrid = false; m_nResizingColumn = m_nCurColumn; PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn); sal_Int32 colWidth = pColumn->getWidth(); @@ -2126,7 +2092,7 @@ namespace svt { namespace table int oldX = m_aVisibleColumnWidthsPixel[resizeCol]; //position of left border if cursor in the first cell int leftX = 0; - if(m_nResizingColumn-1 > 0 && m_nResizingColumn > m_nLeftColumn) + if(m_nResizingColumn > m_nLeftColumn) leftX = m_aVisibleColumnWidthsPixel[resizeCol-1]; else if(m_nResizingColumn == 0 && m_pModel->hasRowHeaders()) leftX = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width(); @@ -2135,11 +2101,6 @@ namespace svt { namespace table //minimize the column width if(oldX > actX && actX >= leftX) { - if(minWidth == 0 && pColumn->isResizable()) - { - minWidth = 1; - //TO DO: set it back to model - } if(minWidth < actWidth) { newActWidth = m_rAntiImpl.PixelToLogic( Size( actWidth, 0 ), MAP_APPFONT ).Width(); @@ -2152,11 +2113,6 @@ namespace svt { namespace table } else if(oldX < actX) { - if(maxWidth == 0 && pColumn->isResizable()) - { - maxWidth = m_pDataWindow->GetSizePixel().Width()-1; - //TO DO: set it back to model - } if(actWidth < maxWidth) { newActWidth = m_rAntiImpl.PixelToLogic( Size( actWidth, 0 ), MAP_APPFONT ).Width(); @@ -2171,6 +2127,7 @@ namespace svt { namespace table m_pDataWindow->Invalidate(INVALIDATE_UPDATE); m_pDataWindow->SetPointer(Pointer()); m_bResizing = false; + m_bResizingGrid = true; } m_pDataWindow->ReleaseMouse(); return m_bResizing; @@ -2362,7 +2319,7 @@ namespace svt { namespace table } if(m_pTableControl->m_nRowSelected.size()>1 && m_pTableControl->m_pSelEngine->GetSelectionMode()!=SINGLE_SELECTION) m_pTableControl->m_pSelEngine->AddAlways(TRUE); - m_pTableControl->invalidateSelectedRow(curRow,rCells); + m_pTableControl->invalidateSelectedRegion(curRow, curRow, rCells); bHandled = TRUE; } m_pTableControl->m_nCurRow = curRow; @@ -2397,7 +2354,7 @@ namespace svt { namespace table if(*it == m_nCurrentRow) { pos = i; - m_pTableControl->invalidateSelectedRow(*it,rCells); + m_pTableControl->invalidateSelectedRegion(*it, *it, rCells); } ++i; } @@ -2411,7 +2368,7 @@ namespace svt { namespace table for(std::vector::iterator it=m_pTableControl->m_nRowSelected.begin(); it!=m_pTableControl->m_nRowSelected.end();++it) { - m_pTableControl->invalidateSelectedRow(*it,rCells); + m_pTableControl->invalidateSelectedRegion(*it, *it, rCells); } m_pTableControl->m_nRowSelected.clear(); } diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index a26079a37827..dffa69422599 100644 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -118,6 +118,7 @@ namespace svt { namespace table RowPos m_nAnchor; bool m_bResizing; ColPos m_nResizingColumn; + bool m_bResizingGrid; #if DBG_UTIL #define INV_SCROLL_POSITION 1 @@ -186,15 +187,12 @@ namespace svt { namespace table virtual RowPos getCurrentRow (const Point& rPoint); void setCursorAtCurrentCell(const Point& rPoint); - /** proves whether the vector with the selected rows contains the current row*/ + /** checks whether the vector with the selected rows contains the current row*/ BOOL isRowSelected(::std::vector selectedRows, RowPos current); - /** returns the position of the current row in the selecttion vector */ + /** returns the position of the current row in the selection vector */ int getRowSelectedNumber(::std::vector selectedRows, RowPos current); - /** _rCellRect contains the region, which should be invalidate after some action e.g. selectiong row*/ + /** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/ void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect ); - /** _rCellRect contains the region, which should be invalidate after some action e.g. selectiong row*/ - //vielleicht kann man mit den anderen verschmelzen, mit einer Überprüfung ob prev==curr? - void invalidateSelectedRow( RowPos _nCurRow, Rectangle& _rCellRect ); /** to be called when a new row is added to the control*/ void invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect ); /** returns the vector, which contains the selected rows*/ @@ -202,7 +200,6 @@ namespace svt { namespace table /** updates the vector, which contains the selected rows after removing the row nRowPos*/ void removeSelectedRow(RowPos _nRowPos); void invalidateRows(RowPos _nRowStart, Rectangle& _rCellRect ); - //virtual void DoubleClick(); // IAbstractTableControl virtual void hideCursor(); @@ -232,6 +229,8 @@ namespace svt { namespace table minus the row and column header areas. */ void impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const; + + ::rtl::OUString impl_convertToString(::com::sun::star::uno::Any _value); private: /** toggles the cursor visibility @@ -319,7 +318,6 @@ namespace svt { namespace table void impl_ni_getAccVisibleColWidths(); void impl_updateLeftColumn(); - ::rtl::OUString impl_convertToString(::com::sun::star::uno::Any _value); DECL_LINK( OnScroll, ScrollBar* ); }; diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 8631ed76a6c0..6ae2a39443d1 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -44,6 +44,8 @@ namespace svt { namespace table :Window( &_rTableControl.getAntiImpl() ) ,m_rTableControl ( _rTableControl ) { + //Color backgroundColor = GetControlBackground(); + //SetBackground( backgroundColor ); } //-------------------------------------------------------------------- @@ -75,15 +77,17 @@ namespace svt { namespace table if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) ) Window::MouseButtonDown( rMEvt ); else - m_aMouseButtonDownHdl.Call( (MouseEvent*) &rMEvt); + { + Point aPoint = rMEvt.GetPosPixel(); + if(m_rTableControl.getCurrentRow(aPoint) >= 0) + m_aSelectHdl.Call( NULL ); + } m_rTableControl.getAntiImpl().LoseFocus(); } void TableDataWindow::MouseButtonUp( const MouseEvent& rMEvt ) { if ( !m_rTableControl.getInputHandler()->MouseButtonUp( m_rTableControl, rMEvt ) ) Window::MouseButtonUp( rMEvt ); - else - m_aMouseButtonUpHdl.Call( (MouseEvent*) &rMEvt); m_rTableControl.getAntiImpl().GetFocus(); } void TableDataWindow::SetPointer( const Pointer& rPointer ) diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index ce04078687b1..4cad623ff3a0 100755 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -50,6 +50,7 @@ #include #include #include +#include using ::rtl::OUString; using namespace ::svt::table; @@ -70,7 +71,10 @@ SVTXGridControl::SVTXGridControl() m_bHasColumnHeaders(false), m_bHasRowHeaders(false), m_bVScroll(false), - m_bHScroll(false) + m_bHScroll(false), + m_bUpdate(false), + m_nSelectedRowCount(0), + m_aSelectionListeners( *this ) { } @@ -85,6 +89,7 @@ SVTXGridControl::~SVTXGridControl() ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridControl*, this ), SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridDataListener*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridColumnListener*, this ), SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); } @@ -113,12 +118,12 @@ void SAL_CALL SVTXGridControl::setToolTip(const ::com::sun::star::uno::Sequence< void SAL_CALL SVTXGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { - (void)listener; + m_aSelectionListeners.addInterface(listener); } void SAL_CALL SVTXGridControl::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { - (void) listener; + m_aSelectionListeners.removeInterface(listener); } void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const Any& aValue) throw(RuntimeException) @@ -126,6 +131,8 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An ::vos::OGuard aGuard( GetMutex() ); TableControl* pTable = (TableControl*)GetWindow(); + const StyleSettings& rStyleSettings = GetWindow()->GetSettings().GetStyleSettings(); + com::sun::star::awt::FontDescriptor& aFont = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); switch( GetPropertyId( PropertyName ) ) { @@ -205,7 +212,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } break; } - case BASEPROPERTY_BACKGROUNDCOLOR: + case BASEPROPERTY_GRID_ROW_BACKGROUND: { sal_Int32 colorBackground = 0x000000; if( aValue >>= colorBackground ) @@ -250,26 +257,6 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_GRID_DATAMODEL: { - //m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY ); - //Sequence > cellData = m_xDataModel->getData(); - //Sequence rowData(0); - //std::vector< std::vector< Window* > > aCellContent(0); - //for(int i = 0; i< m_xDataModel->getRowCount();++i) - //{ - // rowData = cellData[i]; - // std::vector newRow( - // comphelper::sequenceToContainer< std::vector >(rowData)); - // if(newRow.size() < (unsigned)m_pTableModel->getColumnCount()) - // newRow.resize( m_pTableModel->getColumnCount(),rtl::OUString::createFromAscii("")); - // aCellContent.push_back(newRow); - //} - //m_pTableModel->setCellContent(aCellContent); - //Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); - //std::vector< rtl::OUString > newRow( - // comphelper::sequenceToContainer< std::vector >(rowHeaders)); - //m_pTableModel->setRowCount(m_xDataModel->getRowCount()); - //m_pTableModel->setRowHeaderName(newRow); - //break; { m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY ); if(m_xDataModel != NULL) @@ -308,12 +295,16 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An comphelper::sequenceToContainer< std::vector >(rowHeaders)); m_pTableModel->setRowCount(m_xDataModel->getRowCount()); m_pTableModel->setRowHeaderName(newRow); - m_pTableModel->setRowHeight(m_xDataModel->getRowHeight()); - m_pTableModel->setRowHeaderWidth(m_xDataModel->getRowHeaderWidth()); } } else throw GridInvalidDataException(rtl::OUString::createFromAscii("The data model isn't set!"), m_xDataModel); + sal_Int32 fontHeight = aFont.Height+8; + if(m_xDataModel->getRowHeight() == 0) + m_pTableModel->setRowHeight(fontHeight); + else + m_pTableModel->setRowHeight(m_xDataModel->getRowHeight()); + m_pTableModel->setRowHeaderWidth(m_xDataModel->getRowHeaderWidth()); } break; } @@ -327,7 +318,11 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An Sequence > columns = m_xColumnModel->getColumns(); std::vector > aNewColumns( comphelper::sequenceToContainer > >(columns)); - m_pTableModel->setColumnHeaderHeight(m_xColumnModel->getColumnHeaderHeight()); + sal_Int32 fontHeight = aFont.Height+8; + if(m_xColumnModel->getColumnHeaderHeight() == 0) + m_pTableModel->setColumnHeaderHeight(fontHeight); + else + m_pTableModel->setColumnHeaderHeight(m_xColumnModel->getColumnHeaderHeight()); for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) { UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]); @@ -405,6 +400,7 @@ void SVTXGridControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND, BASEPROPERTY_GRID_HEADER_BACKGROUND, BASEPROPERTY_GRID_LINE_COLOR, + BASEPROPERTY_GRID_ROW_BACKGROUND, 0); VCLXWindow::ImplGetPropertyIds( rIds, true ); } @@ -415,17 +411,6 @@ void SAL_CALL SVTXGridControl::setVisible( sal_Bool bVisible ) throw(::com::sun: { pTable->SetModel(PTableModel(m_pTableModel)); pTable->Show( bVisible ); - if(m_xColumnModel != NULL) - { - for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) - { - //set the new widths, which are computed to fill the width of grid, back to uno awt gridcolumn - //so funktioniert es nicht!!! Die Toolkit Klassen müssen notifiziert werden, sonst kommt es nicht an - //herausfinden wie es gehen soll! - m_xColumnModel->getColumn(col)->setColumnWidth(m_pTableModel->getColumnModel()[col]->getWidth()); - } - } - //TO DO: notify uno awt GridModel about hor. /vert. scrollbars } } void SAL_CALL SVTXGridControl::setFocus() throw(::com::sun::star::uno::RuntimeException) @@ -438,49 +423,30 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD { std::vector< Any > newRow; Sequence< Any > rawRowData = Event.rowData; - if(m_xColumnModel->getColumnCount() == 0) + int colCount = m_xColumnModel->getColumnCount(); + if(colCount == 0) { + Reference listener(*this,UNO_QUERY_THROW); + m_xColumnModel->setDefaultColumns(rawRowData.getLength()); for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col ) { UnoControlTableColumn* tableColumn = new UnoControlTableColumn(); m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); + m_xColumnModel->getColumn(col)->addColumnListener(listener); } - m_xColumnModel->setDefaultColumns(rawRowData.getLength()); + } - else if((unsigned int)rawRowData.getLength()!=(unsigned)m_xColumnModel->getColumnCount()) + else if((unsigned int)rawRowData.getLength()!=(unsigned)colCount) throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel); + for ( int k = 0; k < rawRowData.getLength(); k++) - { - ::rtl::OUString xCellType; - ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic> xGraphic; - /*if(xCellType.CellControl!= NULL) - { - xCellType.CellControl->createPeer( getToolkit(), this); - Window* pVclPeer = VCLUnoHelper::GetWindow( xCellType.CellControl->getPeer() ); - xTableCellType->pWindow = pVclPeer; - xTableCellType->pWindow->Hide(); - newRow.push_back(xTableCellType); - } - else - {*/ newRow.push_back(rawRowData[k]); - //} - } m_pTableModel->getCellContent().push_back(newRow); if(m_pTableModel->hasRowHeaders()) m_pTableModel->getRowHeaderName().push_back(Event.headerName); m_pTableModel->setRowCount(m_pTableModel->getCellContent().size()); - //if(m_pTableModel->hasVerticalScrollbar()) - m_bVScroll = m_pTableModel->hasVerticalScrollbar(); - com::sun::star::uno::Any aAny; - aAny <<= m_bVScroll; - setProperty(rtl::OUString::createFromAscii("VScroll"),aAny); - //Reference < XGridControl >( getPeer(), UNO_QUERY_THROW )->ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VSCROLL ), aAny, sal_True ); - - - m_bHScroll = m_pTableModel->hasHorizontalScrollbar(); TableControl* pTable = (TableControl*)GetWindow(); - pTable->InvalidateDataWindow(m_pTableModel->getCellContent().size()-1, false); + pTable->InvalidateDataWindow(m_pTableModel->getCellContent().size()-1, 0, false); if(pTable->isAccessibleAlive()) { pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, @@ -501,93 +467,79 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { - //TableControl* pTable = (TableControl*)GetWindow(); - ////unsigned int rows =m_pImpl->aCellContent.size()-1; - //if(Event.index == -1) - //{ - // if(m_pTableModel->hasRowHeaders()) - // m_pTableModel->getRowHeaderName().clear(); - // m_pTableModel->getCellContent().clear(); - // if(pTable->isAccessibleAlive()) - // { - // pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, - // makeAny( AccessibleTableModelChange(DELETE, 0, m_pTableModel->getColumnCount(), 0, m_pTableModel->getColumnCount())), - // Any()); - // } - //} - //else - //{ - // pTable->removeSelectedRow(Event.index); - // if(m_pTableModel->getCellContent().size()>1) - // { - // if(m_pTableModel->hasRowHeaders()) - // m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index); - // m_pTableModel->getCellContent().erase(m_pTableModel->getCellContent().begin()+Event.index); - // - // } - // else - // { - // if(m_pTableModel->hasRowHeaders()) - // m_pTableModel->getRowHeaderName().clear(); - // m_pTableModel->getCellContent().clear(); - // //m_pImpl->nRowCount=0; - // } - //} - ////pTable->InvalidateDataWindow(Event.index, true); - //m_pTableModel->setRowCount(m_pTableModel->getCellContent().size()); - //pTable->InvalidateDataWindow(Event.index, true); TableControl* pTable = (TableControl*)GetWindow(); if(Event.index == -1) { if(m_pTableModel->hasRowHeaders()) m_pTableModel->getRowHeaderName().clear(); - //::std::vector >::iterator iter = m_pTableModel->getCellContent().begin(); - //for(;iter!=m_pTableModel->getCellContent().end();++iter) - //{ - // std::vector vectIn = *iter; - // std::vector::iterator iterIn = vectIn.begin(); - // for(;iterIn!=vectIn.end();++iterIn) - // DELETEZ(*iterIn); - //} m_pTableModel->getCellContent().clear(); } else if(Event.index >= 0 && Event.index < m_pTableModel->getRowCount()) { - pTable->removeSelectedRow(Event.index); + pTable->RemoveSelectedRow(Event.index); if(m_pTableModel->hasRowHeaders()) m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index); std::vector >::iterator rowPos =m_pTableModel->getCellContent().begin() + Event.index; - //for ( std::vector::iterator iterIn = rowPos->begin(); - // iterIn != rowPos->end(); - // ++iterIn - // ) - //{ - // DELETEZ(*iterIn); - //} m_pTableModel->getCellContent().erase( rowPos ); } m_pTableModel->setRowCount(m_pTableModel->getCellContent().size()); - pTable->InvalidateDataWindow(Event.index, true); + pTable->InvalidateDataWindow(Event.index, Event.index, true); if(pTable->isAccessibleAlive()) { pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, makeAny( AccessibleTableModelChange(DELETE, Event.index, Event.index+1, 0, m_pTableModel->getColumnCount())), Any()); - //pTable->commitGridControlEvent(CHILD, - // makeAny( pTable->m_pAccessTable->m_pAccessible->getTableHeader(TCTYPE_ROWHEADERBAR)), - // Any()); - //for (sal_Int32 i = 0 ; i <= m_pTableModel->getColumnCount() ; ++i) - //{ - // pTable->commitGridControlEvent( - // CHILD, - // makeAny( pTable->m_pAccessTable->m_pAccessible->getTable() ), - // Any()); - //} } - //pTable->Invalidate(); } +void SAL_CALL SVTXGridControl::columnChanged(const ::com::sun::star::awt::grid::GridColumnEvent& Event ) throw (::com::sun::star::uno::RuntimeException) +{ + TableControl* pTable = (TableControl*)GetWindow(); + if(Event.valueName == rtl::OUString::createFromAscii("ColumnResize")) + { + bool resizable = m_pTableModel->getColumnModel()[Event.index]->isResizable(); + Event.newValue>>=resizable; + m_pTableModel->getColumnModel()[Event.index]->setResizable(resizable); + } + else if(Event.valueName == rtl::OUString::createFromAscii("ColWidth")) + { + sal_Int32 colWidth = m_pTableModel->getColumnModel()[Event.index]->getWidth(); + Event.newValue>>=colWidth; + m_pTableModel->getColumnModel()[Event.index]->setWidth(colWidth); + } + else if(Event.valueName == rtl::OUString::createFromAscii("MaxWidth")) + { + sal_Int32 maxWidth = m_pTableModel->getColumnModel()[Event.index]->getMaxWidth(); + Event.newValue>>=maxWidth; + m_pTableModel->getColumnModel()[Event.index]->setMaxWidth(maxWidth); + } + else if(Event.valueName == rtl::OUString::createFromAscii("MinWidth")) + { + sal_Int32 minWidth = m_pTableModel->getColumnModel()[Event.index]->getMinWidth(); + Event.newValue>>=minWidth; + m_pTableModel->getColumnModel()[Event.index]->setMinWidth(minWidth); + } + else if(Event.valueName == rtl::OUString::createFromAscii("PrefWidth")) + { + sal_Int32 prefWidth = m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth(); + Event.newValue>>=prefWidth; + m_pTableModel->getColumnModel()[Event.index]->setPreferredWidth(prefWidth); + } + else if(Event.valueName == rtl::OUString::createFromAscii("HAlign")) + { + ::com::sun::star::style::HorizontalAlignment hAlign = m_pTableModel->getColumnModel()[Event.index]->getHorizontalAlign(); + Event.newValue>>=hAlign; + m_pTableModel->getColumnModel()[Event.index]->setHorizontalAlign(hAlign); + } + else if(Event.valueName == rtl::OUString::createFromAscii("UpdateWidth")) + { + if(m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth() != 0) + m_xColumnModel->getColumn(Event.index)->updateColumn(rtl::OUString::createFromAscii("PrefWidth"), m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth()); + m_xColumnModel->getColumn(Event.index)->updateColumn(rtl::OUString::createFromAscii("ColWidth"), m_pTableModel->getColumnModel()[Event.index]->getWidth()); + } + pTable->Invalidate(); +} void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { (void) Event; @@ -600,24 +552,91 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::G ::sal_Int32 SAL_CALL SVTXGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { - return 0; + TableControl* pTable = (TableControl*)GetWindow(); + std::vector& selectedRows = pTable->GetSelectedRows(); + if(selectedRows.empty()) + return -1; + else + { + std::vector::iterator itStart = selectedRows.begin(); + std::vector::iterator itEnd = selectedRows.end(); + return *(std::min_element(itStart, itEnd)); + } } ::sal_Int32 SAL_CALL SVTXGridControl::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { - return 0; + TableControl* pTable = (TableControl*)GetWindow(); + std::vector& selectedRows = pTable->GetSelectedRows(); + if(selectedRows.empty()) + return -1; + else + { + std::vector::iterator itStart = selectedRows.begin(); + std::vector::iterator itEnd = selectedRows.end(); + return *(std::max_element(itStart, itEnd)); + } } -void SAL_CALL SVTXGridControl::insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL SVTXGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) { - (void)length; - (void)start; + TableControl* pTable = (TableControl*)GetWindow(); + std::vector& selectedRows = pTable->GetSelectedRows(); + if(!selectedRows.empty()) + selectedRows.clear(); + sal_Int32 start = rangeOfRows[0]; + int seqSize = rangeOfRows.getLength(); + sal_Int32 end = rangeOfRows[seqSize-1]; + for(int i=0;iselectionChanged(true); + pTable->InvalidateDataWindow(start, end, false); + SetSynthesizingVCLEvent( sal_True ); + pTable->Select(); + SetSynthesizingVCLEvent( sal_False ); + } -void SAL_CALL SVTXGridControl::removeIndexIntervall(::sal_Int32 start, ::sal_Int32 end) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException) { - (void)end; - (void)start; + TableControl* pTable = (TableControl*)GetWindow(); + std::vector& selectedRows = pTable->GetSelectedRows(); + if(!selectedRows.empty()) + selectedRows.clear(); + for(int i=0;igetRowCount();i++) + selectedRows.push_back(i); + pTable->Invalidate(); + SetSynthesizingVCLEvent( sal_True ); + pTable->Select(); + SetSynthesizingVCLEvent( sal_False ); +} +void SAL_CALL SVTXGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) +{ + TableControl* pTable = (TableControl*)GetWindow(); + std::vector& selectedRows = pTable->GetSelectedRows(); + std::vector::iterator itStart = selectedRows.begin(); + std::vector::iterator itEnd = selectedRows.end(); + sal_Int32 start = rangeOfRows[0]; + sal_Int32 end = rangeOfRows[rangeOfRows.getLength()-1]; + std::vector::iterator iter = std::find(itStart, itEnd, start); + selectedRows.erase(iter, iter+(end-start)+1); + pTable->selectionChanged(true); + pTable->InvalidateDataWindow(start, end, false); + SetSynthesizingVCLEvent( sal_True ); + pTable->Select(); + SetSynthesizingVCLEvent( sal_False ); +} + +void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException) +{ + TableControl* pTable = (TableControl*)GetWindow(); + std::vector& selectedRows = pTable->GetSelectedRows(); + if(!selectedRows.empty()) + selectedRows.clear(); + pTable->Invalidate(); + SetSynthesizingVCLEvent( sal_True ); + pTable->Select(); + SetSynthesizingVCLEvent( sal_False ); } ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL SVTXGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) @@ -635,21 +654,125 @@ void SAL_CALL SVTXGridControl::removeIndexIntervall(::sal_Int32 start, ::sal_Int ::sal_Bool SAL_CALL SVTXGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) { - return sal_False; + TableControl* pTable = (TableControl*)GetWindow(); + std::vector& selectedRows = pTable->GetSelectedRows(); + if(selectedRows.empty()) + return sal_True; + else + return sal_False; } ::sal_Bool SAL_CALL SVTXGridControl::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) { - (void)index; - return sal_False; + TableControl* pTable = (TableControl*)GetWindow(); + std::vector& selectedRows = pTable->GetSelectedRows(); + ::std::vector::iterator iter = selectedRows.begin(); + sal_Bool bSelected = sal_False; + for(;iter!=selectedRows.end();iter++) + { + if(*iter == index) + bSelected = sal_True; + } + return bSelected; } -void SAL_CALL SVTXGridControl::selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL SVTXGridControl::selectRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) { - (void)y; + if(index<0 || index>=m_pTableModel->getRowCount()) + return; + TableControl* pTable = (TableControl*)GetWindow(); + std::vector& selectedRows = pTable->GetSelectedRows(); + if(!isSelectedIndex(index)) + selectedRows.push_back(index); + pTable->selectionChanged(true); + pTable->InvalidateDataWindow(index, index, false); + SetSynthesizingVCLEvent( sal_True ); + pTable->Select(); + SetSynthesizingVCLEvent( sal_False ); } void SAL_CALL SVTXGridControl::selectColumn(::sal_Int32 x) throw (::com::sun::star::uno::RuntimeException) { (void)x; } +void SVTXGridControl::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aObj; + aObj.Source = (::cppu::OWeakObject*)this; + m_aSelectionListeners.disposeAndClear( aObj ); + VCLXWindow::dispose(); +} + +void SVTXGridControl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + + switch ( rVclWindowEvent.GetId() ) + { + case VCLEVENT_TABLEROW_SELECT: + { + TableControl* pTable = (TableControl*)GetWindow(); + + if( pTable ) + { + if ( m_aSelectionListeners.getLength() ) + { + ImplCallItemListeners(); + } + } + } + break; + + default: + VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +void SVTXGridControl::ImplCallItemListeners() +{ + TableControl* pTable = (TableControl*) GetWindow(); + if ( pTable && m_aSelectionListeners.getLength() ) + { + ::std::vector selRows = pTable->GetSelectedRows(); + ::com::sun::star::awt::grid::GridSelectionEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.Column = 0; + sal_Int32 actSelRowCount = selRows.size(); + sal_Int32 diff = actSelRowCount - m_nSelectedRowCount; + //row added to selection + if(diff >= 1) + { + aEvent.Action = com::sun::star::awt::grid::SelectionEventType(0); + aEvent.Row = selRows[actSelRowCount-1]; + aEvent.Range = diff; + } + //selected row changed + else if(diff == 0) + { + aEvent.Row = selRows[actSelRowCount-1]; + aEvent.Action = com::sun::star::awt::grid::SelectionEventType(2); + aEvent.Range = 0; + } + else + { + //selection changed: multiple row deselected, only 1 row is selected + if(actSelRowCount == 1) + { + aEvent.Row = selRows[actSelRowCount-1]; + aEvent.Action = com::sun::star::awt::grid::SelectionEventType(2); + } + //row is deselected + else + { + aEvent.Row = pTable->GetCurrentRow(); + aEvent.Action = com::sun::star::awt::grid::SelectionEventType(1); + } + aEvent.Range = 0; + } + m_nSelectedRowCount=actSelRowCount; + m_aSelectionListeners.selectionChanged( aEvent ); + } +} diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index c8b8af574a61..cd4dc698f8db 100755 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -35,21 +35,23 @@ #include #include #include +#include #include +#include #include #include #include #include #include #include -#include -//#include +#include +#include using namespace ::svt::table; -class SVTXGridControl : public ::cppu::ImplInheritanceHelper2< VCLXWindow, ::com::sun::star::awt::grid::XGridControl, - ::com::sun::star::awt::grid::XGridDataListener> +class SVTXGridControl : public ::cppu::ImplInheritanceHelper3< VCLXWindow, ::com::sun::star::awt::grid::XGridControl, + ::com::sun::star::awt::grid::XGridDataListener, ::com::sun::star::awt::grid::XGridColumnListener> { private: UnoControlTableModel* m_pTableModel; @@ -59,6 +61,13 @@ private: bool m_bHasRowHeaders; bool m_bVScroll; bool m_bHScroll; + bool m_bUpdate; + sal_Int32 m_nSelectedRowCount; + SelectionListenerMultiplexer m_aSelectionListeners; + +protected: + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); + void ImplCallItemListeners(); public: SVTXGridControl(); @@ -67,6 +76,12 @@ public: virtual void SAL_CALL rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL dataChanged(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException); + + //XGridColumnListener overridables + //virtual void SAL_CALL columnAdded(const ::com::sun::star::awt::grid::GridColumnEvent& Event) throw (::com::sun::star::uno::RuntimeException); + //virtual void SAL_CALL columnRemoved(const ::com::sun::star::awt::grid::GridColumnEvent & Event) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL columnChanged(const ::com::sun::star::awt::grid::GridColumnEvent & Event) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); @@ -80,8 +95,10 @@ public: //::com::sun::star::awt::grid::XGridControl virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeIndexIntervall(::sal_Int32 start, ::sal_Int32 end) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deselectAllRows() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelection() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isCellEditable() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException); @@ -98,6 +115,8 @@ public: static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); void SAL_CALL setVisible(sal_Bool bVisible) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL setFocus() throw(::com::sun::star::uno::RuntimeException); - ::rtl::OUString impl_convertToString(::com::sun::star::uno::Any _value); + + // ::com::sun::star::lang::XComponent + void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); }; #endif // _SVT_GRIDCONTROL_HXX_ diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index d1eaee98e7bb..2b53b65de471 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -70,6 +70,7 @@ using namespace ::com::sun::star::uno; ,m_nWidth( 4 ) ,m_nMinWidth( 0 ) // no min width ,m_nMaxWidth( 0 ) // no max width + ,m_nPrefWidth ( 0 ) ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0)) { } @@ -83,11 +84,7 @@ using namespace ::com::sun::star::uno; //-------------------------------------------------------------------- bool UnoControlTableColumn::setID( const ColumnID _nID ) { - // TODO: conflict check - m_nID = _nID; - // TODO: notifications? - return true; } @@ -101,7 +98,6 @@ using namespace ::com::sun::star::uno; void UnoControlTableColumn::setName( const String& _rName ) { m_sName = _rName; - // TODO: notifications? } //-------------------------------------------------------------------- bool UnoControlTableColumn::isResizable() const @@ -113,7 +109,6 @@ using namespace ::com::sun::star::uno; void UnoControlTableColumn::setResizable( bool _bResizable ) { m_bIsResizable = _bResizable; - // TODO: notifications? } //-------------------------------------------------------------------- @@ -126,7 +121,6 @@ using namespace ::com::sun::star::uno; void UnoControlTableColumn::setWidth( TableMetrics _nWidth ) { m_nWidth = _nWidth; - // TODO: notifications? } //-------------------------------------------------------------------- @@ -139,7 +133,6 @@ using namespace ::com::sun::star::uno; void UnoControlTableColumn::setMinWidth( TableMetrics _nMinWidth ) { m_nMinWidth = _nMinWidth; - // TODO: notifications? } //-------------------------------------------------------------------- @@ -152,7 +145,6 @@ using namespace ::com::sun::star::uno; void UnoControlTableColumn::setMaxWidth( TableMetrics _nMaxWidth ) { m_nMaxWidth = _nMaxWidth; - // TODO: notifications? } //-------------------------------------------------------------------- TableMetrics UnoControlTableColumn::getPreferredWidth() const @@ -164,7 +156,6 @@ using namespace ::com::sun::star::uno; void UnoControlTableColumn::setPreferredWidth( TableMetrics _nPrefWidth ) { m_nPrefWidth = _nPrefWidth; - // TODO: notifications? } //-------------------------------------------------------------------- ::com::sun::star::style::HorizontalAlignment UnoControlTableColumn::getHorizontalAlign() @@ -195,7 +186,6 @@ using namespace ::com::sun::star::uno; TableMetrics nColumnHeaderHeight; TableMetrics nRowHeaderWidth; std::vector& aRowHeadersTitle; - //std::vector >& aCellContent; std::vector >& aCellContent; ::com::sun::star::util::Color m_xLineColor; ::com::sun::star::util::Color m_xHeaderColor; @@ -213,11 +203,10 @@ using namespace ::com::sun::star::uno; ,bHScroll ( false ) ,pRenderer ( ) ,pInputHandler ( ) - ,nRowHeight ( 15 ) // 40 mm - ,nColumnHeaderHeight( 10 ) // 50 mm - ,nRowHeaderWidth ( 10 ) // 50 mm + ,nRowHeight ( 0 ) + ,nColumnHeaderHeight( 0 ) + ,nRowHeaderWidth ( 10 ) ,aRowHeadersTitle ( *(new std::vector(0))) - //,aCellContent ( *(new std::vector >(0))) ,aCellContent ( *(new std::vector >(0)) ) ,m_xLineColor( 0xFFFFFF ) ,m_xHeaderColor( 0xFFFFFF ) @@ -245,24 +234,12 @@ using namespace ::com::sun::star::uno; //-------------------------------------------------------------------- UnoControlTableModel::~UnoControlTableModel() { - //if(!m_pImpl->aCellContent.empty()) - //{ - // ::std::vector >::iterator iter = m_pImpl->aCellContent.begin(); - // for(;iter!=m_pImpl->aCellContent.end();++iter) - // { - // std::vector vectIn = *iter; - // std::vector::iterator iterIn = vectIn.begin(); - // for(;iterIn!=vectIn.end();++iterIn) - // DELETEZ(*iterIn); - // } - //} DELETEZ( m_pImpl ); } //-------------------------------------------------------------------- TableSize UnoControlTableModel::getColumnCount() const { - //m_pImpl->aColumns.resize( m_xColumnModel->getColumnCount()); return (TableSize)m_pImpl->aColumns.size(); } @@ -454,54 +431,9 @@ using namespace ::com::sun::star::uno; return m_pImpl->bHScroll; } //-------------------------------------------------------------------- - // void UnoControlTableModel::setCellContent(std::vector > cellContent) - // { - // //if(cellContent.empty()) - // //{ - // // unsigned int i = m_pImpl->aColumns.size(); - // // std::vector& emptyCells; - // // while(i!=0) - // // { - // // cellContent.push_back(emptyCells); - // // --i; - // // } - // //} - // //std::vector cCC; - // //for(::std::vector >::iterator iter = cellContent.begin(); iter!= cellContent.end();++iter) - // //{ - // // cCC = *iter; - // // m_pImpl->aCellContent.push_back(cCC); - // //} - // m_pImpl->aCellContent.swap( cellContent ); - // } - - //std::vector >& UnoControlTableModel::getCellContent() - // { - // return m_pImpl->aCellContent; - // } - //-------------------------------------------------------------------- void UnoControlTableModel::setCellContent(std::vector > cellContent) { - //::vos::OGuard aGuard( GetMutex() ); - /* - if(cellContent.empty()) - { - unsigned int i = m_pImpl->aColumns.size(); - std::vector emptyCells; - while(i!=0) - { - cellContent.push_back(emptyCells); - --i; - } - } - */ - - m_pImpl->aCellContent.swap( cellContent ); - - /*for(::std::vector >::iterator iter = cellContent.begin(); iter!= cellContent.end();++iter) - { - m_pImpl->aCellContent.push_back(*iter); - }*/ + m_pImpl->aCellContent = cellContent; } std::vector >& UnoControlTableModel::getCellContent() @@ -512,20 +444,7 @@ using namespace ::com::sun::star::uno; //-------------------------------------------------------------------- void UnoControlTableModel::setRowHeaderName(std::vector cellColumnContent) { - if(cellColumnContent.empty()) - { - unsigned int i = m_pImpl->aColumns.size(); - while(i!=0) - { - cellColumnContent.push_back(rtl::OUString::createFromAscii("")); - --i; - } - } - for(::std::vector::iterator iter = cellColumnContent.begin(); iter!= cellColumnContent.end();++iter) - { - rtl::OUString s = *iter; - m_pImpl->aRowHeadersTitle.push_back(*iter); - } + m_pImpl->aRowHeadersTitle = cellColumnContent; } std::vector& UnoControlTableModel::getRowHeaderName() diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index cff18f4d9be2..ae0a5ce76a9e 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -47,7 +47,6 @@ #include #include #include -//#include using namespace ::svt::table; @@ -55,7 +54,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt::grid; class UnoControlTableColumn : public IColumnModel - { +{ private: ColumnID m_nID; String m_sName; @@ -124,8 +123,6 @@ class UnoControlTableColumn : public IColumnModel /// retrieves the width of a column, in 1/100th millimeters inline TableMetrics GetColumnWidth( ColPos _nColumn ); - // TODO: setters and getters for ID, Name, Resizable, MinWidth, MaxWidth - public: // ITableModel overridables virtual TableSize getColumnCount() const; diff --git a/toolkit/inc/toolkit/helper/listenermultiplexer.hxx b/toolkit/inc/toolkit/helper/listenermultiplexer.hxx index 543c8a85c401..0c1c5b631fee 100644 --- a/toolkit/inc/toolkit/helper/listenermultiplexer.hxx +++ b/toolkit/inc/toolkit/helper/listenermultiplexer.hxx @@ -57,7 +57,7 @@ #include #include #include - +#include // ---------------------------------------------------- // class ListenerMultiplexerBase // ---------------------------------------------------- @@ -247,8 +247,12 @@ DECL_LISTENERMULTIPLEXER_START_DLLPUB( TreeEditListenerMultiplexer, ::com::sun:: virtual void SAL_CALL nodeEdited( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node, const ::rtl::OUString& NewText ) throw (::com::sun::star::uno::RuntimeException); DECL_LISTENERMULTIPLEXER_END - - +// ---------------------------------------------------- +// class SelectionListenerMultiplexer +// ---------------------------------------------------- +DECL_LISTENERMULTIPLEXER_START_DLLPUB( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener ) + void SAL_CALL selectionChanged( const ::com::sun::star::awt::grid::GridSelectionEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); +DECL_LISTENERMULTIPLEXER_END #endif // _TOOLKIT_HELPER_LISTENERMULTIPLEXER_HXX_ diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index 6fa223cc7b26..cbc0dd05248c 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -201,6 +201,7 @@ namespace rtl { #define BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND 147 #define BASEPROPERTY_GRID_HEADER_BACKGROUND 148 #define BASEPROPERTY_GRID_LINE_COLOR 149 +#define BASEPROPERTY_GRID_ROW_BACKGROUND 150 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen. diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 337076bdfaa9..f68239f9712c 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -33,6 +33,7 @@ #include "defaultgridcolumnmodel.hxx" #include #include +#include #include using ::rtl::OUString; @@ -42,7 +43,8 @@ using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::style; -#define COLUMNSELECTIONALLOWED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnSelectionAllowed" )) +//#define COLUMNSELECTIONALLOWED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnSelectionAllowed" )) +//#define COLUMNRESIZED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnResized" )) namespace toolkit { @@ -53,7 +55,7 @@ namespace toolkit DefaultGridColumnModel::DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory) : columns(std::vector< Reference< XGridColumn > >()) - ,m_nColumnHeaderHeight(10) + ,m_nColumnHeaderHeight(0) ,m_xFactory(xFactory) { } @@ -66,68 +68,68 @@ DefaultGridColumnModel::~DefaultGridColumnModel() //--------------------------------------------------------------------- -void DefaultGridColumnModel::broadcast( broadcast_type eType, const GridColumnEvent& aEvent ) -{ - ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() ); - if( pIter ) - { - ::cppu::OInterfaceIteratorHelper aListIter(*pIter); - while(aListIter.hasMoreElements()) - { - XGridColumnListener* pListener = static_cast(aListIter.next()); - switch( eType ) - { - case column_added: pListener->columnAdded(aEvent); break; - case column_removed: pListener->columnRemoved(aEvent); break; - case column_changed: pListener->columnChanged(aEvent); break; - } - } - } -} - -//--------------------------------------------------------------------- - -void DefaultGridColumnModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue ) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridColumnEvent aEvent( xSource, name, oldValue, newValue, 0, NULL ); - broadcast( column_changed, aEvent); -} - -//--------------------------------------------------------------------- - -void DefaultGridColumnModel::broadcast_add( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn ); - broadcast( column_added, aEvent); -} - -//--------------------------------------------------------------------- - -void DefaultGridColumnModel::broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn ); - broadcast( column_removed, aEvent); -} +//void DefaultGridColumnModel::broadcast( broadcast_type eType, const GridColumnEvent& aEvent ) +//{ +// ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() ); +// if( pIter ) +// { +// ::cppu::OInterfaceIteratorHelper aListIter(*pIter); +// while(aListIter.hasMoreElements()) +// { +// XGridColumnListener* pListener = static_cast(aListIter.next()); +// switch( eType ) +// { +// case column_added: pListener->columnAdded(aEvent); break; +// case column_removed: pListener->columnRemoved(aEvent); break; +// case column_changed: pListener->columnChanged(aEvent); break; +// } +// } +// } +//} +// +////--------------------------------------------------------------------- +// +//void DefaultGridColumnModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue) +//{ +// Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); +// GridColumnEvent aEvent( xSource, name, oldValue, newValue, 0, NULL ); +// broadcast( column_changed, aEvent); +//} +// +////--------------------------------------------------------------------- +// +//void DefaultGridColumnModel::broadcast_add( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ) +//{ +// Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); +// GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn ); +// broadcast( column_added, aEvent); +//} +// +////--------------------------------------------------------------------- +// +//void DefaultGridColumnModel::broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ) +//{ +// Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); +// GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn ); +// broadcast( column_removed, aEvent); +//} //--------------------------------------------------------------------- // XDefaultGridColumnModel //--------------------------------------------------------------------- -::sal_Bool SAL_CALL DefaultGridColumnModel::getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException) -{ - return selectionAllowed; -} - -//--------------------------------------------------------------------- - -void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value) throw (::com::sun::star::uno::RuntimeException) -{ - sal_Bool oldValue = selectionAllowed; - selectionAllowed = value; - broadcast_changed( COLUMNSELECTIONALLOWED, Any(oldValue) , Any(selectionAllowed)); -} +//::sal_Bool SAL_CALL DefaultGridColumnModel::getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException) +//{ +// return selectionAllowed; +//} +// +////--------------------------------------------------------------------- +// +//void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value) throw (::com::sun::star::uno::RuntimeException) +//{ +// sal_Bool oldValue = selectionAllowed; +// selectionAllowed = value; +// broadcast_changed( COLUMNSELECTIONALLOWED, Any(oldValue) , Any(selectionAllowed)); +//} //--------------------------------------------------------------------- @@ -141,10 +143,10 @@ void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value ::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException) { ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - - columns.push_back(column); + Reference xColumn(column); + columns.push_back(xColumn); sal_Int32 index = columns.size() - 1; - broadcast_add(index, column ); + xColumn->setIndex(index); return index; } @@ -160,22 +162,24 @@ void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) { if ( index >=0 && index < ((sal_Int32)columns.size())) + { return columns[index]; + } else return Reference< XGridColumn >(); } //--------------------------------------------------------------------- -void SAL_CALL DefaultGridColumnModel::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener ); -} - -//--------------------------------------------------------------------- - -void SAL_CALL DefaultGridColumnModel::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener ); -} +//void SAL_CALL DefaultGridColumnModel::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) +//{ +// BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener ); +//} +// +////--------------------------------------------------------------------- +// +//void SAL_CALL DefaultGridColumnModel::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) +//{ +// BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener ); +//} //--------------------------------------------------------------------- void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) @@ -193,9 +197,25 @@ void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) t { ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - Reference xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY ); for(sal_Int32 i=0;i xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY ); columns.push_back(xColumn); + xColumn->setIndex(i); + } +} +::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException) +{ + Reference xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY ); + xColumn->setColumnWidth(column->getColumnWidth()); + xColumn->setPreferredWidth(column->getPreferredWidth()); + xColumn->setMaxWidth(column->getMaxWidth()); + xColumn->setMinWidth(column->getMinWidth()); + xColumn->setPreferredWidth(column->getPreferredWidth()); + xColumn->setResizeable(column->getResizeable()); + xColumn->setTitle(column->getTitle()); + xColumn->setHorizontalAlign(column->getHorizontalAlign()); + return xColumn; } //--------------------------------------------------------------------- // XComponent diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx index d700a6b07b5d..bfa9892b3777 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx @@ -32,7 +32,7 @@ #include "precompiled_toolkit.hxx" #include #include -#include +//#include #include #include #include @@ -43,6 +43,7 @@ #include #include #include +#include using ::rtl::OUString; using namespace ::com::sun::star; @@ -54,7 +55,7 @@ using namespace ::com::sun::star::lang; namespace toolkit { -enum broadcast_type { column_added, column_removed, column_changed}; +//enum broadcast_type { column_added, column_removed, column_changed}; class DefaultGridColumnModel : public ::cppu::WeakImplHelper2< XGridColumnModel, XServiceInfo >, public MutexAndBroadcastHelper @@ -65,17 +66,18 @@ public: // XGridColumnModel - virtual ::sal_Bool SAL_CALL getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setColumnSelectionAllowed(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); + //virtual ::sal_Bool SAL_CALL getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException); + //virtual void SAL_CALL setColumnSelectionAllowed(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL getColumns() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); - virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); + //virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); + //virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL setColumnHeaderHeight( sal_Int32 _value) throw (com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getColumnHeaderHeight() throw (com::sun::star::uno::RuntimeException); virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException); // XComponent virtual void SAL_CALL dispose( ) throw (RuntimeException); virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); @@ -87,10 +89,10 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); private: - void broadcast( broadcast_type eType, const GridColumnEvent& aEvent ); - void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue ); + /*void broadcast( broadcast_type eType, const GridColumnEvent& aEvent ); + void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue, sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ); void broadcast_add( sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ); - void broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ); + void broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );*/ std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > columns; sal_Bool selectionAllowed; diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 2d695a9bad0a..528e0e17c3e0 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -35,9 +35,6 @@ #include #include -#include -#include - using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -57,9 +54,9 @@ namespace toolkit /////////////////////////////////////////////////////////////////////// DefaultGridDataModel::DefaultGridDataModel() -: rowHeight(10), +: rowHeight(0), rowHeaders(std::vector< ::rtl::OUString >()), - m_nRowHeaderWidth(7) + m_nRowHeaderWidth(10) { } diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 40c2018c4cc5..b367ee908f3a 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -43,6 +43,15 @@ using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::style; +#define COLWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColWidth" )) +#define MAXWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MaxWidth" )) +#define MINWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MinWidth" )) +#define PREFWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PrefWidth" )) +#define HALIGN ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "HAlign" )) +#define TITLE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Title" )) +#define COLRESIZE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnResize" )) +#define UPDATE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "UpdateWidth" )) + namespace toolkit { @@ -54,7 +63,9 @@ GridColumn::GridColumn() : identifier(Any()) ,horizontalAlign(HorizontalAlignment(0)) ,columnWidth(4) +,preferredWidth(0) ,bResizeable(true) +,index(0) { } @@ -66,6 +77,39 @@ GridColumn::~GridColumn() //--------------------------------------------------------------------- +void GridColumn::broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ) +{ + ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() ); + if( pIter ) + { + ::cppu::OInterfaceIteratorHelper aListIter(*pIter); + while(aListIter.hasMoreElements()) + { + XGridColumnListener* pListener = static_cast(aListIter.next()); + switch( eType ) + { + case column_attribute_changed: pListener->columnChanged(aEvent); break; + } + } + } +} + +//--------------------------------------------------------------------- + +void GridColumn::broadcast_changed(::rtl::OUString name, Any oldValue, Any newValue) +{ + Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + GridColumnEvent aEvent( xSource, name, oldValue, newValue, index); + broadcast( column_attribute_changed, aEvent); +} + +void SAL_CALL GridColumn::updateColumn(const ::rtl::OUString& name, sal_Int32 width) throw (::com::sun::star::uno::RuntimeException) +{ + if(PREFWIDTH == name) + preferredWidth = width; + else if (COLWIDTH == name) + columnWidth = width; +} //--------------------------------------------------------------------- // XGridColumn //--------------------------------------------------------------------- @@ -86,6 +130,7 @@ void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value ::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException) { + broadcast_changed(UPDATE, Any(columnWidth), Any()); return columnWidth; } @@ -94,11 +139,13 @@ void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { columnWidth = value; + broadcast_changed(COLWIDTH, Any(columnWidth),Any(value)); } //-------------------------------------------------------------------- ::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException) { + broadcast_changed(UPDATE, Any(preferredWidth), Any()); return preferredWidth; } @@ -107,6 +154,7 @@ void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::s void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { preferredWidth = value; + broadcast_changed(PREFWIDTH, Any(preferredWidth),Any(value)); } //-------------------------------------------------------------------- @@ -120,6 +168,7 @@ void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { maxWidth = value; + broadcast_changed(MAXWIDTH, Any(maxWidth),Any(value)); } //-------------------------------------------------------------------- @@ -133,6 +182,7 @@ void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { minWidth = value; + broadcast_changed(MINWIDTH, Any(minWidth),Any(value)); } //-------------------------------------------------------------------- @@ -147,6 +197,7 @@ void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException) { title = value; + broadcast_changed(TITLE, Any(title),Any(value)); } //-------------------------------------------------------------------- @@ -160,6 +211,7 @@ sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::Runt void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) { bResizeable = value; + broadcast_changed(COLRESIZE, Any(bResizeable),Any(value)); } //--------------------------------------------------------------------- HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) @@ -171,6 +223,19 @@ HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun: void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) { horizontalAlign = align; + broadcast_changed(HALIGN, Any(horizontalAlign),Any(align)); +} +//--------------------------------------------------------------------- +void SAL_CALL GridColumn::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) +{ + BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener ); +} + +//--------------------------------------------------------------------- + +void SAL_CALL GridColumn::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) +{ + BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener ); } //--------------------------------------------------------------------- @@ -179,22 +244,30 @@ void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (: void SAL_CALL GridColumn::dispose() throw (RuntimeException) { + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); + BrdcstHelper.aLC.disposeAndClear( aEvent ); } //--------------------------------------------------------------------- void SAL_CALL GridColumn::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) { - (void) xListener; + BrdcstHelper.addListener( XEventListener::static_type(), xListener ); } //--------------------------------------------------------------------- void SAL_CALL GridColumn::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) { - (void) xListener; + BrdcstHelper.removeListener( XEventListener::static_type(), xListener ); +} +void SAL_CALL GridColumn::setIndex(sal_Int32 _nIndex) throw (::com::sun::star::uno::RuntimeException) +{ + index = _nIndex; } - //--------------------------------------------------------------------- // XServiceInfo //--------------------------------------------------------------------- diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index a458a07ffda8..d7651a2e00ab 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -31,6 +31,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" #include +#include +#include #include #include #include @@ -51,6 +53,7 @@ using namespace ::com::sun::star::lang; namespace toolkit { +enum broadcast_column_type { column_attribute_changed}; class GridColumn : public ::cppu::WeakImplHelper2< XGridColumn, XServiceInfo >, public MutexAndBroadcastHelper { @@ -75,6 +78,9 @@ public: virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateColumn( const ::rtl::OUString& name, ::sal_Int32 width ) throw (::com::sun::star::uno::RuntimeException); // XComponent virtual void SAL_CALL dispose( ) throw (RuntimeException); virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); @@ -85,9 +91,13 @@ public: virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); - + virtual void SAL_CALL setIndex(sal_Int32 _nIndex)throw (::com::sun::star::uno::RuntimeException); private: + void broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ); + void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue); + Any identifier; + sal_Int32 index; sal_Int32 columnWidth; sal_Int32 preferredWidth; sal_Int32 maxWidth; diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index fa0c3de3adb3..b279ace0ef12 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -86,7 +86,7 @@ UnoGridModel::UnoGridModel() ImplRegisterProperty( BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND ); ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_BACKGROUND ); ImplRegisterProperty( BASEPROPERTY_GRID_LINE_COLOR ); - + ImplRegisterProperty( BASEPROPERTY_GRID_ROW_BACKGROUND ); } UnoGridModel::UnoGridModel( const UnoGridModel& rModel ) @@ -112,6 +112,22 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_GridControl ) ); case BASEPROPERTY_GRID_SELECTIONMODE: return uno::makeAny( SelectionType(1) ); + case BASEPROPERTY_GRID_SHOWROWHEADER: + return uno::makeAny( (sal_Bool)sal_False ); + case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: + return uno::makeAny( (sal_Bool)sal_False ); + case BASEPROPERTY_GRID_DATAMODEL: + return uno::makeAny( Reference ()); + case BASEPROPERTY_GRID_COLUMNMODEL: + return uno::makeAny(Reference() ); + case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND: + return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) ); + case BASEPROPERTY_GRID_HEADER_BACKGROUND: + return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) ); + case BASEPROPERTY_GRID_LINE_COLOR: + return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) ); + case BASEPROPERTY_GRID_ROW_BACKGROUND: + return uno::makeAny(com::sun::star::util::Color(0xFFFFFF) ); default: return UnoControlModel::ImplGetDefaultValue( nPropId ); } @@ -141,7 +157,8 @@ Reference< XPropertySetInfo > UnoGridModel::getPropertySetInfo( ) throw(Runtime // class UnoGridControl // ---------------------------------------------------- UnoGridControl::UnoGridControl() -: mSelectionMode(SelectionType(1)) +: mSelectionMode(SelectionType(1)), + m_aSelectionListeners( *this ) { } @@ -152,6 +169,9 @@ OUString UnoGridControl::GetComponentServiceName() void SAL_CALL UnoGridControl::dispose( ) throw(RuntimeException) { + lang::EventObject aEvt; + aEvt.Source = (::cppu::OWeakObject*)this; + m_aSelectionListeners.disposeAndClear( aEvt ); UnoControl::dispose(); } @@ -160,17 +180,23 @@ void UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolk UnoControlBase::createPeer( rxToolkit, rParentPeer ); Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW ); + xGrid->addSelectionListener(&m_aSelectionListeners); Reference xListener ( getPeer(), UNO_QUERY_THROW ); - //Reference xColListener ( getPeer(), UNO_QUERY_THROW ); + Reference xColListener ( getPeer(), UNO_QUERY_THROW ); Reference xPropSet ( getModel(), UNO_QUERY_THROW ); Reference xGridDataModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "GridDataModel" )), UNO_QUERY_THROW ); if(xGridDataModel != NULL) xGridDataModel->addDataListener(xListener); - //Reference xGridColumnModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "ColumnModel" )), UNO_QUERY_THROW ); - //if(xGridColumnModel != NULL) - // xGridColumnModel->addColumnListener(xColListener); + Reference xGridColumnModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "ColumnModel" )), UNO_QUERY_THROW ); + if(xGridColumnModel != NULL) + { + for(int i = 0;igetColumnCount();i++) + { + xGridColumnModel->getColumn(i)->addColumnListener(xColListener); + } + } } @@ -212,16 +238,24 @@ void SAL_CALL UnoGridControl::removeMouseListener(const ::com::sun::star::uno::R return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMaxSelectionIndex(); } -void SAL_CALL UnoGridControl::insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL UnoGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->insertIndexIntervall( start, length); + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRows( rangeOfRows); } -void SAL_CALL UnoGridControl::removeIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL UnoGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->removeIndexIntervall( start, length ); + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectAllRows(); +} +void SAL_CALL UnoGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) +{ + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRows( rangeOfRows); } +void SAL_CALL UnoGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException) +{ + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectAllRows(); +} ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL UnoGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getSelection(); @@ -244,12 +278,12 @@ void SAL_CALL UnoGridControl::selectRow(::sal_Int32 y) throw (::com::sun::star:: void SAL_CALL UnoGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->addSelectionListener( listener ); + m_aSelectionListeners.addInterface( listener ); } void SAL_CALL UnoGridControl::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->removeSelectionListener( listener ); + m_aSelectionListeners.removeInterface( listener ); } }//namespace toolkit diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index 8b219e70a0f2..c566569d7dbf 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -101,8 +101,10 @@ public: virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deselectAllRows() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelection() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); @@ -116,6 +118,7 @@ public: using UnoControl::getPeer; private: ::com::sun::star::view::SelectionType mSelectionMode; + SelectionListenerMultiplexer m_aSelectionListeners; }; } // toolkit diff --git a/toolkit/source/helper/listenermultiplexer.cxx b/toolkit/source/helper/listenermultiplexer.cxx index cdbb156cd0f5..ee4c9bf4c144 100644 --- a/toolkit/source/helper/listenermultiplexer.cxx +++ b/toolkit/source/helper/listenermultiplexer.cxx @@ -209,3 +209,8 @@ IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TreeExpansionListenerMultiplexer, ::com // ---------------------------------------------------- IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TreeEditListenerMultiplexer, ::com::sun::star::awt::tree::XTreeEditListener ) +// ---------------------------------------------------- +// class SelectionListenerMultiplexer +// ---------------------------------------------------- +IMPL_LISTENERMULTIPLEXER_BASEMETHODS( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener ) +IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener, selectionChanged, ::com::sun::star::awt::grid::GridSelectionEvent ) \ No newline at end of file diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index 9438cb93541b..beb746e02f36 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -286,8 +286,9 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_3 ( "ReferenceDevice", REFERENCE_DEVICE, Reference< XDevice >,BOUND, MAYBEDEFAULT, TRANSIENT ), DECL_PROP_3 ( "EvenRowBackgroundColor", GRID_EVEN_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_3 ( "HeaderBackgroundColor", GRID_HEADER_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_3 ( "LineColor", GRID_LINE_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ) - }; + DECL_PROP_3 ( "LineColor", GRID_LINE_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "RowBackgroundColor", GRID_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ) + }; pPropertyInfos = aImplPropertyInfos; nElements = sizeof( aImplPropertyInfos ) / sizeof( ImplPropertyInfo ); } diff --git a/vcl/inc/vcl/vclevent.hxx b/vcl/inc/vcl/vclevent.hxx index 570c8ad0a342..fe9e566f75e3 100644 --- a/vcl/inc/vcl/vclevent.hxx +++ b/vcl/inc/vcl/vclevent.hxx @@ -195,6 +195,7 @@ namespace com { namespace sun { namespace star { #define VCLEVENT_TOOLBOX_BUTTONSTATECHANGED 1223 // pData = itempos #define VCLEVENT_TABLECELL_NAMECHANGED 1224 // pData = struct(Entry, Column, oldText) +#define VCLEVENT_TABLEROW_SELECT 1225 class VCL_DLLPUBLIC VclSimpleEvent { -- cgit From a3ab9e8435dc16a89589e552a66485da4eb60d04 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Mon, 22 Mar 2010 11:17:10 +0100 Subject: recent changes for grid control --- .../source/extended/AccessibleGridControl.cxx | 7 -- .../source/extended/AccessibleGridControlBase.cxx | 7 -- .../extended/AccessibleGridControlHeader.cxx | 49 +++-------- .../source/extended/AccessibleGridControlTable.cxx | 97 ++++++++++------------ .../extended/AccessibleGridControlTableBase.cxx | 4 - .../extended/AccessibleGridControlTableCell.cxx | 7 +- 6 files changed, 58 insertions(+), 113 deletions(-) diff --git a/accessibility/source/extended/AccessibleGridControl.cxx b/accessibility/source/extended/AccessibleGridControl.cxx index 4671f3284110..2d313264bc6a 100755 --- a/accessibility/source/extended/AccessibleGridControl.cxx +++ b/accessibility/source/extended/AccessibleGridControl.cxx @@ -36,7 +36,6 @@ #include #include #include -//#include "svtools/table/tablecontrol.hxx" // ============================================================================ @@ -77,8 +76,6 @@ public: AccessibleGridControlHeader* m_pColumnHeaderBar; }; -// Ctor/Dtor/disposing -------------------------------------------------------- - DBG_NAME( AccessibleGridControl ) AccessibleGridControl::AccessibleGridControl( @@ -86,7 +83,6 @@ AccessibleGridControl::AccessibleGridControl( IAccessibleTable& _rTable ) : AccessibleGridControlBase( _rxParent, _rTable, TCTYPE_GRIDCONTROL ) { -// DBG_CTOR( AccessibleTableControl, NULL ); m_pImpl.reset( new AccessibleGridControl_Impl() ); m_pImpl->m_aCreator = _rxCreator; } @@ -94,7 +90,6 @@ AccessibleGridControl::AccessibleGridControl( // ----------------------------------------------------------------------------- AccessibleGridControl::~AccessibleGridControl() { - DBG_DTOR( AccessibleGridControl, NULL ); } // ----------------------------------------------------------------------------- @@ -334,13 +329,11 @@ AccessibleGridControlAccess::AccessibleGridControlAccess( const Reference< XAcce ,m_rTable( _rTable ) ,m_pContext( NULL ) { - DBG_CTOR( AccessibleGridControlAccess, NULL ); } // ----------------------------------------------------------------------------- AccessibleGridControlAccess::~AccessibleGridControlAccess() { - DBG_DTOR( AccessibleGridControlAccess, NULL ); } // ----------------------------------------------------------------------------- diff --git a/accessibility/source/extended/AccessibleGridControlBase.cxx b/accessibility/source/extended/AccessibleGridControlBase.cxx index 91dd9bd3bdc5..8af6728dd827 100755 --- a/accessibility/source/extended/AccessibleGridControlBase.cxx +++ b/accessibility/source/extended/AccessibleGridControlBase.cxx @@ -60,8 +60,6 @@ namespace accessibility { using namespace com::sun::star::accessibility::AccessibleStateType; // ============================================================================ -// Ctor/Dtor/disposing -------------------------------------------------------- - DBG_NAME( AccessibleGridControlBase ) AccessibleGridControlBase::AccessibleGridControlBase( @@ -76,13 +74,10 @@ AccessibleGridControlBase::AccessibleGridControlBase( m_aDescription( rTable.GetAccessibleObjectDescription( eObjType ) ), m_aClientId(0) { - DBG_CTOR( AccessibleGridControlBase, NULL ); } AccessibleGridControlBase::~AccessibleGridControlBase() { -// DBG_DTOR( AccessibleGridControlBase, NULL ); - if( isAlive() ) { // increment ref count to prevent double call of Dtor @@ -521,7 +516,6 @@ GridControlAccessibleElement::GridControlAccessibleElement( const Reference< XAc AccessibleTableControlObjType eObjType ) :AccessibleGridControlBase( rxParent, rTable, eObjType ) { -// DBG_CTOR( GridControlAccessibleElement, NULL ); } // XInterface ----------------------------------------------------------------- @@ -540,7 +534,6 @@ Reference< XAccessibleContext > SAL_CALL GridControlAccessibleElement::getAccess // ---------------------------------------------------------------------------- GridControlAccessibleElement::~GridControlAccessibleElement( ) { -// DBG_DTOR( GridControlAccessibleElement, NULL ); } // ============================================================================ diff --git a/accessibility/source/extended/AccessibleGridControlHeader.cxx b/accessibility/source/extended/AccessibleGridControlHeader.cxx index a5a2be4049dc..fe02c92222fd 100755 --- a/accessibility/source/extended/AccessibleGridControlHeader.cxx +++ b/accessibility/source/extended/AccessibleGridControlHeader.cxx @@ -59,8 +59,6 @@ namespace accessibility { // ============================================================================ -// Ctor/Dtor/disposing -------------------------------------------------------- - DBG_NAME( AccessibleGridControlHeader ) AccessibleGridControlHeader::AccessibleGridControlHeader( @@ -69,15 +67,12 @@ AccessibleGridControlHeader::AccessibleGridControlHeader( ::svt::table::AccessibleTableControlObjType eObjType): AccessibleGridControlTableBase( rxParent, rTable, eObjType ) { -// DBG_CTOR( AccessibleGridControlHeaderBar, NULL ); - DBG_ASSERT( isRowBar() || isColumnBar(), "accessibility/extended/AccessibleGridControlHeaderBar - invalid object type" ); } AccessibleGridControlHeader::~AccessibleGridControlHeader() { -// DBG_DTOR( AccessibleGridControlHeader, NULL ); } // XAccessibleContext --------------------------------------------------------- @@ -184,35 +179,24 @@ Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibl ensureIsAlive(); return NULL; // no headers in headers } - +//not selectable Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleRows() throw ( uno::RuntimeException ) { - TCSolarGuard aSolarGuard; - ::osl::MutexGuard aGuard( getOslMutex() ); - ensureIsAlive(); - - Sequence< sal_Int32 > aSelSeq; - // row of column header bar not selectable - if( isRowBar() ) - implGetSelectedRows( aSelSeq ); + Sequence< sal_Int32 > aSelSeq(0); return aSelSeq; } //columns aren't selectable Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleColumns() throw ( uno::RuntimeException ) { - return NULL; + Sequence< sal_Int32 > aSelSeq(0); + return aSelSeq; } -//To Do - not yet implemented -sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32 nRow ) +//row headers not selectable +sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32 /*nRow*/ ) throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) { - TCSolarGuard aSolarGuard; - ::osl::MutexGuard aGuard( getOslMutex() ); - ensureIsAlive(); - ensureIsValidRow( nRow ); - //return isRowBar() ? implIsRowSelected( nRow ) : sal_False; return sal_False; } //columns aren't selectable @@ -222,28 +206,19 @@ sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleColumnSelected( sal_I (void)nColumn; return sal_False; } - +//not implemented Reference< XAccessible > SAL_CALL AccessibleGridControlHeader::getAccessibleCellAt( - sal_Int32 nRow, sal_Int32 nColumn ) + sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) { - TCSolarGuard aSolarGuard; - ::osl::MutexGuard aGuard( getOslMutex() ); - ensureIsAlive(); - ensureIsValidAddress( nRow, nColumn ); - return implGetChild( nRow, implToVCLColumnPos( nColumn ) ); + return NULL; } -// TO DO - not implemented yet +// not selectable sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleSelected( - sal_Int32 nRow, sal_Int32 nColumn ) + sal_Int32 /*nRow*/, sal_Int32 /*nColumn */) throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) { - TCSolarGuard aSolarGuard; - ::osl::MutexGuard aGuard( getOslMutex() ); - ensureIsAlive(); - ensureIsValidAddress( nRow, nColumn ); - return FALSE; - // return isRowBar() ? implIsRowSelected( nRow ) : implIsColumnSelected( nColumn ); + return sal_False; } // XServiceInfo --------------------------------------------------------------- diff --git a/accessibility/source/extended/AccessibleGridControlTable.cxx b/accessibility/source/extended/AccessibleGridControlTable.cxx index 3b51c986b8b1..8457406010de 100755 --- a/accessibility/source/extended/AccessibleGridControlTable.cxx +++ b/accessibility/source/extended/AccessibleGridControlTable.cxx @@ -54,8 +54,6 @@ namespace accessibility { // ============================================================================ -// Ctor/Dtor/disposing -------------------------------------------------------- - DBG_NAME( AccessibleGridControlTable ) AccessibleGridControlTable::AccessibleGridControlTable( @@ -64,12 +62,10 @@ AccessibleGridControlTable::AccessibleGridControlTable( AccessibleTableControlObjType _eType) : AccessibleGridControlTableBase( rxParent, rTable, _eType ) { - DBG_CTOR( AccessibleGridControlTable, NULL ); } AccessibleGridControlTable::~AccessibleGridControlTable() { - DBG_DTOR( AccessibleGridControlTable, NULL ); } // XAccessibleContext --------------------------------------------------------- @@ -197,20 +193,28 @@ Sequence< sal_Int32 > SAL_CALL AccessibleGridControlTable::getSelectedAccessible // Sequence< sal_Int32 > aSelSeq; // implGetSelectedColumns( aSelSeq ); // return aSelSeq; - return NULL; + Sequence< sal_Int32 > aSelSeq(0); + return aSelSeq; } -//To Do: not implemented yet sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleRowSelected( sal_Int32 nRow ) throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) { - //TCSolarGuard aSolarGuard; - //::osl::MutexGuard aGuard( getOslMutex() ); - //ensureIsAlive(); - //ensureIsValidRow( nRow ); - //return implIsRowSelected( nRow ); - (void) nRow; - return sal_False; + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidRow( nRow ); + sal_Bool bSelected = sal_False; + Sequence< sal_Int32 > selectedRows = getSelectedAccessibleRows(); + for(int i=0; i selectedRows = m_aTable.GetSelectedRows(); + selectedRows.push_back(nRow); } -//To Do - not implemented yet sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) { - // using interface methods - no mutex - /*return isRowBar() ? - isAccessibleRowSelected( nChildIndex ) : - isAccessibleColumnSelected( nChildIndex );*/ - (void)nChildIndex; - return FALSE; + TCSolarGuard aSolarGuard; + ::osl::MutexGuard aGuard( getOslMutex() ); + ensureIsAlive(); + ensureIsValidIndex( nChildIndex ); + sal_Int32 nColumns = m_aTable.GetColumnCount(); + sal_Int32 nRow = (nChildIndex / nColumns); + return isAccessibleRowSelected(nRow); } -//To Do - not implemented yet void SAL_CALL AccessibleGridControlTable::clearAccessibleSelection() throw ( uno::RuntimeException ) { TCSolarGuard aSolarGuard; ::osl::MutexGuard aGuard( getOslMutex() ); ensureIsAlive(); + for(int i=0;i selectedRows = getSelectedAccessibleRows(); + for(int i=0;i selectedRows = getSelectedAccessibleRows(); + sal_Int32 nColumns = m_aTable.GetColumnCount(); + return selectedRows.getLength()*nColumns; } -//To Do - not implemented yet Reference< XAccessible > SAL_CALL AccessibleGridControlTable::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) @@ -307,10 +312,12 @@ AccessibleGridControlTable::getSelectedAccessibleChild( sal_Int32 nSelectedChild TCSolarGuard aSolarGuard; ::osl::MutexGuard aGuard( getOslMutex() ); ensureIsAlive(); - (void)nSelectedChildIndex; - return NULL; + if(isAccessibleChildSelected(nSelectedChildIndex)) + return getAccessibleChild(nSelectedChildIndex); + else + return NULL; } -//To Do - not implemented yet +//not implemented yet, because only row selection possible void SAL_CALL AccessibleGridControlTable::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) @@ -319,14 +326,6 @@ void SAL_CALL AccessibleGridControlTable::deselectAccessibleChild( ::osl::MutexGuard aGuard( getOslMutex() ); ensureIsAlive(); (void)nSelectedChildIndex; - // method may throw lang::IndexOutOfBoundsException - //if ( isAccessibleChildSelected(nSelectedChildIndex) ) - //{ - // if( isRowBar() ) - // implSelectRow( nSelectedChildIndex, sal_False ); - // else - // implSelectColumn( implToVCLColumnPos( nSelectedChildIndex ), sal_False ); - //} } // XInterface ----------------------------------------------------------------- @@ -367,14 +366,6 @@ Rectangle AccessibleGridControlTable::implGetBoundingBoxOnScreen() return m_aTable.calcTableRect(); } // internal helper methods ---------------------------------------------------- -//To Do - not implemented yet -//sal_Int32 AccessibleGridControlTable::implGetChildIndexFromSelectedIndex( -// sal_Int32 nSelectedChildIndex ) -// throw ( lang::IndexOutOfBoundsException ) -//{ -// (void)nSelectedChildIndex; -// return 0; -//} Reference< XAccessibleTable > AccessibleGridControlTable::implGetHeaderBar( sal_Int32 nChildIndex ) throw ( uno::RuntimeException ) diff --git a/accessibility/source/extended/AccessibleGridControlTableBase.cxx b/accessibility/source/extended/AccessibleGridControlTableBase.cxx index 76584bf4b965..2416e96fdd53 100755 --- a/accessibility/source/extended/AccessibleGridControlTableBase.cxx +++ b/accessibility/source/extended/AccessibleGridControlTableBase.cxx @@ -56,8 +56,6 @@ namespace accessibility { // ============================================================================ -// Ctor/Dtor/disposing -------------------------------------------------------- - DBG_NAME( AccessibleGridControlTableBase ) AccessibleGridControlTableBase::AccessibleGridControlTableBase( @@ -66,12 +64,10 @@ AccessibleGridControlTableBase::AccessibleGridControlTableBase( AccessibleTableControlObjType eObjType ) : GridControlAccessibleElement( rxParent, rTable, eObjType ) { - DBG_CTOR( AccessibleGridControlTableBase, NULL ); } AccessibleGridControlTableBase::~AccessibleGridControlTableBase() { - DBG_DTOR( AccessibleGridControlTableBase, NULL ); } // XAccessibleContext --------------------------------------------------------- diff --git a/accessibility/source/extended/AccessibleGridControlTableCell.cxx b/accessibility/source/extended/AccessibleGridControlTableCell.cxx index 981a3e6086b0..cad1d7f0cbc3 100755 --- a/accessibility/source/extended/AccessibleGridControlTableCell.cxx +++ b/accessibility/source/extended/AccessibleGridControlTableCell.cxx @@ -68,7 +68,6 @@ namespace accessibility // ============================================================================= // = AccessibleGridControlCell // ============================================================================= - //DBG_NAME( svt_AccessibleGridControlCell ) // ----------------------------------------------------------------------------- AccessibleGridControlCell::AccessibleGridControlCell( const Reference< XAccessible >& _rxParent, IAccessibleTable& _rTable, @@ -77,7 +76,6 @@ namespace accessibility ,m_nRowPos( _nRowPos ) ,m_nColPos( _nColPos ) { -// DBG_CTOR( svt_AccessibleGridControlCell, NULL ); // set accessible name here, because for that we need the position of the cell // and so the base class isn't capable of doing this ::rtl::OUString aAccName; @@ -107,8 +105,7 @@ namespace accessibility ::rtl::OUString AccessibleGridControlTableCell::implGetText() { ensureIsAlive(); - //return mpTable->GetAccessibleCellText( getRowPos(), static_cast< USHORT >( getColumnPos() ) ); - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "test" )); + return m_aTable.GetAccessibleCellText( getRowPos(), getColumnPos() ); } ::com::sun::star::lang::Locale AccessibleGridControlTableCell::implGetLocale() @@ -366,12 +363,12 @@ namespace accessibility //!!! don't know how to put a string into the clipboard return sal_False; } + Rectangle AccessibleGridControlTableCell::implGetBoundingBox() { return Rectangle(Point(0,0),Point(0,0));//To Do - return headercell rectangle } // ----------------------------------------------------------------------------- - Rectangle AccessibleGridControlTableCell::implGetBoundingBoxOnScreen() { return Rectangle(Point(0,0),Point(0,0));//To Do - return headercell rectangle -- cgit From 10bf81fb33adf67f05d6744e4edc7ec0dbd9abba Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Mon, 22 Mar 2010 11:17:10 +0100 Subject: recent changes for grid control --- solenv/bin/build.pl | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/solenv/bin/build.pl b/solenv/bin/build.pl index 5b4d4622754a..84df7ca04f38 100755 --- a/solenv/bin/build.pl +++ b/solenv/bin/build.pl @@ -2292,24 +2292,20 @@ sub is_output_tree { }; return ''; }; - sub get_tmp_dir { my $tmp_dir; - if( defined($ENV{TMPDIR}) ) { - $tmp_dir = $ENV{TMPDIR} . '/'; - } elsif( defined($ENV{TMP}) ) { + if( defined($ENV{TMP}) ) { $tmp_dir = $ENV{TMP} . '/'; } else { $tmp_dir = '/tmp/'; } - $tmp_dir = tempdir ( DIR => $tmp_dir ); - if (!-d $tmp_dir) { - print_error("Cannot create temporary directory for checkout in $tmp_dir") if ($@); - }; + $tmp_dir .= $$ while (-e $tmp_dir); + $tmp_dir = CorrectPath($tmp_dir); + eval {mkpath($tmp_dir)}; + print_error("Cannot create temporary directory in $tmp_dir") if ($@); return $tmp_dir; }; - sub retrieve_build_list { my $module = shift; my $old_fh = select(STDOUT); -- cgit From 944df0291adce8725df6614d1d19d91642dd8173 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Mon, 22 Mar 2010 11:17:10 +0100 Subject: recent changes for grid control --- offapi/com/sun/star/awt/grid/GridColumnEvent.idl | 16 +--------- .../com/sun/star/awt/grid/GridSelectionEvent.idl | 13 +++++--- .../com/sun/star/awt/grid/SelectionEventType.idl | 8 ++++- .../com/sun/star/awt/grid/UnoControlGridModel.idl | 7 +++-- offapi/com/sun/star/awt/grid/XGridColumn.idl | 30 +++++++++++++++++- offapi/com/sun/star/awt/grid/XGridColumnModel.idl | 28 +++++++---------- offapi/com/sun/star/awt/grid/XGridSelection.idl | 36 ++++++++++++---------- 7 files changed, 80 insertions(+), 58 deletions(-) diff --git a/offapi/com/sun/star/awt/grid/GridColumnEvent.idl b/offapi/com/sun/star/awt/grid/GridColumnEvent.idl index c6c5ac646cdf..66738d5521e8 100644 --- a/offapi/com/sun/star/awt/grid/GridColumnEvent.idl +++ b/offapi/com/sun/star/awt/grid/GridColumnEvent.idl @@ -34,24 +34,13 @@ #include #endif -#ifndef __com_sun_star_awt_grid_XGridColumn_idl__ -#include -#endif - //============================================================================= module com { module sun { module star { module awt { module grid { //============================================================================= -/** An event used by a XGridColumnModel to notify changes in the column - model to the XGridControl. - You usually need to fill this event only if you implement the XGridColumnModel - yourself. - - @see XGridColumnModel - @see XGridControl - @see XGridColumnListener +/** An event used by a XGridColumn to notify changes in the column. */ struct GridColumnEvent: com::sun::star::lang::EventObject { @@ -66,9 +55,6 @@ struct GridColumnEvent: com::sun::star::lang::EventObject /** Contains the index of the changed column**/ long index; - - /** Contains the changed column**/ - XGridColumn column; //------------------------------------------------------------------------- }; diff --git a/offapi/com/sun/star/awt/grid/GridSelectionEvent.idl b/offapi/com/sun/star/awt/grid/GridSelectionEvent.idl index a2ec28361ca0..7d657b832c41 100644 --- a/offapi/com/sun/star/awt/grid/GridSelectionEvent.idl +++ b/offapi/com/sun/star/awt/grid/GridSelectionEvent.idl @@ -53,14 +53,17 @@ struct GridSelectionEvent: com::sun::star::lang::EventObject { //------------------------------------------------------------------------- - /** Contains the x coordinate of the selected cell**/ - long x; + /** the selected row*/ + long Row; - /** Contains the y coordinate of the selected cell**/ - long y; + /** the selected column*/ + long Column; + + /**number of selected rows, if multiple rows selected*/ + long Range; /** Contains the action SelectionEventType that was performed **/ - SelectionEventType action; + SelectionEventType Action; }; diff --git a/offapi/com/sun/star/awt/grid/SelectionEventType.idl b/offapi/com/sun/star/awt/grid/SelectionEventType.idl index 4d8aa7fc0cdb..b31076e139fa 100644 --- a/offapi/com/sun/star/awt/grid/SelectionEventType.idl +++ b/offapi/com/sun/star/awt/grid/SelectionEventType.idl @@ -52,7 +52,13 @@ enum SelectionEventType /** This value indicates that a selection was removed from the grid control */ - REMOVE + REMOVE, + + //------------------------------------------------------------------------- + + /** This value indicates that a selection was changed + */ + CHANGE }; diff --git a/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl b/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl index 97238f8a163b..f111f6970a96 100644 --- a/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl +++ b/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl @@ -101,10 +101,11 @@ service UnoControlGridModel

The default value is SelectionType::SINGLE

*/ [property] ::com::sun::star::view::SelectionType SelectionModel; - /** Specifies the background color of odd rows. If color for even rows isn't set, then specifies - the color of all rows. Default value is white. + + /** Specifies the background color of rows. If color for even rows is set, then specifies + the color of odd rows. Default value is white. */ - [property] ::com::sun::star::util::Color BackgroundColor; + [property] ::com::sun::star::util::Color RowBackgroundColor; /** Specifies the background color of even rows. Default value is white. */ diff --git a/offapi/com/sun/star/awt/grid/XGridColumn.idl b/offapi/com/sun/star/awt/grid/XGridColumn.idl index 45dcc258fb08..aa0f3e514634 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumn.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumn.idl @@ -34,6 +34,7 @@ #include #endif #include +#include //============================================================================= @@ -44,7 +45,7 @@ module com { module sun { module star { module awt { module grid { /** The XGridColumn defines the properties and behavior of a column in a grid control */ -interface XGridColumn: com::sun::star::uno::XInterface +interface XGridColumn { /** Specifies the an idendifier of the colomn.**/ [attribute] any Identifier; @@ -76,6 +77,33 @@ interface XGridColumn: com::sun::star::uno::XInterface /** A title is displayed in the colum header row if UnoControlGridModel::ShowRowHeader is set to **/ [attribute] string Title; + + /** Adds a listener for the GridColumnEvent posted after the grid changes. + @param Listener + the listener to add. + */ + [oneway] void addColumnListener( [in] XGridColumnListener listener); + + //------------------------------------------------------------------------- + + /** Removes a listener previously added with addColumnListener(). + @param Listener + the listener to remove. + */ + [oneway] void removeColumnListener( [in] XGridColumnListener listener); + + /**Updates changed column widths, when column widths are being resized. + @param name + can be PrefWidth or ColWidth, depending on which was changed + @param width + the new column width + */ + void updateColumn( [in] string name, [in] long width); + /**Sets column index + @param index + index, which is the index of the column in the column array of the column model + */ + void setIndex( [in] long index ); }; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/XGridColumnModel.idl b/offapi/com/sun/star/awt/grid/XGridColumnModel.idl index fad0ce190d69..0b8553f915a3 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumnModel.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumnModel.idl @@ -33,6 +33,7 @@ #include #include + #include //============================================================================= @@ -48,9 +49,9 @@ module com { module sun { module star { module awt { module grid { */ interface XGridColumnModel: com::sun::star::uno::XInterface { - /** Specifies whether column selection is allowed - */ - [attribute] boolean ColumnSelectionAllowed; + ///** Specifies whether column selection is allowed + //*/ + //[attribute] boolean ColumnSelectionAllowed; /**Specifies the height of column header. */ @@ -100,23 +101,16 @@ interface XGridColumnModel: com::sun::star::uno::XInterface */ void setDefaultColumns([in] long elements); - /* - long getTotalColumnWidth(); - */ - - /** Adds a listener for the GridColumnEvent posted after the grid changes. - @param Listener - the listener to add. + /**Creates new XGridColumn with the settings of other column. To be used if the columns which are added to + the column model have the same settings. + @param column + the column, which is already created */ - [oneway] void addColumnListener( [in] XGridColumnListener listener); - - //------------------------------------------------------------------------- + XGridColumn copyColumn( [in] XGridColumn column ); - /** Removes a listener previously added with addColumnListener(). - @param Listener - the listener to remove. + /* + long getTotalColumnWidth(); */ - [oneway] void removeColumnListener( [in] XGridColumnListener listener); }; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/XGridSelection.idl b/offapi/com/sun/star/awt/grid/XGridSelection.idl index b567b7570ddc..a9bd83948fbb 100644 --- a/offapi/com/sun/star/awt/grid/XGridSelection.idl +++ b/offapi/com/sun/star/awt/grid/XGridSelection.idl @@ -56,21 +56,25 @@ interface XGridSelection: com::sun::star::uno::XInterface */ long getMaxSelectionIndex(); - /** Adds a selection intervall. - @param start - the start row index. - @param length - the number of rows to be selected. + /** Selects all rows. */ - [oneway] void insertIndexIntervall( [in] long start, [in] long length); + [oneway] void selectAllRows(); - /** Removes a selection intervall. - @param start - the start row index. - @param length - the number of rows to be selected. + /** Selects multiple rows. Previous selections will be removed. + @param rangeOfRows + array of rows indexes, which will be selected. */ - [oneway] void removeIndexIntervall( [in] long start, [in] long length); + [oneway] void selectRows( [in] sequence< long > rangeOfRows); + + /** Deselects all selected rows. + */ + [oneway] void deselectAllRows(); + + /** Deselects selected rows. Selected rows, which aren't in the range remain selected. + @param rangeOfRows + array of rows indexes, which will be deselected. + */ + [oneway] void deselectRows( [in] sequence< long > rangeOfRows); /** Returns the indicies of all selected rows. @returns @@ -93,17 +97,17 @@ interface XGridSelection: com::sun::star::uno::XInterface boolean isSelectedIndex( [in] long index); /** Marks a row as selected. - @param + @param index the index of a row. */ - [oneway] void selectRow( [in] long y); + [oneway] void selectRow( [in] long index); /* [oneway] void selectColumn( [in] long x); */ /** Adds a listener for the GridSelectionEvent posted after the grid changes. - @param Listener + @param listener the listener to add. */ [oneway] void addSelectionListener( [in] XGridSelectionListener listener); @@ -111,7 +115,7 @@ interface XGridSelection: com::sun::star::uno::XInterface //------------------------------------------------------------------------- /** Removes a listener previously added with addSelectionListener(). - @param Listener + @param listener the listener to remove. */ [oneway] void removeSelectionListener( [in] XGridSelectionListener listener); -- cgit From b09453118d699ce2c7e00cda02ffb1247dd29ac2 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Mon, 22 Mar 2010 15:15:28 +0100 Subject: fixed bugs for linux build --- svtools/inc/svtools/table/tablemodel.hxx | 4 +- svtools/source/table/tablecontrol.cxx | 5 -- svtools/source/table/tablecontrol_impl.cxx | 21 +----- svtools/source/table/tablecontrol_impl.hxx | 2 +- svtools/source/table/tabledatawindow.cxx | 2 - svtools/source/uno/svtxgridcontrol.cxx | 6 +- svtools/source/uno/svtxgridcontrol.hxx | 2 - svtools/source/uno/unocontroltablemodel.cxx | 16 ++--- svtools/source/uno/unocontroltablemodel.hxx | 4 +- .../controls/grid/defaultgridcolumnmodel.cxx | 80 ---------------------- .../source/controls/grid/defaultgriddatamodel.cxx | 19 ----- toolkit/source/controls/grid/gridcontrol.cxx | 11 --- 12 files changed, 14 insertions(+), 158 deletions(-) diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 18d4db16c123..786af87db12d 100644 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -447,13 +447,13 @@ namespace svt { namespace table virtual bool hasHorizontalScrollbar() = 0; /** fills cells with content */ - virtual void setCellContent(std::vector< std::vector< ::com::sun::star::uno::Any > > cellContent)=0; + virtual void setCellContent(const std::vector< std::vector< ::com::sun::star::uno::Any > >& cellContent)=0; /** gets the content of the cells */ virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0; /**sets title of header rows */ - virtual void setRowHeaderName(std::vector cellColumnContent)=0; + virtual void setRowHeaderName(const std::vector& cellColumnContent)=0; /** gets title of header rows */ virtual std::vector& getRowHeaderName() = 0; diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 635008d94f94..f4d328261cba 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -260,7 +260,6 @@ namespace svt { namespace table aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderBar" ) ); break; case TCTYPE_TABLECELL: - //Window* pWin = GetCellContent(_nRow, _nCol); aRetText = GetRowName(_nRow); break; case TCTYPE_ROWHEADERCELL: @@ -387,10 +386,6 @@ void TableControl::FillAccessibleStateSet( break; case TCTYPE_TABLECELL: { - //sal_Int32 nRow = GetCurRow(); - //sal_uInt16 nColumn = GetCurColumnId(); - //if ( IsFieldVisible(nRow,nColumn) ) - // rStateSet.AddState( AccessibleStateType::VISIBLE ); rStateSet.AddState( AccessibleStateType::TRANSIENT ); rStateSet.AddState( AccessibleStateType::SELECTABLE); if( GetSelectedRowCount()>0) diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 7220f964a99e..39286903b11f 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -190,9 +190,8 @@ namespace svt { namespace table { return false; } - virtual void setCellContent(std::vector > pCellEntryType) + virtual void setCellContent(const std::vector >& ) { - (void)pCellEntryType; } virtual ::com::sun::star::util::Color getLineColor() { @@ -248,9 +247,8 @@ namespace svt { namespace table { return *( new std::vector >); } - virtual void setRowHeaderName(std::vector pCellEntryType) + virtual void setRowHeaderName(const std::vector& ) { - (void)pCellEntryType; } virtual std::vector& getRowHeaderName() { @@ -1169,7 +1167,6 @@ namespace svt { namespace table it!=m_nRowSelected.end();++it) { invalidateSelectedRegion(*it, *it, rCells); - //m_pDataWindow->Invalidate(rCells); } m_nRowSelected.clear(); } @@ -1203,7 +1200,6 @@ namespace svt { namespace table it!=m_nRowSelected.end();++it) { invalidateSelectedRegion(*it, *it, rCells); - //m_pDataWindow->Invalidate(rCells); } m_nRowSelected.clear(); } @@ -1327,7 +1323,6 @@ namespace svt { namespace table it!=m_nRowSelected.end();++it) { invalidateSelectedRegion(*it, *it, rCells); - //m_pDataWindow->Invalidate(rCells); } m_nRowSelected.clear(); m_nRowSelected.push_back(m_nCurRow); @@ -1415,7 +1410,6 @@ namespace svt { namespace table it!=m_nRowSelected.end();++it) { invalidateSelectedRegion(*it, *it, rCells); - //m_pDataWindow->Invalidate(rCells); } m_nRowSelected.clear(); m_nRowSelected.push_back(m_nCurRow); @@ -1547,7 +1541,6 @@ namespace svt { namespace table Rectangle aCellRect; impl_getCellRect( m_nCurColumn, m_nCurRow, aCellRect ); - // const StyleSettings& rStyle = m_rAntiImpl.GetSettings().GetStyleSettings(); if ( _bShow ) { pRenderer->ShowCellCursor( *m_pDataWindow, aCellRect); @@ -1673,7 +1666,6 @@ namespace svt { namespace table //this method is to be called, when a new row is added void TableControl_Impl::invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect) { - //DBG_CHECK_ME(); if(m_nCurRow < 0) m_nCurRow = 0; if(m_nCursorHidden == 2) @@ -1719,7 +1711,6 @@ namespace svt { namespace table //------------------------------------------------------------------------------- void TableControl_Impl::invalidateRows(RowPos _nRowStart, Rectangle& _rCellRect) { - //DBG_CHECK_ME(); (void)_nRowStart; (void)_rCellRect; impl_ni_updateScrollbars(); @@ -1728,7 +1719,6 @@ namespace svt { namespace table m_nTopRow--; else m_nTopRow = 0; - //m_pDataWindow->Invalidate(_rCellRect); m_pDataWindow->Invalidate(); } @@ -2063,9 +2053,6 @@ namespace svt { namespace table m_bResizingGrid = false; m_nResizingColumn = m_nCurColumn; PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn); - //sal_Int32 colWidth = pColumn->getWidth(); - ////impl_ni_getAccVisibleColWidths(); - //int newColWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); if(m_aVisibleColumnWidthsPixel[m_nResizingColumn-m_nLeftColumn]-1 == rPoint.X() && pColumn->isResizable()) { m_pDataWindow->CaptureMouse(); @@ -2082,7 +2069,6 @@ namespace svt { namespace table PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn); int maxWidth = pColumn->getMaxWidth(); int minWidth = pColumn->getMinWidth(); - //int colWidth = pColumn->getWidth(); int resizeCol = m_nResizingColumn-m_nLeftColumn; //new position of mouse int actX = rPoint.X(); @@ -2260,9 +2246,6 @@ namespace svt { namespace table { //selecting region, int diff = m_pTableControl->m_nCurRow - curRow; - //bool isAlreadySelected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, m_pTableControl->m_nAnchor); - /* if(!isAlreadySelected && m_nCurrentRow != m_pTableControl->m_nCurRow) - m_pTableControl->m_nRowSelected.push_back(m_nAnchor);*/ //selected region lies above the last selection if( diff >= 0) { diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index dffa69422599..8bc6b371d1d8 100644 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -321,7 +321,7 @@ namespace svt { namespace table DECL_LINK( OnScroll, ScrollBar* ); }; - //see seleng.hxx, seleng.cxx, FunctionSet overwritables, part of selection engine + //see seleng.hxx, seleng.cxx, FunctionSet overridables, part of selection engine class TableFunctionSet : public FunctionSet { friend class TableDataWindow; diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 6ae2a39443d1..8d7b08c4e255 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -44,8 +44,6 @@ namespace svt { namespace table :Window( &_rTableControl.getAntiImpl() ) ,m_rTableControl ( _rTableControl ) { - //Color backgroundColor = GetControlBackground(); - //SetBackground( backgroundColor ); } //-------------------------------------------------------------------- diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 482d01224073..81ca6e2afd0f 100755 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -111,8 +111,6 @@ sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int void SAL_CALL SVTXGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const com::sun::star::uno::Sequence< sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException) { TableControl* pTable = (TableControl*)GetWindow(); - /*std::vector< sal_Int32 > newCols( - comphelper::sequenceToContainer< std::vector< sal_Int32 > >(columns));*/ pTable->setTooltip(text, columns); } @@ -268,9 +266,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An { std::vector< Any > newRow; Sequence< Any > rawRowData = cellData[i]; - //check whether the data row vector length matches with the column count, - //all cells must have some content even if it is empty string - //preventing errors + //check whether the data row vector length matches with the column count if(m_xColumnModel->getColumnCount() == 0) { for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col ) diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index cd4dc698f8db..232eaea4349f 100755 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -78,8 +78,6 @@ public: virtual void SAL_CALL dataChanged(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException); //XGridColumnListener overridables - //virtual void SAL_CALL columnAdded(const ::com::sun::star::awt::grid::GridColumnEvent& Event) throw (::com::sun::star::uno::RuntimeException); - //virtual void SAL_CALL columnRemoved(const ::com::sun::star::awt::grid::GridColumnEvent & Event) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL columnChanged(const ::com::sun::star::awt::grid::GridColumnEvent & Event) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 2b53b65de471..6d04098e0f78 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -53,13 +53,11 @@ using namespace ::com::sun::star::uno; ,m_sName() ,m_bIsResizable( true ) ,m_nWidth( 4 ) - ,m_nMinWidth( 0 ) // no min width - ,m_nMaxWidth( 0 ) // no max width + ,m_nMinWidth( 0 ) + ,m_nMaxWidth( 0 ) ,m_nPrefWidth ( 0 ) ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0)) { - //m_nID = m_xGridColumn->getIdentifier(); - //m_nWidth = m_xGridColumn->getColumnWidth(); m_sName = m_xGridColumn->getTitle(); } //-------------------------------------------------------------------- @@ -68,8 +66,8 @@ using namespace ::com::sun::star::uno; ,m_sName() ,m_bIsResizable( true ) ,m_nWidth( 4 ) - ,m_nMinWidth( 0 ) // no min width - ,m_nMaxWidth( 0 ) // no max width + ,m_nMinWidth( 0 ) + ,m_nMaxWidth( 0 ) ,m_nPrefWidth ( 0 ) ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0)) { @@ -293,7 +291,6 @@ using namespace ::com::sun::star::uno; void UnoControlTableModel::addTableModelListener( const PTableModelListener& listener ) { (void) listener; - //listener->onTableModelChanged(PTableModel(this)); // TODO DBG_ERROR( "DefaultTableModel::addTableModelListener: not yet implemented!" ); } @@ -431,18 +428,17 @@ using namespace ::com::sun::star::uno; return m_pImpl->bHScroll; } //-------------------------------------------------------------------- - void UnoControlTableModel::setCellContent(std::vector > cellContent) + void UnoControlTableModel::setCellContent(const std::vector >& cellContent) { m_pImpl->aCellContent = cellContent; } std::vector >& UnoControlTableModel::getCellContent() { - //::vos::OGuard aGuard( GetMutex() ); return m_pImpl->aCellContent; } //-------------------------------------------------------------------- - void UnoControlTableModel::setRowHeaderName(std::vector cellColumnContent) + void UnoControlTableModel::setRowHeaderName(const std::vector& cellColumnContent) { m_pImpl->aRowHeadersTitle = cellColumnContent; } diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index ae0a5ce76a9e..c72db4e7ba87 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -148,9 +148,9 @@ class UnoControlTableColumn : public IColumnModel virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const; virtual void setVerticalScrollbarVisibility(bool _bVScroll) const; virtual void setHorizontalScrollbarVisibility(bool _bHScroll) const; - virtual void setCellContent(std::vector > cellContent); + virtual void setCellContent(const std::vector >& cellContent); virtual std::vector >& getCellContent(); - virtual void setRowHeaderName(std::vector cellColumnContent); + virtual void setRowHeaderName(const std::vector& cellColumnContent); virtual std::vector& getRowHeaderName(); virtual ::com::sun::star::util::Color getLineColor(); virtual void setLineColor(::com::sun::star::util::Color _rColor); diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index f68239f9712c..c61023f7cf2e 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -43,8 +43,6 @@ using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::style; -//#define COLUMNSELECTIONALLOWED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnSelectionAllowed" )) -//#define COLUMNRESIZED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnResized" )) namespace toolkit { @@ -68,71 +66,6 @@ DefaultGridColumnModel::~DefaultGridColumnModel() //--------------------------------------------------------------------- -//void DefaultGridColumnModel::broadcast( broadcast_type eType, const GridColumnEvent& aEvent ) -//{ -// ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() ); -// if( pIter ) -// { -// ::cppu::OInterfaceIteratorHelper aListIter(*pIter); -// while(aListIter.hasMoreElements()) -// { -// XGridColumnListener* pListener = static_cast(aListIter.next()); -// switch( eType ) -// { -// case column_added: pListener->columnAdded(aEvent); break; -// case column_removed: pListener->columnRemoved(aEvent); break; -// case column_changed: pListener->columnChanged(aEvent); break; -// } -// } -// } -//} -// -////--------------------------------------------------------------------- -// -//void DefaultGridColumnModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue) -//{ -// Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); -// GridColumnEvent aEvent( xSource, name, oldValue, newValue, 0, NULL ); -// broadcast( column_changed, aEvent); -//} -// -////--------------------------------------------------------------------- -// -//void DefaultGridColumnModel::broadcast_add( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ) -//{ -// Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); -// GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn ); -// broadcast( column_added, aEvent); -//} -// -////--------------------------------------------------------------------- -// -//void DefaultGridColumnModel::broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ) -//{ -// Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); -// GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn ); -// broadcast( column_removed, aEvent); -//} - -//--------------------------------------------------------------------- -// XDefaultGridColumnModel -//--------------------------------------------------------------------- -//::sal_Bool SAL_CALL DefaultGridColumnModel::getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException) -//{ -// return selectionAllowed; -//} -// -////--------------------------------------------------------------------- -// -//void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value) throw (::com::sun::star::uno::RuntimeException) -//{ -// sal_Bool oldValue = selectionAllowed; -// selectionAllowed = value; -// broadcast_changed( COLUMNSELECTIONALLOWED, Any(oldValue) , Any(selectionAllowed)); -//} - -//--------------------------------------------------------------------- - ::sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnCount() throw (::com::sun::star::uno::RuntimeException) { return columns.size(); @@ -168,19 +101,6 @@ DefaultGridColumnModel::~DefaultGridColumnModel() else return Reference< XGridColumn >(); } -//--------------------------------------------------------------------- -//void SAL_CALL DefaultGridColumnModel::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) -//{ -// BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener ); -//} -// -////--------------------------------------------------------------------- -// -//void SAL_CALL DefaultGridColumnModel::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) -//{ -// BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener ); -//} - //--------------------------------------------------------------------- void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) { diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 528e0e17c3e0..91bdd30225ed 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -41,7 +41,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; -//using namespace ::com::sun::star::style; #define ROWHEIGHT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeight" )) #define ROWHEADERS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaders" )) @@ -182,18 +181,6 @@ void SAL_CALL DefaultGridDataModel::addRow(const ::rtl::OUString & headername, c std::vector< Any > newRow; for ( int i = 0; i < rRowdata.getLength();i++) { - //OUString title(rRowdata[i]); - - // create and use interal a UnoControlFixedText for text content - //Reference< XFixedText > xFixedText( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.UnoControlFixedText" ) ), UNO_QUERY_THROW ); - //Reference< XControl > xFixedTextControl( xFixedText , UNO_QUERY ); - // - //Reference< XControlModel > xFixedTextModel( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.UnoControlFixedTextModel" ) ), UNO_QUERY ); - //Reference< ::com::sun::star::beans::XPropertySet > xFixedTextModelPropSet( xFixedTextModel, UNO_QUERY ); - //xFixedTextModelPropSet->setPropertyValue( OUString::createFromAscii( "Label"), makeAny( title ) ); - - //xFixedTextControl->setModel( xFixedTextModel ); - newRow.push_back(rRowdata[i]); } @@ -209,12 +196,6 @@ void SAL_CALL DefaultGridDataModel::removeRow(::sal_Int32 index) throw (::com::s { if ( index >= 0 && index <= getRowCount()-1) { - /* if(Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectedIndex( index )) - { - ::com::sun::star::uno::Sequence<::sal_Int32> selectedRows = Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getSelection(); - selectedRow.erase(selectedRows.begin()+index); - }*/ - ::rtl::OUString headerName( (::rtl::OUString) rowHeaders[index] ); rowHeaders.erase(rowHeaders.begin() + index); diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index b279ace0ef12..e397ad8158f0 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -213,17 +213,6 @@ void SAL_CALL UnoGridControl::setToolTip(const ::com::sun::star::uno::Sequence< { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->setToolTip( text, columns ); } -/* -void SAL_CALL UnoGridControl::addMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->addMouseListener( listener ); -} - -void SAL_CALL UnoGridControl::removeMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->removeMouseListener( listener ); -} -*/ // ------------------------------------------------------------------- // XGridSelection // ------------------------------------------------------------------- -- cgit From 96f3fde8e6bad2e339fea0f8e70434096b412b8f Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Mon, 22 Mar 2010 15:34:06 +0100 Subject: fixed bugs for linux build 2 --- toolkit/source/helper/listenermultiplexer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/source/helper/listenermultiplexer.cxx b/toolkit/source/helper/listenermultiplexer.cxx index ee4c9bf4c144..68bb791bb2d0 100644 --- a/toolkit/source/helper/listenermultiplexer.cxx +++ b/toolkit/source/helper/listenermultiplexer.cxx @@ -213,4 +213,4 @@ IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TreeEditListenerMultiplexer, ::com::sun::s // class SelectionListenerMultiplexer // ---------------------------------------------------- IMPL_LISTENERMULTIPLEXER_BASEMETHODS( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener ) -IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener, selectionChanged, ::com::sun::star::awt::grid::GridSelectionEvent ) \ No newline at end of file +IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener, selectionChanged, ::com::sun::star::awt::grid::GridSelectionEvent ) -- cgit From 0f1df8f471390de177610ee2bb9cc2f424d740c2 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Mon, 22 Mar 2010 16:21:58 +0100 Subject: fixed bugs for linux build 3 --- svtools/source/uno/svtxgridcontrol.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 81ca6e2afd0f..40616c2a4d87 100755 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -130,7 +130,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An TableControl* pTable = (TableControl*)GetWindow(); const StyleSettings& rStyleSettings = GetWindow()->GetSettings().GetStyleSettings(); - com::sun::star::awt::FontDescriptor& aFont = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); + const com::sun::star::awt::FontDescriptor& aFont = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); switch( GetPropertyId( PropertyName ) ) { -- cgit From 1e6396afa1556f43718784ae84e2992ea4fc6a24 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 22 Mar 2010 16:36:18 +0000 Subject: fix library locations for libvbaswobj & libmsforms --- scp2/source/ooo/file_library_ooo.scp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scp2/source/ooo/file_library_ooo.scp b/scp2/source/ooo/file_library_ooo.scp index 9b0da10d5238..5937b561b8c4 100755 --- a/scp2/source/ooo/file_library_ooo.scp +++ b/scp2/source/ooo/file_library_ooo.scp @@ -415,7 +415,7 @@ File gid_File_Lib_Vbaswobj TXT_FILE_BODY; Styles = (PACKED,UNO_COMPONENT); RegistryID = gid_Starregistry_Services_Rdb; - Dir = gid_Dir_Program; + Dir = SCP2_OOO_BIN_DIR; #ifdef UNX Name = STRING(CONCAT4(libvbaswobj,DLLPOSTFIX,.uno,UNXSUFFIX)); #else @@ -427,7 +427,7 @@ File gid_File_Lib_Vbamsforms TXT_FILE_BODY; Styles = (PACKED,UNO_COMPONENT); RegistryID = gid_Starregistry_Services_Rdb; - Dir = gid_Dir_Program; + Dir = SCP2_OOO_BIN_DIR; #ifdef UNX Name = STRING(CONCAT4(libmsforms,DLLPOSTFIX,.uno,UNXSUFFIX)); #else -- cgit From 550d319ebe948dff72deaac7f0ef87f30c53006b Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Tue, 23 Mar 2010 09:35:24 +0100 Subject: fixed bugs for linux build 4 --- accessibility/source/extended/AccessibleGridControlTable.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accessibility/source/extended/AccessibleGridControlTable.cxx b/accessibility/source/extended/AccessibleGridControlTable.cxx index 8457406010de..e1047bcb969a 100755 --- a/accessibility/source/extended/AccessibleGridControlTable.cxx +++ b/accessibility/source/extended/AccessibleGridControlTable.cxx @@ -282,7 +282,7 @@ void SAL_CALL AccessibleGridControlTable::clearAccessibleSelection() TCSolarGuard aSolarGuard; ::osl::MutexGuard aGuard( getOslMutex() ); ensureIsAlive(); - for(int i=0;i Date: Tue, 23 Mar 2010 15:43:42 +0100 Subject: fixed bugs for linux build 5 --- solenv/bin/build.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/solenv/bin/build.pl b/solenv/bin/build.pl index 9ceee7f1be49..66afeec6e2c7 100755 --- a/solenv/bin/build.pl +++ b/solenv/bin/build.pl @@ -2207,15 +2207,17 @@ sub is_output_tree { }; sub get_tmp_dir { my $tmp_dir; - if( defined($ENV{TMP}) ) { + if( defined($ENV{TMPDIR}) ) { + $tmp_dir = $ENV{TMPDIR} . '/'; + } elsif( defined($ENV{TMP}) ) { $tmp_dir = $ENV{TMP} . '/'; } else { $tmp_dir = '/tmp/'; } - $tmp_dir .= $$ while (-e $tmp_dir); - $tmp_dir = CorrectPath($tmp_dir); - eval {mkpath($tmp_dir)}; - print_error("Cannot create temporary directory in $tmp_dir") if ($@); + $tmp_dir = tempdir ( DIR => $tmp_dir ); + if (!-d $tmp_dir) { + print_error("Cannot create temporary directory for checkout in $tmp_dir") if ($@); + }; return $tmp_dir; }; -- cgit From 9fb6554349b5ef27eff08281fcb999322551cf18 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Thu, 25 Mar 2010 11:17:21 +0100 Subject: gridcontrol_03:scrollbar bug fixed --- svtools/source/table/tablecontrol_impl.cxx | 150 ++++++++--------------------- 1 file changed, 41 insertions(+), 109 deletions(-) diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index f391a9912e2e..bd5f188e3889 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -103,22 +103,22 @@ namespace svt { namespace table { return false; } - virtual void setRowHeaders(bool _bRowHeaders) + virtual void setRowHeaders(bool _bRowHeaders) { (void)_bRowHeaders; } - virtual void setColumnHeaders(bool _bColumnHeaders) + virtual void setColumnHeaders(bool _bColumnHeaders) { - (void)_bColumnHeaders; - } - void setColumnCount(TableSize _nColCount) - { - (void) _nColCount; - } - void setRowCount(TableSize _nRowCount) - { - (void)_nRowCount; + (void)_bColumnHeaders; } + void setColumnCount(TableSize _nColCount) + { + (void) _nColCount; + } + void setRowCount(TableSize _nRowCount) + { + (void)_nRowCount; + } virtual bool isCellEditable( ColPos col, RowPos row ) const { (void)col; @@ -919,21 +919,15 @@ namespace svt { namespace table // our current style settings, to be passed to the renderer const StyleSettings& rStyle = m_rAntiImpl.GetSettings().GetStyleSettings(); - + m_nRowCount = m_pModel->getRowCount(); + TableSize nVisibleRows = impl_getVisibleRows(true); + TableSize nActualRows = m_nRowCount; + if(m_nRowCount>nVisibleRows) + nActualRows = nVisibleRows; // the area occupied by all (at least partially) visible cells, including // headers Rectangle aAllCellsWithHeaders; impl_getAllVisibleCellsArea( aAllCellsWithHeaders ); - - m_nRowCount = m_pModel->getRowCount(); - TableSize nVisibleRows = impl_getVisibleRows(true); - TableSize nVisibleColumns = impl_getVisibleColumns(true); - TableSize nActualRows = m_nRowCount; - TableSize nActualCols = m_nColumnCount; - if(m_nRowCount>nVisibleRows) - nActualRows = nVisibleRows; - if(m_nColumnCount>nVisibleColumns) - nActualCols = nVisibleColumns; // ............................ // draw the header column area if ( getModel()->hasColumnHeaders() ) @@ -964,17 +958,15 @@ namespace svt { namespace table // the area occupied by the row header, if any Rectangle aRowHeaderArea; - if ( getModel()->hasRowHeaders() ) + if ( m_pModel->hasRowHeaders() ) { aRowHeaderArea = aAllCellsWithHeaders; aRowHeaderArea.Right() = m_nRowHeaderWidthPixel - 1; - if(m_nTopRow+nActualRows>m_nRowCount) - aRowHeaderArea.Bottom() = m_nRowHeightPixel * (nActualRows -1)+ m_nColHeaderHeightPixel - 1; - else - aRowHeaderArea.Bottom() = m_nRowHeightPixel * nActualRows + m_nColHeaderHeightPixel - 1; - pRenderer->PaintHeaderArea( - *m_pDataWindow, aRowHeaderArea, false, true, rStyle - ); + if(m_nTopRow+nActualRows>m_nRowCount) + aRowHeaderArea.Bottom() = m_nRowHeightPixel * (nActualRows -1)+ m_nColHeaderHeightPixel - 1; + else + aRowHeaderArea.Bottom() = m_nRowHeightPixel * nActualRows + m_nColHeaderHeightPixel - 1; + pRenderer->PaintHeaderArea(*m_pDataWindow, aRowHeaderArea, false, true, rStyle); // Note that strictly, aRowHeaderArea also contains the intersection between column // and row header area. However, below we go to paint this intersection, again, // so this hopefully doesn't hurt if we already paint it here. @@ -997,51 +989,13 @@ namespace svt { namespace table // paint all rows Rectangle aAllDataCellsArea; impl_getAllVisibleDataCellArea( aAllDataCellsArea ); - - //get the vector, which contains row vectors, each containing the data for the cells in this row - std::vector >& aCellContent = m_pModel->getCellContent(); - //if the vector is empty, fill it with empty data, so the table can be painted - if(aCellContent.empty()) - { - std::vector< ::com::sun::star::uno::Any > emptyCells; - while(m_nRowCount!=0) - { - aCellContent.push_back( emptyCells); - --m_nRowCount; - } - } - std::vector >::iterator it = aCellContent.begin()+m_nTopRow; - //get the vector, which contains the row header titles - std::vector& aRowHeaderContent = m_pModel->getRowHeaderName(); - ::std::vector::iterator itRowName = aRowHeaderContent.begin(); - - if(m_pModel->hasRowHeaders()) - { - //if the vector is empty, fill it with empty strings, so the table can be painted - if(aRowHeaderContent.empty()) - { - while(m_nRowCount!=0) - { - aRowHeaderContent.push_back(rtl::OUString::createFromAscii("")); - --m_nRowCount; - } - } - itRowName = aRowHeaderContent.begin()+m_nTopRow; - } + ::std::vector< std::vector< ::com::sun::star::uno::Any > >& aCellContent = m_pModel->getCellContent(); for ( TableRowGeometry aRowIterator( *this, aAllCellsWithHeaders, getTopRow() ); aRowIterator.isValid(); aRowIterator.moveDown() ) { if ( _rUpdateRect.GetIntersection( aRowIterator.getRect() ).IsEmpty() ) - { - if(it < aCellContent.end()-1) - { - if(m_pModel->hasRowHeaders()) - ++itRowName; - ++it; - } - continue; - } + continue; bool isActiveRow = ( aRowIterator.getRow() == getCurRow() ); bool isSelectedRow = false; if(!m_nRowSelected.empty()) @@ -1053,15 +1007,6 @@ namespace svt { namespace table isSelectedRow = true; } } - std::vector< ::com::sun::star::uno::Any > aCellData; - if(it != aCellContent.begin()+m_nTopRow+nActualRows) - { - aCellData = *it; - if(it < aCellContent.end()-1) - ++it; - } - ::std::vector< ::com::sun::star::uno::Any >::iterator iter = aCellData.begin()+m_nLeftColumn; - // give the redenderer a chance to prepare the row pRenderer->PrepareRow( aRowIterator.getRow(), isActiveRow, isSelectedRow, *m_pDataWindow, aRowIterator.getRect().GetIntersection( aAllDataCellsArea ), rStyle ); @@ -1069,20 +1014,13 @@ namespace svt { namespace table // paint the row header if ( m_pModel->hasRowHeaders() ) { - rtl::OUString rowHeaderName; - if(itRowName != aRowHeaderContent.begin()+m_nTopRow+nActualRows) - { - rowHeaderName = *itRowName; - if(itRowName < m_pModel->getRowHeaderName().end()-1) - ++itRowName; - } - Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); - pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, + Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); + rtl::OUString rowHeaderName = m_pModel->getRowHeaderName()[aRowIterator.getRow()]; + pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, rStyle, rowHeaderName ); } if ( !colCount ) continue; - // paint all cells in this row for ( TableCellGeometry aCell( aRowIterator, m_nLeftColumn ); aCell.isValid(); @@ -1090,29 +1028,23 @@ namespace svt { namespace table ) { bool isSelectedColumn = false; - ::com::sun::star::uno::Any rCellData; - if(!aCellData.empty() && iter != aCellData.begin()+m_nLeftColumn+nActualCols) + Size siz = m_rAntiImpl.GetSizePixel(); + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; + ::com::sun::star::uno::Any rCellData = aCellContent[aRowIterator.getRow()][aCell.getColumn()]; + if(rCellData>>=xGraphic) { - rCellData = *iter; - if(iter < aCellData.end()-1) - ++iter; - Size siz = m_rAntiImpl.GetSizePixel(); - ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; - if(rCellData>>=xGraphic) - { - Image* pImage = new Image(xGraphic); - if(pImage!=NULL) - pRenderer->PaintCellImage( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, + Image* pImage = new Image(xGraphic); + if(pImage!=NULL) + pRenderer->PaintCellImage( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, *m_pDataWindow, aCell.getRect(), rStyle, pImage ); - } - else - { - ::rtl::OUString sContent = impl_convertToString(rCellData); - pRenderer->PaintCellString( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, + } + else + { + ::rtl::OUString sContent = impl_convertToString(rCellData); + pRenderer->PaintCellString( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, *m_pDataWindow, aCell.getRect(), rStyle, sContent ); - } + } } - } } } //-------------------------------------------------------------------- @@ -2250,7 +2182,7 @@ namespace svt { namespace table //no region selected else { - if(m_pTableControl->m_nRowSelected.empty() + if(m_pTableControl->m_nRowSelected.empty()) m_pTableControl->m_nRowSelected.push_back(curRow); else { -- cgit From ee6e797e37f1657e47c530205d0162c6a886850d Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Thu, 25 Mar 2010 11:49:27 +0100 Subject: gridcontrol_03:scrollbar update after resizing bug fixed --- svtools/source/table/tablecontrol.cxx | 2 +- svtools/source/table/tablecontrol_impl.cxx | 6 ++---- svtools/source/table/tablecontrol_impl.hxx | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 4785248fbea6..3d8fedd2977e 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -177,7 +177,7 @@ namespace svt { namespace table { Rectangle _rRect; if(_bRemoved) - m_pImpl->invalidateRows(_nRowStart, _rRect); + m_pImpl->invalidateRows(); else { if(m_bSelectionChanged) diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index bd5f188e3889..d145e61b9274 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -899,7 +899,7 @@ namespace svt { namespace table { if(m_bResizingGrid) impl_ni_updateColumnWidths(); - impl_ni_updateScrollbars(); + invalidateRows(); m_bResizingGrid = true; } } @@ -1614,10 +1614,8 @@ namespace svt { namespace table m_nCurRow = _nRowPos-1; } //------------------------------------------------------------------------------ - void TableControl_Impl::invalidateRows(RowPos _nRowStart, Rectangle& _rCellRect) + void TableControl_Impl::invalidateRows() { - (void)_nRowStart; - (void)_rCellRect; impl_ni_updateScrollbars(); TableSize nVisibleRows = impl_getVisibleRows(true); if(m_nTopRow+nVisibleRows>m_nRowCount && m_nRowCount>=nVisibleRows) diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 8494e73d5ce9..bf22d8b3cd4e 100644 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -200,7 +200,7 @@ namespace svt { namespace table std::vector& getSelectedRows(); /** updates the vector, which contains the selected rows after removing the row nRowPos*/ void removeSelectedRow(RowPos _nRowPos); - void invalidateRows(RowPos _nRowStart, Rectangle& _rCellRect ); + void invalidateRows(); // IAbstractTableControl virtual void hideCursor(); -- cgit From de55cd16378a12c2360e3c600af84ffb9ffffe84 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 26 Mar 2010 17:45:16 +0100 Subject: gridcontrol_03:improvements --- svtools/inc/svtools/table/tablecontrol.hxx | 4 +- svtools/source/table/tablecontrol.cxx | 24 ++-------- svtools/source/table/tablecontrol_impl.cxx | 71 ++++++++++++++--------------- svtools/source/table/tablecontrol_impl.hxx | 42 +++++++++-------- svtools/source/uno/svtxgridcontrol.cxx | 11 +++-- svtools/source/uno/unocontroltablemodel.cxx | 12 ++--- 6 files changed, 75 insertions(+), 89 deletions(-) diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 3c91e31e1b00..839d4f73ebd6 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -71,8 +71,8 @@ namespace svt { namespace table DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); TableControl_Impl* m_pImpl; - ::com::sun::star::uno::Sequence< sal_Int32 >& m_nCols; - ::com::sun::star::uno::Sequence< ::rtl::OUString >& m_aText; + ::com::sun::star::uno::Sequence< sal_Int32 > m_nCols; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aText; Link m_aSelectHdl; bool m_bSelectionChanged; public: diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 3d8fedd2977e..01da79e2056e 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -68,8 +68,6 @@ namespace svt { namespace table TableControl::TableControl( Window* _pParent, WinBits _nStyle ) :Control( _pParent, _nStyle ) ,m_pImpl( new TableControl_Impl( *this ) ) - ,m_nCols(*( new ::com::sun::star::uno::Sequence< sal_Int32 >(0) )) - ,m_aText(*( new ::com::sun::star::uno::Sequence< ::rtl::OUString >(0) )) ,m_bSelectionChanged(false) { m_pImpl->getDataWindow()->SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) ); @@ -339,11 +337,7 @@ namespace svt { namespace table ::com::sun::star::uno::Any cellContent = ::com::sun::star::uno::Any(::rtl::OUString::createFromAscii("")); std::vector >& aTableContent = GetModel()->getCellContent(); if(&aTableContent) - { - std::vector< ::com::sun::star::uno::Any >& aRowContent = aTableContent[_nRowPos]; - if(&aRowContent) - cellContent = aRowContent[_nColPos]; - } + cellContent = aTableContent[_nRowPos][_nColPos]; return cellContent; } // ----------------------------------------------------------------------------- @@ -351,7 +345,7 @@ namespace svt { namespace table ::rtl::OUString TableControl::GetAccessibleCellText( sal_Int32 _nRowPos, sal_Int32 _nColPos) { ::com::sun::star::uno::Any cellContent = GetCellContent(_nRowPos, _nColPos); - return m_pImpl->impl_convertToString(cellContent); + return m_pImpl->convertToString(cellContent); } // ----------------------------------------------------------------------------- @@ -525,23 +519,13 @@ void TableControl::commitGridControlEvent( sal_Int16 _nEventId, const Any& _rNew Rectangle TableControl::calcHeaderRect(sal_Bool _bIsColumnBar,BOOL _bOnScreen) { (void)_bOnScreen; - Rectangle aRectTable, aRectTableWithHeaders; - m_pImpl->impl_getAllVisibleDataCellArea(aRectTable); - m_pImpl->impl_getAllVisibleCellsArea(aRectTableWithHeaders); - Size aSizeTable(aRectTable.GetSize()); - Size aSizeTableWithHeaders(aRectTableWithHeaders.GetSize()); - if(_bIsColumnBar) - return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width()-aSizeTable.Width(), aSizeTableWithHeaders.Height())); - else - return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width(), aSizeTableWithHeaders.Height()-aSizeTable.Height())); + return m_pImpl->calcHeaderRect(_bIsColumnBar); } // ----------------------------------------------------------------------------- Rectangle TableControl::calcTableRect(BOOL _bOnScreen) { (void)_bOnScreen; - Rectangle aRect; - m_pImpl->impl_getAllVisibleDataCellArea(aRect); - return aRect; + return m_pImpl->calcTableRect(); } //-------------------------------------------------------------------- ::com::sun::star::uno::Sequence< sal_Int32 >& TableControl::getColumnsForTooltip() diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index d145e61b9274..9ef171bf6c8c 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -234,7 +234,7 @@ namespace svt { namespace table } virtual std::vector >& getCellContent() { - return *( new std::vector >); + return m_aCellContent; } virtual void setRowHeaderName(const std::vector& ) { @@ -247,6 +247,7 @@ namespace svt { namespace table } private: std::vector aRowHeaderNames; + std::vector > m_aCellContent; }; @@ -1040,7 +1041,7 @@ namespace svt { namespace table } else { - ::rtl::OUString sContent = impl_convertToString(rCellData); + ::rtl::OUString sContent = convertToString(rCellData); pRenderer->PaintCellString( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, *m_pDataWindow, aCell.getRect(), rStyle, sContent ); } @@ -1806,28 +1807,19 @@ namespace svt { namespace table return m_pDataWindow; } //------------------------------------------------------------------------------- - BOOL TableControl_Impl::isRowSelected(::std::vector selectedRows, RowPos current) + BOOL TableControl_Impl::isRowSelected(const ::std::vector& selectedRows, RowPos current) { - for(::std::vector::iterator it=selectedRows.begin(); - it!=selectedRows.end();++it) - { - if(*it == current) - return TRUE; - } - return FALSE; + return ::std::find(selectedRows.begin(),selectedRows.end(),current) != selectedRows.end(); } //------------------------------------------------------------------------------- - int TableControl_Impl::getRowSelectedNumber(::std::vector selectedRows, RowPos current) + int TableControl_Impl::getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current) { - int pos = -1; - int i = 0; - for(std::vector::iterator it=selectedRows.begin();it!=selectedRows.end();++it) + std::vector::const_iterator it = ::std::find(selectedRows.begin(),selectedRows.end(),current); + if ( it != selectedRows.end() ) { - if(*it == current) - return pos = i; - ++i; + return it - selectedRows.begin(); } - return pos; + return -1; } //------------------------------------------------------------------------------- void TableControl_Impl::setTooltip(const Point& rPoint ) @@ -1843,21 +1835,13 @@ namespace svt { namespace table if(i==0) { ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; - ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; - if(content>>=xGraphic) - aTooltipText=::rtl::OUString::createFromAscii(""); - else - aTooltipText = impl_convertToString(content); + aTooltipText = convertToString(content); } else { aTooltipText+= ::rtl::OUString::createFromAscii("\n"); ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; - ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; - if(content>>=xGraphic) - aTooltipText += ::rtl::OUString::createFromAscii(""); - else - aTooltipText += impl_convertToString(content); + aTooltipText += convertToString(content); } } } @@ -1887,11 +1871,7 @@ namespace svt { namespace table if(i==0) { ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; - ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; - if(content>>=xGraphic) - aTooltipText = ::rtl::OUString::createFromAscii(""); - else - aTooltipText = text[i] + impl_convertToString(content); + aTooltipText = text[i] + convertToString(content); } else { @@ -1901,10 +1881,7 @@ namespace svt { namespace table { ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; - if(content>>=xGraphic) - aTooltipText +=::rtl::OUString::createFromAscii(""); - else - aTooltipText += impl_convertToString(content); + aTooltipText += convertToString(content); } } } @@ -2073,7 +2050,7 @@ namespace svt { namespace table m_nLeftColumn--; } //-------------------------------------------------------------------- - rtl::OUString TableControl_Impl::impl_convertToString(::com::sun::star::uno::Any value) + rtl::OUString TableControl_Impl::convertToString(const ::com::sun::star::uno::Any& value) { sal_Int32 nInt = 0; sal_Bool bBool = false; @@ -2090,6 +2067,24 @@ namespace svt { namespace table sNewString = sConvertString.valueOf(fDouble); return sNewString; } + Rectangle TableControl_Impl::calcHeaderRect(bool bColHeader) + { + Rectangle aRectTable, aRectTableWithHeaders; + impl_getAllVisibleDataCellArea(aRectTable); + impl_getAllVisibleCellsArea(aRectTableWithHeaders); + Size aSizeTable(aRectTable.GetSize()); + Size aSizeTableWithHeaders(aRectTableWithHeaders.GetSize()); + if(bColHeader) + return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width()-aSizeTable.Width(), aSizeTableWithHeaders.Height())); + else + return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width(), aSizeTableWithHeaders.Height()-aSizeTable.Height())); + } + Rectangle TableControl_Impl::calcTableRect() + { + Rectangle aRect; + impl_getAllVisibleDataCellArea(aRect); + return aRect; + } //-------------------------------------------------------------------- IMPL_LINK( TableControl_Impl, OnScroll, ScrollBar*, _pScrollbar ) { diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index bf22d8b3cd4e..61fcda7ceb71 100644 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -189,9 +189,9 @@ namespace svt { namespace table void setCursorAtCurrentCell(const Point& rPoint); /** checks whether the vector with the selected rows contains the current row*/ - BOOL isRowSelected(::std::vector selectedRows, RowPos current); + BOOL isRowSelected(const ::std::vector& selectedRows, RowPos current); /** returns the position of the current row in the selection vector */ - int getRowSelectedNumber(::std::vector selectedRows, RowPos current); + int getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current); /** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/ void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect ); /** to be called when a new row is added to the control*/ @@ -213,25 +213,10 @@ namespace svt { namespace table virtual bool endResizeColumn(const Point& rPoint); TableDataWindow* getDataWindow(); - /** retrieves the area occupied by the totality of (at least partially) visible cells - The returned area includes row and column headers. Also, it takes into - account the the fact that there might be less columns than would normally - find room in the control. - - As a result of respecting the partial visibility of rows and columns, - the returned area might be larger than the data window's output size. - */ - void impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const; - - /** retrieves the area occupied by all (at least partially) visible data cells. - - Effectively, the returned area is the same as returned by ->impl_getAllVisibleCellsArea, - minus the row and column header areas. - */ - void impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const; - - ::rtl::OUString impl_convertToString(::com::sun::star::uno::Any _value); + ::rtl::OUString convertToString(const ::com::sun::star::uno::Any& _value); + Rectangle calcHeaderRect(bool bColHeader); + Rectangle calcTableRect(); private: /** toggles the cursor visibility @@ -316,6 +301,23 @@ namespace svt { namespace table column range were reached. */ TableSize impl_ni_ScrollColumns( TableSize _nRowDelta ); + /** retrieves the area occupied by the totality of (at least partially) visible cells + + The returned area includes row and column headers. Also, it takes into + account the the fact that there might be less columns than would normally + find room in the control. + + As a result of respecting the partial visibility of rows and columns, + the returned area might be larger than the data window's output size. + */ + void impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const; + + /** retrieves the area occupied by all (at least partially) visible data cells. + + Effectively, the returned area is the same as returned by ->impl_getAllVisibleCellsArea, + minus the row and column header areas. + */ + void impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const; void impl_ni_getAccVisibleColWidths(); void impl_updateLeftColumn(); diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index a9a61bbee1b1..5be2c71c9f52 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -372,7 +372,6 @@ Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru return Any ( m_xDataModel ); case BASEPROPERTY_GRID_COLUMNMODEL: return Any ( m_xColumnModel); - case BASEPROPERTY_TABSTOP: case BASEPROPERTY_HSCROLL: return Any ( m_bHScroll); case BASEPROPERTY_VSCROLL: @@ -463,6 +462,8 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri TableControl* pTable = (TableControl*)GetWindow(); if(Event.index == -1) { + if(!isSelectionEmpty()) + deselectAllRows(); if(m_pTableModel->hasRowHeaders()) m_pTableModel->getRowHeaderName().clear(); m_pTableModel->getCellContent().clear(); @@ -475,8 +476,12 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri } else if(Event.index >= 0 && Event.index < m_pTableModel->getRowCount()) { - pTable->RemoveSelectedRow(Event.index); - + if(isSelectedIndex(Event.index)) + { + Sequence selected(1); + selected[0]=Event.index; + deselectRows(selected); + } if(m_pTableModel->hasRowHeaders()) m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index); std::vector >::iterator rowPos =m_pTableModel->getCellContent().begin() + Event.index; diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 3dca0cbf4425..d239ee3c740d 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -169,7 +169,7 @@ using namespace ::com::sun::star::uno; //==================================================================== struct UnoControlTableModel_Impl { - ::std::vector< PColumnModel >& aColumns; + ::std::vector< PColumnModel > aColumns; TableSize nRowCount; bool bHasColumnHeaders; bool bHasRowHeaders; @@ -180,8 +180,8 @@ using namespace ::com::sun::star::uno; TableMetrics nRowHeight; TableMetrics nColumnHeaderHeight; TableMetrics nRowHeaderWidth; - std::vector& aRowHeadersTitle; - std::vector >& aCellContent; + std::vector aRowHeadersTitle; + std::vector > aCellContent; ::com::sun::star::util::Color m_xLineColor; ::com::sun::star::util::Color m_xHeaderColor; ::com::sun::star::util::Color m_xTextColor; @@ -190,7 +190,7 @@ using namespace ::com::sun::star::uno; ::com::sun::star::style::VerticalAlignment m_xVerticalAlign; UnoControlTableModel_Impl() - :aColumns ( *(new std::vector< PColumnModel> (0))) + :aColumns ( ) ,nRowCount ( 0 ) ,bHasColumnHeaders ( false ) ,bHasRowHeaders ( false ) @@ -201,8 +201,8 @@ using namespace ::com::sun::star::uno; ,nRowHeight ( 0 ) ,nColumnHeaderHeight( 0 ) ,nRowHeaderWidth ( 10 ) - ,aRowHeadersTitle ( *(new std::vector(0))) - ,aCellContent ( *(new std::vector >(0)) ) + ,aRowHeadersTitle ( ) + ,aCellContent ( ) ,m_xLineColor ( 0xFFFFFF ) ,m_xHeaderColor ( 0xFFFFFF ) ,m_xTextColor ( 0 )//black as default -- cgit From de4206aebc147755cda52f369571a2a4c212e4df Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 26 Mar 2010 19:05:51 +0100 Subject: sw33bf03: #i107240#: SvXMLMetaExport: export elements without whitespace --- xmloff/source/meta/xmlmetae.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xmloff/source/meta/xmlmetae.cxx b/xmloff/source/meta/xmlmetae.cxx index a124a7c016d1..7b6ab702875c 100644 --- a/xmloff/source/meta/xmlmetae.cxx +++ b/xmloff/source/meta/xmlmetae.cxx @@ -478,7 +478,9 @@ SvXMLMetaExport::startElement(const ::rtl::OUString & i_rName, } // finally, start the element - mrExport.StartElement(i_rName, sal_True); //FIXME:whitespace? + // #i107240# no whitespace here, because the DOM may already contain + // whitespace, which is not cleared when loading and thus accumulates. + mrExport.StartElement(i_rName, (m_level > 1) ? sal_False : sal_True); ++m_level; } -- cgit From 5d58845170113179d5bc9e60d2411196b8d30240 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 26 Mar 2010 19:38:34 +0100 Subject: sw33bf03: #i110408#: SwXFlatParagraph: apply patch by dtardon --- sw/inc/unoflatpara.hxx | 12 ++++++++++-- sw/source/core/unocore/unoflatpara.cxx | 30 +++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/sw/inc/unoflatpara.hxx b/sw/inc/unoflatpara.hxx index e092a6d28c82..70af89580ec5 100644 --- a/sw/inc/unoflatpara.hxx +++ b/sw/inc/unoflatpara.hxx @@ -32,6 +32,7 @@ #define _UNOFLATPARA_HXX #include +#include #include #include #include @@ -54,9 +55,10 @@ class SwDoc; ******************************************************************************/ class SwXFlatParagraph: - public ::cppu::WeakImplHelper1 + public ::cppu::WeakImplHelper2 < - css::text::XFlatParagraph + css::text::XFlatParagraph, + css::lang::XUnoTunnel >, public SwXTextMarkup { @@ -88,6 +90,12 @@ public: const SwTxtNode* getTxtNode() const; + static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 >& rId) + throw (css::uno::RuntimeException); + private: SwXFlatParagraph( const SwXFlatParagraph & ); // not defined SwXFlatParagraph & operator = ( const SwXFlatParagraph & ); // not defined diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index d68fc43a3abc..e857a3b21af7 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -33,6 +33,7 @@ #include +#include #include #include @@ -268,6 +269,24 @@ css::uno::Sequence< ::sal_Int32 > SAL_CALL SwXFlatParagraph::getLanguagePortions return css::uno::Sequence< ::sal_Int32>(); } + +const uno::Sequence< sal_Int8 >& +SwXFlatParagraph::getUnoTunnelId() +{ + static uno::Sequence aSeq(CreateUnoTunnelId()); + return aSeq; +} + + +sal_Int64 SAL_CALL +SwXFlatParagraph::getSomething( + const uno::Sequence< sal_Int8 >& rId) + throw (uno::RuntimeException) +{ + return sw::UnoTunnelImpl(rId, this); +} + + /****************************************************************************** * SwXFlatParagraphIterator ******************************************************************************/ @@ -429,8 +448,9 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaAfter(co if (!mpDoc) return xRet; - text::XFlatParagraph* pFP = xPara.get(); - SwXFlatParagraph* pFlatParagraph = static_cast(pFP); + const uno::Reference xFPTunnel(xPara, uno::UNO_QUERY); + OSL_ASSERT(xFPTunnel.is()); + SwXFlatParagraph* const pFlatParagraph(sw::UnoTunnelGetImplementation(xFPTunnel)); if ( !pFlatParagraph ) return xRet; @@ -475,8 +495,9 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaBefore(c if (!mpDoc) return xRet; - text::XFlatParagraph* pFP = xPara.get(); - SwXFlatParagraph* pFlatParagraph = static_cast(pFP); + const uno::Reference xFPTunnel(xPara, uno::UNO_QUERY); + OSL_ASSERT(xFPTunnel.is()); + SwXFlatParagraph* const pFlatParagraph(sw::UnoTunnelGetImplementation(xFPTunnel)); if ( !pFlatParagraph ) return xRet; @@ -511,4 +532,3 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaBefore(c return xRet; } - -- cgit From 824add304ad68e5cfae6742195a1a2c93f131295 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 29 Mar 2010 09:39:35 +0100 Subject: ab75: #i110417# initial ( untested ) implementation --- scp2/source/gnome/file_gnome.scp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scp2/source/gnome/file_gnome.scp b/scp2/source/gnome/file_gnome.scp index 9d10261843d2..166e75d19bb4 100644 --- a/scp2/source/gnome/file_gnome.scp +++ b/scp2/source/gnome/file_gnome.scp @@ -47,7 +47,7 @@ File gid_File_Lib_Gnomevfs Regmergefile = "ucpgvfs-ucd.txt"; End #endif - +#if 0 #if (defined ENABLE_GNOMEVFS && defined ENABLE_LOCKDOWN) || defined ENABLE_GIO File gid_File_Share_Registry_Gnome_Xcd TXT_FILE_BODY; @@ -56,6 +56,7 @@ File gid_File_Share_Registry_Gnome_Xcd Name = "gnome.xcd"; End #endif +#endif #ifdef ENABLE_GCONF File gid_File_Lib_Gconfbe -- cgit From da50ceb5c035c8b70b4483d32e02851902bd7421 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 29 Mar 2010 09:39:35 +0100 Subject: ab75: #i110417# initial ( untested ) implementation --- basic/inc/basic/sberrors.hxx | 3 + basic/source/classes/errobject.cxx | 181 +++++++++++++++++++++++++++++++++++++ basic/source/classes/makefile.mk | 18 +++- basic/source/classes/sb.cxx | 1 + basic/source/classes/sb.src | 6 ++ basic/source/inc/errobject.hxx | 16 ++++ basic/source/runtime/runtime.cxx | 32 +++++++ basic/source/runtime/stdobj.cxx | 6 ++ basic/source/runtime/step0.cxx | 8 +- basic/source/runtime/step1.cxx | 4 + 10 files changed, 270 insertions(+), 5 deletions(-) create mode 100644 basic/source/classes/errobject.cxx create mode 100644 basic/source/inc/errobject.hxx diff --git a/basic/inc/basic/sberrors.hxx b/basic/inc/basic/sberrors.hxx index c21b3b0237b8..c34176e0bde7 100644 --- a/basic/inc/basic/sberrors.hxx +++ b/basic/inc/basic/sberrors.hxx @@ -287,6 +287,8 @@ typedef ULONG SbError; #define ERRCODE_BASIC_LOOP_NOT_INIT ((LAST_SBX_ERROR_ID+109UL) | ERRCODE_AREA_SBX | \ ERRCODE_CLASS_COMPILER) // For loop not initialized +#define ERRCODE_BASIC_COMPAT ((LAST_SBX_ERROR_ID+103UL)| ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) + // Map old codes to new codes #define SbERR_SYNTAX ERRCODE_BASIC_SYNTAX #define SbERR_NO_GOSUB ERRCODE_BASIC_NO_GOSUB @@ -410,6 +412,7 @@ typedef ULONG SbError; #define SbERR_PROG_TOO_LARGE ERRCODE_BASIC_PROG_TOO_LARGE #define SbERR_NO_STRINGS_ARRAYS ERRCODE_BASIC_NO_STRINGS_ARRAYS #define SbERR_BASIC_EXCEPTION ERRCODE_BASIC_EXCEPTION +#define SbERR_BASIC_COMPAT ERRCODE_BASIC_COMPAT #define SbERR_BASIC_ARRAY_FIX ERRCODE_BASIC_ARRAY_FIX #define SbERR_BASIC_STRING_OVERFLOW ERRCODE_BASIC_STRING_OVERFLOW #define SbERR_BASIC_EXPR_TOO_COMPLEX ERRCODE_BASIC_EXPR_TOO_COMPLEX diff --git a/basic/source/classes/errobject.cxx b/basic/source/classes/errobject.cxx new file mode 100644 index 000000000000..dc62e65b6945 --- /dev/null +++ b/basic/source/classes/errobject.cxx @@ -0,0 +1,181 @@ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_basic.hxx" +#include "errobject.hxx" + +#include +#include +#include "sbintern.hxx" +#include "runtime.hxx" + +using namespace ::com::sun::star; +using namespace ::ooo; + +typedef ::cppu::WeakImplHelper2< vba::XErrObject, script::XDefaultProperty > ErrObjectImpl_BASE; + +class ErrObject : public ErrObjectImpl_BASE +{ + rtl::OUString m_sHelpFile; + rtl::OUString m_sSource; + rtl::OUString m_sDescription; + sal_Int32 m_nNumber; + sal_Int32 m_nHelpContext; + +public: + ErrObject(); + ~ErrObject(); + // Attributes + virtual ::sal_Int32 SAL_CALL getNumber() throw (uno::RuntimeException); + virtual void SAL_CALL setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getHelpContext() throw (uno::RuntimeException); + virtual void SAL_CALL setHelpContext( ::sal_Int32 _helpcontext ) throw (uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getHelpFile() throw (uno::RuntimeException); + virtual void SAL_CALL setHelpFile( const ::rtl::OUString& _helpfile ) throw (uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDescription() throw (uno::RuntimeException); + virtual void SAL_CALL setDescription( const ::rtl::OUString& _description ) throw (uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSource() throw (uno::RuntimeException); + virtual void SAL_CALL setSource( const ::rtl::OUString& _source ) throw (uno::RuntimeException); + + // Methods + virtual void SAL_CALL Clear( ) throw (uno::RuntimeException); + virtual void SAL_CALL Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException); + // XDefaultProperty + virtual ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (uno::RuntimeException); +}; + + +ErrObject::~ErrObject() +{ +} + +ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0) +{ +} + +sal_Int32 SAL_CALL +ErrObject::getNumber() throw (uno::RuntimeException) +{ + return m_nNumber; +} + +void SAL_CALL +ErrObject::setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException) +{ + m_nNumber = _number; + + +} + +::sal_Int32 SAL_CALL +ErrObject::getHelpContext() throw (uno::RuntimeException) +{ + return m_nHelpContext; +} +void SAL_CALL +ErrObject::setHelpContext( ::sal_Int32 _helpcontext ) throw (uno::RuntimeException) +{ + m_nHelpContext = _helpcontext; +} + +::rtl::OUString SAL_CALL +ErrObject::getHelpFile() throw (uno::RuntimeException) +{ + return m_sHelpFile; +} + +void SAL_CALL +ErrObject::setHelpFile( const ::rtl::OUString& _helpfile ) throw (uno::RuntimeException) +{ + m_sHelpFile = _helpfile; +} + +::rtl::OUString SAL_CALL +ErrObject::getDescription() throw (uno::RuntimeException) +{ + return m_sDescription; +} + +void SAL_CALL +ErrObject::setDescription( const ::rtl::OUString& _description ) throw (uno::RuntimeException) +{ + m_sDescription = _description; +} + +::rtl::OUString SAL_CALL +ErrObject::getSource() throw (uno::RuntimeException) +{ + return m_sSource; +} + +void SAL_CALL +ErrObject::setSource( const ::rtl::OUString& _source ) throw (uno::RuntimeException) +{ + m_sSource = _source; +} + +// Methods +void SAL_CALL +ErrObject::Clear( ) throw (uno::RuntimeException) +{ + m_sHelpFile = rtl::OUString(); + m_sSource = m_sHelpFile; + m_sDescription = m_sSource; + m_nNumber = 0; + m_nHelpContext = 0; +} + +void SAL_CALL +ErrObject::Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException) +{ + if ( !Number.hasValue() ) + throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference< uno::XInterface >() ); + Description >>= m_sDescription; + Source >>= m_sSource; + HelpFile >>= m_sHelpFile; + HelpContext >>= m_nHelpContext; + Number >>= m_nNumber; + if ( m_nNumber ) + { + SbError n = StarBASIC::GetSfxFromVBError( m_nNumber ); + if ( !n ) + n = m_nNumber; // force orig number, probably should have a specific table of vb ( localized ) errors + pINST->Error( n, m_sDescription ); + } +} + +// XDefaultProperty +::rtl::OUString SAL_CALL +ErrObject::getDefaultPropertyName( ) throw (uno::RuntimeException) +{ + static rtl::OUString sDfltPropName( RTL_CONSTASCII_USTRINGPARAM("Number") ); + return sDfltPropName; +} + +// SbxErrObject +SbxErrObject::SbxErrObject( const String& rName, const Any& rUnoObj ): SbUnoObject( rName, rUnoObj ) +{ + OSL_TRACE("SbxErrObject::SbxErrObject ctor"); + rUnoObj >>= m_xErr; + if ( m_xErr.is() ) + SetDfltProperty( uno::Reference< script::XDefaultProperty >( m_xErr, uno::UNO_QUERY_THROW )->getDefaultPropertyName() ) ; +} + +SbxErrObject::~SbxErrObject() +{ + OSL_TRACE("SbxErrObject::~SbxErrObject dtor"); +} + +uno::Reference< vba::XErrObject > +SbxErrObject::getUnoErrObject() +{ + SbxVariable* pVar = getErrObject(); + SbxErrObject* pGlobErr = static_cast< SbxErrObject* >( pVar ); + return pGlobErr->m_xErr; +} + +SbxVariableRef +SbxErrObject::getErrObject() +{ + static SbxVariableRef pGlobErr = new SbxErrObject( String( RTL_CONSTASCII_USTRINGPARAM("Err")), uno::makeAny( uno::Reference< vba::XErrObject >( new ErrObject() ) ) ); + return pGlobErr; +} + diff --git a/basic/source/classes/makefile.mk b/basic/source/classes/makefile.mk index eb5486f02abf..e00ed4674cc1 100644 --- a/basic/source/classes/makefile.mk +++ b/basic/source/classes/makefile.mk @@ -37,18 +37,28 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk +ALLTAR .SEQUENTIAL : \ + $(MISC)$/$(TARGET).don \ + $(MISC)$/$(TARGET).slo + +$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb + +$(CPPUMAKER) -O$(OUT)$/inc -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@ + echo $@ + +$(MISC)$/$(TARGET).slo : $(SLOTARGET) + echo $@ + # --- Allgemein ----------------------------------------------------------- -COMMON_SLOFILES= \ +SLOFILES= \ $(SLO)$/sb.obj \ $(SLO)$/sbxmod.obj \ $(SLO)$/image.obj \ $(SLO)$/sbintern.obj \ $(SLO)$/sbunoobj.obj \ $(SLO)$/propacc.obj \ - $(SLO)$/disas.obj - -SLOFILES= $(COMMON_SLOFILES) \ + $(SLO)$/disas.obj \ + $(SLO)$/errobject.obj \ $(SLO)$/eventatt.obj OBJFILES= \ diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index c5ac53c43092..60f4de70c2be 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -215,6 +215,7 @@ const SFX_VB_ErrorItem __FAR_DATA SFX_VB_ErrorTab[] = { 1004, SbERR_METHOD_FAILED }, { 1005, SbERR_SETPROP_FAILED }, { 1006, SbERR_GETPROP_FAILED }, + { 1007, SbERR_BASIC_COMPAT }, { 0xFFFF, 0xFFFFFFFFL } // End mark }; diff --git a/basic/source/classes/sb.src b/basic/source/classes/sb.src index 926da0359d7e..41ae03d9934f 100644 --- a/basic/source/classes/sb.src +++ b/basic/source/classes/sb.src @@ -588,6 +588,12 @@ Resource RID_BASIC_START { Text [ en-US ] = "For loop not initialized." ; }; + String ERRCODE_BASIC_COMPAT & ERRCODE_RES_MASK + { + Text [ de ] = "$(ARG1)." ; + Text [ en-US ] = "$(ARG1)." ; + Text [ x-comment ] = " "; + }; }; // Hinweis: IDS_SBERR_TERMINATED = IDS_SBERR_START+2000. String IDS_SBERR_TERMINATED diff --git a/basic/source/inc/errobject.hxx b/basic/source/inc/errobject.hxx new file mode 100644 index 000000000000..51d4b6caa4f9 --- /dev/null +++ b/basic/source/inc/errobject.hxx @@ -0,0 +1,16 @@ +#ifndef ERROBJECT_HXX +#define ERROBJECT_HXX +#include "sbunoobj.hxx" +#include + + +class SbxErrObject : public SbUnoObject +{ + com::sun::star::uno::Reference< ooo::vba::XErrObject > m_xErr; + SbxErrObject( const String& aName_, const com::sun::star::uno::Any& aUnoObj_ ); + ~SbxErrObject(); +public: + static SbxVariableRef getErrObject(); + static com::sun::star::uno::Reference< ooo::vba::XErrObject > getUnoErrObject(); +}; +#endif diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 52aa76e2f2df..75ff47c73486 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -43,6 +43,7 @@ #include #include #include "sbunoobj.hxx" +#include "errobject.hxx" bool SbiRuntime::isVBAEnabled() { @@ -794,7 +795,38 @@ BOOL SbiRuntime::Step() void SbiRuntime::Error( SbError n ) { if( n ) + { nError = n; + if ( isVBAEnabled() ) + { + String aMsg = pInst->GetErrorMsg(); + // If a message is defined use that ( in preference to + // the defined one for the error ) NB #TODO + // if there is an error defined it more than likely + // is not the one you want ( some are the same though ) + // we really need a new vba compatible error list + if ( !aMsg.Len() ) + { + StarBASIC::MakeErrorText( n, aMsg ); + aMsg = StarBASIC::GetErrorText(); + if ( !aMsg.Len() ) // no message for err no. + // need localized resource here + aMsg = String( RTL_CONSTASCII_USTRINGPARAM("Internal Object Error:") ); + } + // no num? most likely then it *is* really a vba err + SbxErrObject::getUnoErrObject()->setNumber( ( StarBASIC::GetVBErrorCode( n ) == 0 ) ? n : StarBASIC::GetVBErrorCode( n ) ); + SbxErrObject::getUnoErrObject()->setDescription( aMsg ); + + // prepend an error number to the message. + String aTmp = '\''; + aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() ); + aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") ); + aTmp += aMsg; + + pInst->aErrorMsg = aTmp; + nError = SbERR_BASIC_COMPAT; + } + } } void SbiRuntime::Error( SbError _errCode, const String& _details ) diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index c0b4ffa3cd59..d2585501c826 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -33,6 +33,7 @@ #include #include "rtlproto.hxx" #include "sbintern.hxx" +#include "errobject.hxx" // Das nArgs-Feld eines Tabelleneintrags ist wie folgt verschluesselt: // Zur Zeit wird davon ausgegangen, dass Properties keine Parameter @@ -652,6 +653,11 @@ SbiStdObject::~SbiStdObject() SbxVariable* SbiStdObject::Find( const String& rName, SbxClassType t ) { + // #TODO #FIXME hack for substituting ooo-basic Err with vba-ish + // ErrObject object + static String sErr( RTL_CONSTASCII_USTRINGPARAM("Err") ); + if ( rName.EqualsIgnoreCaseAscii( sErr ) ) + return SbxErrObject::getErrObject(); // Bereits eingetragen? SbxVariable* pVar = SbxObject::Find( rName, t ); if( !pVar ) diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 33df854a4499..b432d1851ed5 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -30,6 +30,7 @@ #include #include +#include "errobject.hxx" #include "runtime.hxx" #include "sbintern.hxx" #include "iosys.hxx" @@ -1116,6 +1117,7 @@ void SbiRuntime::StepSTDERROR() pInst->nErr = 0L; pInst->nErl = 0; nError = 0L; + SbxErrObject::getUnoErrObject()->Clear(); } void SbiRuntime::StepNOERROR() @@ -1124,6 +1126,7 @@ void SbiRuntime::StepNOERROR() pInst->nErr = 0L; pInst->nErl = 0; nError = 0L; + SbxErrObject::getUnoErrObject()->Clear(); bError = FALSE; } @@ -1132,6 +1135,9 @@ void SbiRuntime::StepNOERROR() void SbiRuntime::StepLEAVE() { bRun = FALSE; + // If VBA and we are leaving an ErrorHandler then clear the error ( it's been processed ) + if ( bInError && pError ) + SbxErrObject::getUnoErrObject()->Clear(); } void SbiRuntime::StepCHANNEL() // TOS = Kanalnummer @@ -1265,6 +1271,6 @@ void SbiRuntime::StepERROR() SbxVariableRef refCode = PopVar(); USHORT n = refCode->GetUShort(); SbError error = StarBASIC::GetSfxFromVBError( n ); - Error( error ); + pInst->Error( error ); } diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx index 399257cf6ad3..2161f3d1dd09 100644 --- a/basic/source/runtime/step1.cxx +++ b/basic/source/runtime/step1.cxx @@ -35,6 +35,7 @@ #include "iosys.hxx" #include "image.hxx" #include "sbunoobj.hxx" +#include "errobject.hxx" bool checkUnoObjectType( SbUnoObject* refVal, const String& aClass ); @@ -360,6 +361,7 @@ void SbiRuntime::StepERRHDL( UINT32 nOp1 ) pInst->nErr = 0; pInst->nErl = 0; nError = 0; + SbxErrObject::getUnoErrObject()->Clear(); } // Resume nach Fehlern (+0=statement, 1=next or Label) @@ -380,6 +382,8 @@ void SbiRuntime::StepRESUME( UINT32 nOp1 ) } else pCode = pErrStmnt; + if ( pError ) // current in error handler ( and got a Resume Next statment ) + SbxErrObject::getUnoErrObject()->Clear(); if( nOp1 > 1 ) StepJUMP( nOp1 ); -- cgit From bf03c0de2e93eeeceb27d8eeb980849bdcca3ffd Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 29 Mar 2010 09:51:16 +0100 Subject: ab75: #i110417# revert unintended local change to scp2 --- scp2/source/gnome/file_gnome.scp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scp2/source/gnome/file_gnome.scp b/scp2/source/gnome/file_gnome.scp index 166e75d19bb4..9d10261843d2 100644 --- a/scp2/source/gnome/file_gnome.scp +++ b/scp2/source/gnome/file_gnome.scp @@ -47,7 +47,7 @@ File gid_File_Lib_Gnomevfs Regmergefile = "ucpgvfs-ucd.txt"; End #endif -#if 0 + #if (defined ENABLE_GNOMEVFS && defined ENABLE_LOCKDOWN) || defined ENABLE_GIO File gid_File_Share_Registry_Gnome_Xcd TXT_FILE_BODY; @@ -56,7 +56,6 @@ File gid_File_Share_Registry_Gnome_Xcd Name = "gnome.xcd"; End #endif -#endif #ifdef ENABLE_GCONF File gid_File_Lib_Gconfbe -- cgit From 7e1bf0010d130597d5658a117737e7d9747dee91 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 30 Mar 2010 12:51:35 +0200 Subject: sw33bf03: #i110454#: fix ASSERT from WW8Export::ExportDocument_Impl() --- sw/inc/shellio.hxx | 7 ++++--- sw/source/filter/rtf/rtfatr.cxx | 4 ++-- sw/source/filter/writer/writer.cxx | 16 +++++++++------- sw/source/filter/ww8/wrtww8.cxx | 8 ++++---- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 45d413ced105..9208659d9f66 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -439,13 +439,14 @@ class SW_DLLPUBLIC Writer : public SvRefBase SwAsciiOptions aAscOpts; String sBaseURL; + SvStream * m_pStream; + void _AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ); void _AddFontItems( SfxItemPool& rPool, USHORT nWhichId ); protected: Writer_Impl* pImpl; - SvStream* pStrm; SwPaM* pOrigPam; // der letze zu bearbeitende Pam const String* pOrigFileName; @@ -537,9 +538,9 @@ public: inline SvStream& OutLong( long nVal ) { return OutLong( Strm(), nVal ); } inline SvStream& OutULong( ULONG nVal ) { return OutULong( Strm(), nVal ); } - void SetStrm( SvStream& rStrm ) { pStrm = &rStrm; } + void SetStream(SvStream *const pStream) { m_pStream = pStream; } #ifndef DBG_UTIL - SvStream& Strm() { return *pStrm; } + SvStream& Strm() { return *m_pStream; } #else SvStream& Strm(); #endif diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx index ecbcfbfe7c7f..b5e2f7b316ea 100644 --- a/sw/source/filter/rtf/rtfatr.cxx +++ b/sw/source/filter/rtf/rtfatr.cxx @@ -513,12 +513,12 @@ void OutRTF_SwFlyFrmFmt( SwRTFWriter& rRTFWrt ) // ueberhaupt eigene Attribute gibt ! SvMemoryStream aTmpStrm; SvStream* pSaveStrm = &rRTFWrt.Strm(); - rRTFWrt.SetStrm( aTmpStrm ); + rRTFWrt.SetStream( &aTmpStrm ); rRTFWrt.bRTFFlySyntax = false; OutRTF_SwFmt( rRTFWrt, *rRTFWrt.pFlyFmt ); - rRTFWrt.SetStrm( *pSaveStrm ); // Stream-Pointer wieder zurueck + rRTFWrt.SetStream( pSaveStrm ); // Stream-Pointer wieder zurueck if ( aTmpStrm.GetEndOfData() ) // gibt es SWG spezifische Attribute? { diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index 2ed742255173..66ad4f87b699 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -145,7 +145,9 @@ void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk) */ Writer::Writer() - : pImpl(0), pStrm(0), pOrigPam(0), pOrigFileName(0), pDoc(0), pCurPam(0) + : pImpl(0) + , m_pStream(0) + , pOrigPam(0), pOrigFileName(0), pDoc(0), pCurPam(0) { bWriteAll = bShowProgress = bUCS2_WithStartChar = true; bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR = @@ -181,7 +183,7 @@ void Writer::ResetWriter() pCurPam = 0; pOrigFileName = 0; pDoc = 0; - pStrm = 0; + m_pStream = 0; bShowProgress = bUCS2_WithStartChar = TRUE; bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR = @@ -253,8 +255,8 @@ SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, #ifdef DBG_UTIL SvStream& Writer::Strm() { - ASSERT( pStrm, "Oh-oh. Dies ist ein Storage-Writer. Gleich knallts!" ); - return *pStrm; + ASSERT( m_pStream, "Oh-oh. Writer with no Stream!" ); + return *m_pStream; } #endif @@ -318,7 +320,7 @@ ULONG Writer::Write( SwPaM& rPaM, SvStream& rStrm, const String* pFName ) return nResult; } - pStrm = &rStrm; + m_pStream = &rStrm; pDoc = rPaM.GetDoc(); pOrigFileName = pFName; pImpl = new Writer_Impl( *pDoc ); @@ -590,7 +592,7 @@ ULONG StgWriter::WriteStream() ULONG StgWriter::Write( SwPaM& rPaM, SvStorage& rStg, const String* pFName ) { - pStrm = 0; + SetStream(0); pStg = &rStg; pDoc = rPaM.GetDoc(); pOrigFileName = pFName; @@ -611,7 +613,7 @@ ULONG StgWriter::Write( SwPaM& rPaM, SvStorage& rStg, const String* pFName ) ULONG StgWriter::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >& rStg, const String* pFName, SfxMedium* pMedium ) { - pStrm = 0; + SetStream(0); pStg = 0; xStg = rStg; pDoc = rPaM.GetDoc(); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 9eb8fec9de7c..709fa282e6cb 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2982,7 +2982,6 @@ void WW8Export::ExportDocument_Impl() pFib = new WW8Fib( bWrtWW8 ? 8 : 6 ); - SvStream* pOldStrm = &(Strm()); // JP 19.05.99: wozu das ??? SvStorageStreamRef xWwStrm( GetWriter().GetStorage().OpenSotStream( aMainStg ) ); SvStorageStreamRef xTableStrm( xWwStrm ), xDataStrm( xWwStrm ); xWwStrm->SetBufferSize( 32768 ); @@ -3002,7 +3001,7 @@ void WW8Export::ExportDocument_Impl() xDataStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); } - GetWriter().SetStrm( *xWwStrm ); + GetWriter().SetStream( & *xWwStrm ); pTableStrm = &xTableStrm; pDataStrm = &xDataStrm; @@ -3024,7 +3023,8 @@ void WW8Export::ExportDocument_Impl() { bEncrypt =true; - GetWriter().SetStrm( *aTempMain.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ) ); + GetWriter().SetStream( + aTempMain.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ) ); pTableStrm = aTempTable.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); @@ -3176,7 +3176,7 @@ void WW8Export::ExportDocument_Impl() delete pPiece; delete pDop; delete pFib; - GetWriter().SetStrm( *pOldStrm ); + GetWriter().SetStream( 0 ); xWwStrm->SetBufferSize( 0 ); -- cgit From 386916453e828dc02912ccaa44fb262217a1f362 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 30 Mar 2010 12:52:28 +0200 Subject: sw33bf03: #i110455#: fix inverted ASSERT in MSWordStyles::WriteProperties() --- sw/source/filter/ww8/wrtw8sty.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 8e6b0c77b878..7051639a4b3a 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -438,7 +438,8 @@ void MSWordStyles::WriteProperties( const SwFmt* pFmt, bool bParProp, USHORT nPo m_rExport.OutputFormat( *pFmt, bParProp, !bParProp ); - ASSERT( m_rExport.pCurrentStyle != pFmt, "current style was changed" ); // reset current style... + ASSERT( m_rExport.pCurrentStyle == pFmt, "current style was changed" ); + // reset current style... m_rExport.pCurrentStyle = NULL; if ( bInsDefCharSiz ) // nicht abgeleitet v. anderem Style -- cgit From 6302434c682f559337bb3b4efc8e2d6ceadd9341 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 7 Apr 2010 17:00:09 +0100 Subject: npower13_objectmodule: fold in review comments from ab --- basic/source/classes/sbxmod.cxx | 2 +- basic/source/runtime/methods.cxx | 46 ++++++++++++++++++++++----------------- basic/source/runtime/methods1.cxx | 2 ++ 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 87855035eb2e..ab655c88ce10 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1539,7 +1539,7 @@ SbObjModule::Find( const XubString& rName, SbxClassType t ) { //OSL_TRACE("SbObjectModule find for %s", rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr() ); SbxVariable* pVar = NULL; - if ( !pVar && pDocObject) + if ( pDocObject) pVar = pDocObject->Find( rName, t ); if ( !pVar ) pVar = SbModule::Find( rName, t ); diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index e1b704cb8918..816576d173e8 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -4110,17 +4110,20 @@ RTLFUNC(Load) // Diesen Call einfach an das Object weiterreichen SbxBase* pObj = (SbxObject*)rPar.Get(1)->GetObject(); - if( pObj && pObj->IsA( TYPE( SbUserFormModule ) ) ) + if ( pObj ) { - SbUserFormModule* pFormModule = ( SbUserFormModule* )pObj; - pFormModule->load(); - } - else if( pObj && pObj->IsA( TYPE( SbxObject ) ) ) - { - SbxVariable* pVar = ((SbxObject*)pObj)-> - Find( String( RTL_CONSTASCII_USTRINGPARAM("Load") ), SbxCLASS_METHOD ); - if( pVar ) - pVar->GetInteger(); + if( pObj->IsA( TYPE( SbUserFormModule ) ) ) + { + SbUserFormModule* pFormModule = ( SbUserFormModule* )pObj; + pFormModule->load(); + } + else if( pObj->IsA( TYPE( SbxObject ) ) ) + { + SbxVariable* pVar = ((SbxObject*)pObj)-> + Find( String( RTL_CONSTASCII_USTRINGPARAM("Load") ), SbxCLASS_METHOD ); + if( pVar ) + pVar->GetInteger(); + } } } @@ -4138,17 +4141,20 @@ RTLFUNC(Unload) // Diesen Call einfach an das Object weitereichen SbxBase* pObj = (SbxObject*)rPar.Get(1)->GetObject(); - if( pObj && pObj->IsA( TYPE( SbUserFormModule ) ) ) + if ( pObj ) { - SbUserFormModule* pFormModule = ( SbUserFormModule* )pObj; - pFormModule->Unload(); - } - else if( pObj && pObj->IsA( TYPE( SbxObject ) ) ) - { - SbxVariable* pVar = ((SbxObject*)pObj)-> - Find( String( RTL_CONSTASCII_USTRINGPARAM("Unload") ), SbxCLASS_METHOD ); - if( pVar ) - pVar->GetInteger(); + if( pObj->IsA( TYPE( SbUserFormModule ) ) ) + { + SbUserFormModule* pFormModule = ( SbUserFormModule* )pObj; + pFormModule->Unload(); + } + else if( pObj->IsA( TYPE( SbxObject ) ) ) + { + SbxVariable* pVar = ((SbxObject*)pObj)-> + Find( String( RTL_CONSTASCII_USTRINGPARAM("Unload") ), SbxCLASS_METHOD ); + if( pVar ) + pVar->GetInteger(); + } } } diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index dbdeee8197c2..b25c213a493d 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -2601,6 +2601,8 @@ RTLFUNC(Me) SbObjModule* pMod = PTR_CAST(SbObjModule,pActiveModule); if ( pMod ) refVar->PutObject( pMod ); + else + StarBASIC::Error( SbERR_INVALID_USAGE_OBJECT ); } else refVar->PutObject( pClassModuleObject ); -- cgit From 9f1c59d9dfc18d8e95ebac1ee55c0e50f227270f Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 7 Apr 2010 17:00:09 +0100 Subject: npower13_objectmodule: fold in review comments from ab --- offapi/com/sun/star/script/ModuleInfo.idl | 55 +++++++++++++++++++++++++++++ offapi/com/sun/star/script/ModuleType.idl | 58 +++++++++++++++++++++++++++++++ offapi/com/sun/star/script/makefile.mk | 2 ++ udkapi/com/sun/star/script/ModuleInfo.idl | 55 ----------------------------- udkapi/com/sun/star/script/ModuleType.idl | 58 ------------------------------- udkapi/com/sun/star/script/makefile.mk | 2 -- 6 files changed, 115 insertions(+), 115 deletions(-) create mode 100644 offapi/com/sun/star/script/ModuleInfo.idl create mode 100644 offapi/com/sun/star/script/ModuleType.idl delete mode 100644 udkapi/com/sun/star/script/ModuleInfo.idl delete mode 100644 udkapi/com/sun/star/script/ModuleType.idl diff --git a/offapi/com/sun/star/script/ModuleInfo.idl b/offapi/com/sun/star/script/ModuleInfo.idl new file mode 100644 index 000000000000..ea7684692e8e --- /dev/null +++ b/offapi/com/sun/star/script/ModuleInfo.idl @@ -0,0 +1,55 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ModuleInfo.idl,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef __com_sun_star_script_ModuleInfo_idl__ +#define __com_sun_star_script_ModuleInfo_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif + +//============================================================================= +module com { module sun { module star { module script { +struct ModuleInfo +{ + com::sun::star::uno::XInterface ModuleObject; + short ModuleType; +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/script/ModuleType.idl b/offapi/com/sun/star/script/ModuleType.idl new file mode 100644 index 000000000000..adf51e0dc6f1 --- /dev/null +++ b/offapi/com/sun/star/script/ModuleType.idl @@ -0,0 +1,58 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ModuleType.idl,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef __com_sun_star_script_ModuleType_idl__ +#define __com_sun_star_script_ModuleType_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include +#endif + +//============================================================================= +module com { module sun { module star { module script { +published constants ModuleType +{ + const long Unknown = 0; + const long Normal = 1; + const long Class = 2; + const long Form = 3; + const long Document = 4; +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/script/makefile.mk b/offapi/com/sun/star/script/makefile.mk index bc9b8c3d2ed2..b694a753f7d7 100644 --- a/offapi/com/sun/star/script/makefile.mk +++ b/offapi/com/sun/star/script/makefile.mk @@ -50,6 +50,8 @@ IDLFILES=\ ModuleSizeExceededRequest.idl\ XVBACompat.idl\ XVBAModuleInfo.idl\ + ModuleInfo.idl\ + ModuleType.idl\ # ------------------------------------------------------------------ diff --git a/udkapi/com/sun/star/script/ModuleInfo.idl b/udkapi/com/sun/star/script/ModuleInfo.idl deleted file mode 100644 index ea7684692e8e..000000000000 --- a/udkapi/com/sun/star/script/ModuleInfo.idl +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************* - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ModuleInfo.idl,v $ - * - * $Revision: 1.2 $ - * - * last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $ - * - * The Contents of this file are made available subject to - * the terms of GNU Lesser General Public License Version 2.1. - * - * - * GNU Lesser General Public License Version 2.1 - * ============================================= - * Copyright 2005 by Sun Microsystems, Inc. - * 901 San Antonio Road, Palo Alto, CA 94303, USA - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - * - ************************************************************************/ - -#ifndef __com_sun_star_script_ModuleInfo_idl__ -#define __com_sun_star_script_ModuleInfo_idl__ - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - -//============================================================================= -module com { module sun { module star { module script { -struct ModuleInfo -{ - com::sun::star::uno::XInterface ModuleObject; - short ModuleType; -}; - -//============================================================================= - -}; }; }; }; - -#endif diff --git a/udkapi/com/sun/star/script/ModuleType.idl b/udkapi/com/sun/star/script/ModuleType.idl deleted file mode 100644 index adf51e0dc6f1..000000000000 --- a/udkapi/com/sun/star/script/ModuleType.idl +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************* - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ModuleType.idl,v $ - * - * $Revision: 1.2 $ - * - * last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $ - * - * The Contents of this file are made available subject to - * the terms of GNU Lesser General Public License Version 2.1. - * - * - * GNU Lesser General Public License Version 2.1 - * ============================================= - * Copyright 2005 by Sun Microsystems, Inc. - * 901 San Antonio Road, Palo Alto, CA 94303, USA - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - * - ************************************************************************/ - -#ifndef __com_sun_star_script_ModuleType_idl__ -#define __com_sun_star_script_ModuleType_idl__ - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - -//============================================================================= -module com { module sun { module star { module script { -published constants ModuleType -{ - const long Unknown = 0; - const long Normal = 1; - const long Class = 2; - const long Form = 3; - const long Document = 4; -}; - -//============================================================================= - -}; }; }; }; - -#endif diff --git a/udkapi/com/sun/star/script/makefile.mk b/udkapi/com/sun/star/script/makefile.mk index 2c5388c10542..32aa58fefa6d 100644 --- a/udkapi/com/sun/star/script/makefile.mk +++ b/udkapi/com/sun/star/script/makefile.mk @@ -81,8 +81,6 @@ IDLFILES=\ XScriptEventsAttacher.idl\ XDefaultMethod.idl\ XDefaultProperty.idl\ - ModuleInfo.idl\ - ModuleType.idl\ # ------------------------------------------------------------------ -- cgit From 708b462a826eef5634275fa0400ec003c310619f Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 7 Apr 2010 17:02:52 +0100 Subject: npower13_objectmodule: #i110672# fix Application.ThisWorkbook ( from dr ) --- oovbaapi/ooo/vba/excel/XApplication.idl | 4 ---- vbahelper/inc/vbahelper/vbahelper.hxx | 2 ++ vbahelper/source/vbahelper/vbahelper.cxx | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl index 1a29a0d0c459..e4c063d161cf 100644 --- a/oovbaapi/ooo/vba/excel/XApplication.idl +++ b/oovbaapi/ooo/vba/excel/XApplication.idl @@ -61,10 +61,6 @@ interface XApplication : com::sun::star::uno::XInterface [attribute, readonly] XWorksheet ActiveSheet; [attribute, readonly] ooo::vba::XAssistant Assistant; [attribute] long Calculation; - //#TODO #FIXME this is more of a placeholder, will return - // the value of activeworkbook, in xl 'ThisWorkbook' should return the - // workbook in which the 'calling' macro is running. Should be possible - // to determine this [attribute, readonly] XWorkbook ThisWorkbook; [attribute, readonly] string Name; [attribute] boolean DisplayAlerts; diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx index 315ddb19b7ca..83b9737315ea 100644 --- a/vbahelper/inc/vbahelper/vbahelper.hxx +++ b/vbahelper/inc/vbahelper/vbahelper.hxx @@ -64,6 +64,8 @@ namespace ooo VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const css::uno::Sequence< css::uno::Any >& aArgs ) throw (css::uno::RuntimeException); css::uno::Reference< css::frame::XModel > getCurrentDoc( const rtl::OUString& sKey ) throw (css::uno::RuntimeException); + VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getThisExcelDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); + VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getThisWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentExcelDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 83bd677dd7de..ac8423d2ce3a 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -464,6 +464,18 @@ getCurrentDocCtx( const rtl::OUString& ctxName, const uno::Reference< uno::XComp return xModel; } +uno::Reference< frame::XModel > +getThisExcelDoc( const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException) +{ + return getCurrentDocCtx( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ExcelDocumentContext" ) ), xContext ); +} + +uno::Reference< frame::XModel > +getThisWordDoc( const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException) +{ + return getCurrentDocCtx( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("WordDocumentContext" ) ), xContext ); +} + uno::Reference< frame::XModel > getCurrentExcelDoc( const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException) { @@ -475,7 +487,7 @@ getCurrentExcelDoc( const uno::Reference< uno::XComponentContext >& xContext ) t } catch( uno::Exception& e ) { - xModel = getCurrentDocCtx( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ExcelDocumentContext" ) ), xContext ); + xModel = getThisExcelDoc( xContext ); } return xModel; } @@ -491,7 +503,7 @@ getCurrentWordDoc( const uno::Reference< uno::XComponentContext >& xContext ) th } catch( uno::Exception& e ) { - xModel = getCurrentDocCtx( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("WordDocumentContext" ) ), xContext ); + xModel = getThisWordDoc( xContext ); } return xModel; } -- cgit From 7d79523ba745c5e226eb5ccc9a00f7f494bd14b3 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 7 Apr 2010 17:02:52 +0100 Subject: npower13_objectmodule: #i110672# fix Application.ThisWorkbook ( from dr ) --- sc/source/ui/vba/vbaapplication.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 5d9e513dabeb..984c5b27c97b 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -132,10 +132,16 @@ ScVbaApplication::getActiveWorkbook() throw (uno::RuntimeException) { return new ActiveWorkbook( this, mxContext ); } + uno::Reference< excel::XWorkbook > SAL_CALL ScVbaApplication::getThisWorkbook() throw (uno::RuntimeException) { - return getActiveWorkbook(); + uno::Reference< frame::XModel > xModel = getThisExcelDoc(mxContext); + if( !xModel.is() ) + return uno::Reference< excel::XWorkbook >(); + + ScVbaWorkbook *pWb = new ScVbaWorkbook( this, mxContext, xModel ); + return uno::Reference< excel::XWorkbook > (pWb); } uno::Reference< XAssistant > SAL_CALL -- cgit From 198c81549d1c0a21236c4f1e2b84b695e8a4e8d6 Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Thu, 8 Apr 2010 16:47:53 +0200 Subject: #161974# restructure reading buildlist --- soldep/bootstrp/prj.cxx | 677 ++++++++++++++++------------------------------ soldep/inc/soldep/prj.hxx | 9 +- 2 files changed, 242 insertions(+), 444 deletions(-) diff --git a/soldep/bootstrp/prj.cxx b/soldep/bootstrp/prj.cxx index d13e08a05283..9fde614659b0 100644 --- a/soldep/bootstrp/prj.cxx +++ b/soldep/bootstrp/prj.cxx @@ -160,45 +160,34 @@ ByteString SimpleConfig::GetNextLine() ByteString SimpleConfig::GetCleanedNextLine( BOOL bReadComments ) /*****************************************************************************/ { + sal_Bool bStreamOk; + sal_Bool bReadNextLine = sal_True; + while (bReadNextLine) + { + bStreamOk = aFileStream.ReadLine ( aTmpStr ); + if (!bStreamOk) + return ByteString(); - aFileStream.ReadLine ( aTmpStr ); - if ( aTmpStr.Search( "#" ) == 0 ) - if (bReadComments ) - return aTmpStr; - else - while ( aTmpStr.Search( "#" ) == 0 ) - { - aFileStream.ReadLine ( aTmpStr ); - } + ByteString sTab = "\t"; + ByteString sDoubleTab = "\t\t"; + ByteString sSpace = " "; + xub_StrLen nIndex = 0; - aTmpStr = aTmpStr.EraseLeadingChars(); - aTmpStr = aTmpStr.EraseTrailingChars(); -// while ( aTmpStr.SearchAndReplace(String(' '),String('\t') ) != (USHORT)-1 ); - int nLength = aTmpStr.Len(); -// USHORT nPos = 0; - ByteString aEraseString; - BOOL bFirstTab = TRUE; - for ( USHORT i = 0; i<= nLength; i++) - { - if ( aTmpStr.GetChar( i ) == 0x20 ) - aTmpStr.SetChar( i, 0x09 ); + aTmpStr.SearchAndReplaceAll(sSpace, sTab); + while ( (nIndex = aTmpStr.SearchAndReplace(sDoubleTab, sTab, nIndex )) != STRING_NOTFOUND ); + + aTmpStr = aTmpStr.EraseLeadingAndTrailingChars('\t'); // remove tabs - if ( aTmpStr.GetChar( i ) == 0x09 ) + if ( aTmpStr.Search( "#" ) == 0 ) { - if ( bFirstTab ) - bFirstTab = FALSE; - else - { - aTmpStr.SetChar( i, 0x20 ); - } + if (bReadComments ) + return aTmpStr; } else - bFirstTab = TRUE; - + bReadNextLine = sal_False; } - aTmpStr.EraseAllChars(' '); - return aTmpStr; + return aTmpStr; } @@ -824,7 +813,8 @@ Prj::Prj() : bVisited( FALSE ), bIsAvailable( TRUE ), pTempCommandDataList (0), - bTempCommandDataListPermanent (FALSE) + bTempCommandDataListPermanent (FALSE), + bError (FALSE) /*****************************************************************************/ { } @@ -841,7 +831,8 @@ Prj::Prj( ByteString aName ) : bVisited( FALSE ), bIsAvailable( TRUE ), pTempCommandDataList (0), - bTempCommandDataListPermanent (FALSE) + bTempCommandDataListPermanent (FALSE), + bError (FALSE) /*****************************************************************************/ { } @@ -1146,6 +1137,7 @@ Prj& Prj::operator>> ( SvStream& rStream ) rStream << bFixedDependencies; rStream << bSorted; rStream << bIsAvailable; + rStream << bError; if (pPrjDepInfoList) { @@ -1178,6 +1170,7 @@ Prj& Prj::operator<< ( SvStream& rStream ) rStream >> bFixedDependencies; rStream >> bSorted; rStream >> bIsAvailable; + rStream >> bError; BOOL bDepList; rStream >> bDepList; @@ -1509,18 +1502,7 @@ void Star::Read( String &rFileName ) while( aFileList.Count()) { String ssFileName = *aFileList.GetObject(( ULONG ) 0 ); - ByteString sFileName_l(ssFileName, RTL_TEXTENCODING_ASCII_US); - StarFile *pFile = new StarFile( ssFileName ); - if ( pFile->Exists()) { -// if (sFileName_l.Len() >= RTL_CONSTASCII_LENGTH(XML_EXT) && ssFileName.EqualsAscii(XML_EXT, sFileName_l.Len() - RTL_CONSTASCII_LENGTH(XML_EXT), RTL_CONSTASCII_LENGTH(XML_EXT))) -// { -// ReadXmlBuildList(sFileName_l); -// } else { - SimpleConfig aSolarConfig( ssFileName ); - while (( aString = aSolarConfig.GetNext()) != "" ) - InsertToken (( char * ) aString.GetBuffer()); -// } - } + StarFile* pFile = ReadBuildlist (ssFileName); aMutex.acquire(); ReplaceFileEntry (&aLoadedFilesList, pFile); //aLoadedFilesList.Insert( pFile, LIST_APPEND ); @@ -1575,19 +1557,9 @@ void Star::Read( SolarFileList *pSolarFiles ) ByteString aString; String ssFileName = *pSolarFiles->GetObject(( ULONG ) 0 ); - ByteString sFileName_l(ssFileName, RTL_TEXTENCODING_ASCII_US); - StarFile *pFile = new StarFile( ssFileName ); + StarFile *pFile = ReadBuildlist ( ssFileName); if ( pFile->Exists()) { -// if (sFileName_l.Len() >= RTL_CONSTASCII_LENGTH(XML_EXT) && ssFileName.EqualsAscii(XML_EXT, sFileName_l.Len() - RTL_CONSTASCII_LENGTH(XML_EXT), RTL_CONSTASCII_LENGTH(XML_EXT))) -// { -// ReadXmlBuildList(sFileName_l); -// } else { - SimpleConfig aSolarConfig( ssFileName ); - while (( aString = aSolarConfig.GetNext()) != "" ) - InsertToken (( char * ) aString.GetBuffer()); -// } - DirEntry aEntry( pFile->GetName() ); DirEntry aEntryPrj = aEntry.GetPath().GetPath(); if (aEntryPrj.GetExtension() != String::CreateFromAscii( "" )) @@ -1721,207 +1693,259 @@ void Star::Expand_Impl() } /*****************************************************************************/ -void Star::InsertToken ( char *yytext ) +StarFile* Star::ReadBuildlist (const String& rFilename, BOOL bReadComments, BOOL bExtendAlias) +/*****************************************************************************/ +{ + ByteString sFileName_l(rFilename, RTL_TEXTENCODING_ASCII_US); + StarFile *pFile = new StarFile( rFilename ); + if ( pFile->Exists()) { + SimpleConfig aSolarConfig( rFilename ); + DirEntry aEntry(rFilename); + ByteString sProjectName (aEntry.GetPath().GetPath().GetName(), RTL_TEXTENCODING_ASCII_US); + Prj* pPrj = GetPrj (sProjectName); // 0, if Prj not found + if (pPrj) + { + Remove(pPrj); // Project exist, remove old Project and read again + DELETEZ (pPrj); // delete and set pPrj to 0 + } + ByteString aString; + while (( aString = aSolarConfig.GetCleanedNextLine( bReadComments )) != ByteString::EmptyString() ) + InsertTokenLine ( aString, &pPrj, sProjectName, bExtendAlias ); + } + return pFile; +} + +/*****************************************************************************/ +void Star::InsertTokenLine ( const ByteString& rTokenLine, Prj** ppPrj, const ByteString& rProjectName, const sal_Bool bExtendAlias ) /*****************************************************************************/ { - static int i = 0; - static ByteString aDirName, aWhat, aWhatOS, + int i = 0; + ByteString aWhat, aWhatOS, sClientRestriction, aLogFileName, aProjectName, aPrefix, aCommandPara; - static BOOL bPrjDep = FALSE; - static BOOL bHardDep = FALSE; - static BOOL bFixedDep = FALSE; - static int nCommandType, nOSType; + ByteString aDirName; + BOOL bPrjDep = FALSE; + BOOL bHardDep = FALSE; + BOOL bFixedDep = FALSE; + BOOL bNewProject = FALSE; + int nCommandType=0, nOSType=0; + Prj* pPrj = *ppPrj; CommandData* pCmdData; - static SByteStringList *pStaticDepList; - Prj* pPrj; + SByteStringList *pDepList = NULL; + ByteString aCommentString; + ByteString sToken; + ByteString sStringBuffer = rTokenLine; - switch (i) + while (sStringBuffer != ByteString::EmptyString()) { - case 0: - aPrefix = yytext; - pStaticDepList = 0; - break; - case 1: - aDirName = yytext; - aProjectName = aDirName.GetToken ( 0, 0x5c); - break; - case 2: - if ( !strcmp( yytext, ":" )) - { - bPrjDep = TRUE; - bHardDep = FALSE; - bFixedDep = FALSE; - i = 9; - } - else if ( !strcmp( yytext, "::" )) - { - bPrjDep = TRUE; - bHardDep = TRUE; - bFixedDep = FALSE; - i = 9; - } - else if ( !strcmp( yytext, ":::" )) - { - bPrjDep = TRUE; - bHardDep = TRUE; - bFixedDep = TRUE; - i = 9; - } - else - { - bPrjDep = FALSE; - bHardDep = FALSE; - bFixedDep = FALSE; + ByteString sToken = sStringBuffer.GetToken(0,'\t'); + sStringBuffer.Erase(0, sToken.Len()+1); - aWhat = yytext; - nCommandType = GetJobType(aWhat); - } - if (bPrjDep) - { - if ( HasProject( aProjectName )) + switch (i) + { + case 0: + if ( sToken.Search( "#" ) == 0 ) { - RemovePrj(GetPrj(aProjectName)); - // Projekt exist. schon, entfernen, später neue anlegen + i = -1; + aCommentString = sToken; + sStringBuffer = ByteString::EmptyString(); + if ( Count() == 0 ) + aDirName = "null_entry" ; //comments at begin of file } - } - break; - case 3: - if ( !bPrjDep ) - { - aWhat = yytext; - if ( aWhat == "-" ) + else { - aCommandPara = ByteString(); + aPrefix = sToken; + pDepList = 0; } - else - aCommandPara = aWhat; - } - break; - case 4: - if ( !bPrjDep ) - { - aWhatOS = yytext; - if ( aWhatOS.GetTokenCount( ',' ) > 1 ) { - sClientRestriction = aWhatOS.Copy( aWhatOS.GetToken( 0, ',' ).Len() + 1 ); - aWhatOS = aWhatOS.GetToken( 0, ',' ); + break; + case 1: + aDirName = sToken; + aProjectName = aDirName.GetToken ( 0, 0x5c); + if (aProjectName != rProjectName) + sStringBuffer = ByteString::EmptyString(); // something is wrong, ignore line + break; + case 2: + if ( sToken.CompareTo(":") == COMPARE_EQUAL ) + { + bPrjDep = TRUE; + bHardDep = FALSE; + bFixedDep = FALSE; + i = 9; } - nOSType = GetOSType (aWhatOS); - } - break; - case 5: - if ( !bPrjDep ) - { - aLogFileName = (ByteString(aProjectName).Append("_")).Append(yytext); - } - break; - default: - if ( !bPrjDep ) - { - ByteString aItem = yytext; - if ( aItem == "NULL" ) + else if ( sToken.CompareTo("::") == COMPARE_EQUAL ) { - // Liste zu Ende - i = -1; + bPrjDep = TRUE; + bHardDep = TRUE; + bFixedDep = FALSE; + i = 9; + } + else if ( sToken.CompareTo(":::") == COMPARE_EQUAL ) + { + bPrjDep = TRUE; + bHardDep = TRUE; + bFixedDep = TRUE; + i = 9; } else { - // ggfs. Dependency liste anlegen und ergaenzen - if ( !pStaticDepList ) - pStaticDepList = new SByteStringList; - ByteString* pStr = new ByteString ((ByteString (aProjectName).Append("_")).Append(aItem)); - pStaticDepList->PutString( pStr ); + bPrjDep = FALSE; + bHardDep = FALSE; + bFixedDep = FALSE; + + aWhat = sToken; + nCommandType = GetJobType(aWhat); } - } - else - { - ByteString aItem = yytext; - if ( aItem == "NULL" ) + if (bPrjDep) { - // Liste zu Ende - i = -1; - bPrjDep= FALSE; + if (pPrj) + sStringBuffer = ByteString::EmptyString(); // definition more than once or not first line, ignore line } - else + break; + case 3: + if ( !bPrjDep ) { - ByteString sMode; - BOOL bHasModes = FALSE; - if (aItem.Search(":") != STRING_NOTFOUND) + aWhat = sToken; + if ( aWhat == "-" ) { - sMode = aItem.GetToken ( 0, ':'); - aItem = aItem.GetToken ( 1, ':'); - bHasModes = TRUE; + aCommandPara = ByteString(); } + else + aCommandPara = aWhat; + } + break; + case 4: + if ( !bPrjDep ) + { + aWhatOS = sToken; + if ( aWhatOS.GetTokenCount( ',' ) > 1 ) { + sClientRestriction = aWhatOS.Copy( aWhatOS.GetToken( 0, ',' ).Len() + 1 ); + aWhatOS = aWhatOS.GetToken( 0, ',' ); + } + nOSType = GetOSType (aWhatOS); + } + break; + case 5: + if ( !bPrjDep ) + { + if (bExtendAlias) + aLogFileName = (ByteString(aProjectName).Append("_")).Append(sToken); + else + aLogFileName = sToken; - if ( HasProject( aProjectName )) + } + break; + default: + if ( !bPrjDep ) + { + ByteString aItem = sToken; + if ( aItem == "NULL" ) { - pPrj = GetPrj( aProjectName ); - // Projekt exist. schon, neue Eintraege anhaengen + // Liste zu Ende + i = -1; } else { - // neues Project anlegen - pPrj = new Prj ( aProjectName ); - pPrj->SetPreFix( aPrefix ); - Insert(pPrj,LIST_APPEND); + // ggfs. Dependency liste anlegen und ergaenzen + if ( !pDepList ) + pDepList = new SByteStringList; + ByteString* pStr; + if (bExtendAlias) + pStr = new ByteString ((ByteString (aProjectName).Append("_")).Append(aItem)); + else + pStr = new ByteString (aItem); + pDepList->PutString( pStr ); + } + } + else + { + ByteString aItem = sToken; + if ( aItem == "NULL" ) + { + // Liste zu Ende + i = -1; + bPrjDep= FALSE; } - if (bHasModes) - pPrj->AddDependencies( aItem, sMode ); else - pPrj->AddDependencies( aItem ); - pPrj->HasHardDependencies( bHardDep ); - pPrj->HasFixedDependencies( bFixedDep ); - -/* - if ( nStarMode == STAR_MODE_RECURSIVE_PARSE ) { - String sItem( aItem, RTL_TEXTENCODING_ASCII_US ); - InsertSolarList( sItem ); + { + ByteString sMode; + BOOL bHasModes = FALSE; + if (aItem.Search(":") != STRING_NOTFOUND) + { + sMode = aItem.GetToken ( 0, ':'); + aItem = aItem.GetToken ( 1, ':'); + bHasModes = TRUE; + } + if (!pPrj) + { + // neues Project anlegen + pPrj = new Prj ( aProjectName ); + pPrj->SetPreFix( aPrefix ); + bNewProject = TRUE; + } + if (bHasModes) + pPrj->AddDependencies( aItem, sMode ); + else + pPrj->AddDependencies( aItem ); + pPrj->HasHardDependencies( bHardDep ); + pPrj->HasFixedDependencies( bFixedDep ); } - */ } - } - break; + break; + } + if ( i == -1 ) + break; + i++; } /* Wenn dieses Project noch nicht vertreten ist, in die Liste der Solar-Projekte einfuegen */ if ( i == -1 ) { - if ( HasProject( aProjectName )) - { - pPrj = GetPrj( aProjectName ); - // Projekt exist. schon, neue Eintraege anhaengen - } - else + if (!pPrj) { // neues Project anlegen pPrj = new Prj ( aProjectName ); pPrj->SetPreFix( aPrefix ); - Insert(pPrj,LIST_APPEND); + bNewProject = TRUE; } + if (bNewProject) + Insert(pPrj,LIST_APPEND); + pCmdData = new CommandData; pCmdData->SetPath( aDirName ); pCmdData->SetCommandType( nCommandType ); pCmdData->SetCommandPara( aCommandPara ); pCmdData->SetOSType( nOSType ); pCmdData->SetLogFile( aLogFileName ); + pCmdData->SetComment( aCommentString ); pCmdData->SetClientRestriction( sClientRestriction ); - if ( pStaticDepList ) - pCmdData->SetDependencies( pStaticDepList ); + if ( pDepList ) + pCmdData->SetDependencies( pDepList ); - pStaticDepList = 0; + pDepList = 0; pPrj->Insert ( pCmdData, LIST_APPEND ); - aDirName =""; - aWhat =""; - aWhatOS = ""; - sClientRestriction = ""; - aLogFileName = ""; - nCommandType = 0; - nOSType = 0; - } - i++; - // und wer raeumt die depLst wieder ab ? - // CommandData macht das + // und wer raeumt die depLst wieder ab ? + // CommandData macht das + } + else + { + if (!pPrj) + { + // new project to set the error flag + pPrj = new Prj ( rProjectName ); + pPrj->SetPreFix( aPrefix ); + bNewProject = TRUE; + } + if (pPrj) + { + pPrj->SetError(); + if (bNewProject) + Insert(pPrj,LIST_APPEND); // add project even if there is a buildlist error + } + if ( pDepList ) + delete pDepList; + } + *ppPrj = pPrj; } /*****************************************************************************/ @@ -2572,19 +2596,7 @@ USHORT StarWriter::Read( String aFileName, BOOL bReadComments, USHORT nMode ) while( aFileList.Count()) { String ssFileName = *aFileList.GetObject(( ULONG ) 0 ); - ByteString sFileName_l(ssFileName, RTL_TEXTENCODING_ASCII_US); - StarFile *pFile = new StarFile( ssFileName ); - if ( pFile->Exists()) { -// if (sFileName_l.Len() >= RTL_CONSTASCII_LENGTH(XML_EXT) && ssFileName.EqualsAscii(XML_EXT, sFileName_l.Len() - RTL_CONSTASCII_LENGTH(XML_EXT), RTL_CONSTASCII_LENGTH(XML_EXT))) -// { -// ReadXmlBuildList(sFileName_l); -// } else { - SimpleConfig aSolarConfig( ssFileName ); - while (( aString = aSolarConfig.GetCleanedNextLine( bReadComments )) != "" ) - InsertTokenLine ( aString ); - } -// } - + StarFile* pFile = ReadBuildlist (ssFileName, bReadComments, FALSE); aMutex.acquire(); aLoadedFilesList.Insert( pFile, LIST_APPEND ); aMutex.release(); @@ -2608,21 +2620,7 @@ USHORT StarWriter::Read( SolarFileList *pSolarFiles, BOOL bReadComments ) while( pSolarFiles->Count()) { ByteString aString; String ssFileName = *pSolarFiles->GetObject(( ULONG ) 0 ); - ByteString sFileName_l(ssFileName, RTL_TEXTENCODING_ASCII_US); - StarFile *pFile = new StarFile( ssFileName); - if ( pFile->Exists()) { -// if (sFileName_l.Len() >= RTL_CONSTASCII_LENGTH(XML_EXT) && ssFileName.EqualsAscii(XML_EXT, sFileName_l.Len() - RTL_CONSTASCII_LENGTH(XML_EXT), RTL_CONSTASCII_LENGTH(XML_EXT))) -// { -// ReadXmlBuildList(sFileName_l); -// } -// else -// { - SimpleConfig aSolarConfig( ssFileName ); - while (( aString = aSolarConfig.GetCleanedNextLine( bReadComments )) != "" ) - InsertTokenLine ( aString ); -// } - } - + StarFile* pFile = ReadBuildlist(ssFileName, bReadComments, FALSE); aMutex.acquire(); aLoadedFilesList.Insert( pFile, LIST_APPEND ); aMutex.release(); @@ -2803,217 +2801,12 @@ USHORT StarWriter::WriteMultiple( String rSourceRoot ) } /*****************************************************************************/ -void StarWriter::InsertTokenLine ( ByteString& rString ) +void StarWriter::InsertTokenLine ( const ByteString& rTokenLine ) /*****************************************************************************/ { - int i = 0; - ByteString aWhat, aWhatOS, - sClientRestriction, aLogFileName, aProjectName, aPrefix, aCommandPara; - static ByteString aDirName; - BOOL bPrjDep = FALSE; - BOOL bHardDep = FALSE; - BOOL bFixedDep = FALSE; - int nCommandType=0, nOSType=0; - CommandData* pCmdData; - SByteStringList *pDepList2 = NULL; - Prj* pPrj; - - ByteString aEmptyString; - ByteString aToken = rString.GetToken( 0, '\t' ); - ByteString aCommentString; - - const char* yytext = aToken.GetBuffer(); - - while ( !( aToken == aEmptyString ) ) - { - switch (i) - { - case 0: - if ( rString.Search( "#" ) == 0 ) - { - i = -1; - aCommentString = rString; - rString = aEmptyString; - if ( Count() == 0 ) - aDirName = "null_entry" ; //comments at begin of file - break; - } - aPrefix = yytext; - pDepList2 = NULL; - break; - case 1: - aDirName = yytext; - break; - case 2: - if ( !strcmp( yytext, ":" )) - { - bPrjDep = TRUE; - bHardDep = FALSE; - bFixedDep = FALSE; - i = 9; - } - else if ( !strcmp( yytext, "::" )) - { - bPrjDep = TRUE; - bHardDep = TRUE; - bFixedDep = FALSE; - i = 9; - } - else if ( !strcmp( yytext, ":::" )) - { - bPrjDep = TRUE; - bHardDep = TRUE; - bFixedDep = TRUE; - i = 9; - } - else - { - bPrjDep = FALSE; - bHardDep = FALSE; - bFixedDep = FALSE; - - aWhat = yytext; - nCommandType = GetJobType(aWhat); - } - break; - case 3: - if ( !bPrjDep ) - { - aWhat = yytext; - if ( aWhat == "-" ) - { - aCommandPara = ByteString(); - } - else - aCommandPara = aWhat; - } - break; - case 4: - if ( !bPrjDep ) - { - aWhatOS = yytext; - if ( aWhatOS.GetTokenCount( ',' ) > 1 ) { - sClientRestriction = aWhatOS.Copy( aWhatOS.GetToken( 0, ',' ).Len() + 1 ); - aWhatOS = aWhatOS.GetToken( 0, ',' ); - } - nOSType = GetOSType (aWhatOS); - } - break; - case 5: - if ( !bPrjDep ) - { - aLogFileName = yytext; - } - break; - default: - if ( !bPrjDep ) - { - ByteString aItem = yytext; - if ( aItem == "NULL" ) - { - // Liste zu Ende - i = -1; - } - else - { - // ggfs. Dependency liste anlegen und ergaenzen - if ( !pDepList2 ) - pDepList2 = new SByteStringList; - pDepList2->PutString( new ByteString( aItem )); - } - } - else - { - ByteString aItem = yytext; - if ( aItem == "NULL" ) - { - // Liste zu Ende - i = -1; - bPrjDep= FALSE; - } - else - { - ByteString sMode; - BOOL bHasModes = FALSE; - if (aItem.Search(":") != STRING_NOTFOUND) - { - sMode = aItem.GetToken ( 0, ':'); - aItem = aItem.GetToken ( 1, ':'); - bHasModes = TRUE; - } - - aProjectName = aDirName.GetToken ( 0, 0x5c); - if ( HasProject( aProjectName )) - { - pPrj = GetPrj( aProjectName ); - // Projekt exist. schon, neue Eintraege anhaengen - } - else - { - // neues Project anlegen - pPrj = new Prj ( aProjectName ); - pPrj->SetPreFix( aPrefix ); - Insert(pPrj,LIST_APPEND); - } - if (bHasModes) - pPrj->AddDependencies( aItem, sMode ); - else - pPrj->AddDependencies( aItem ); - pPrj->HasHardDependencies( bHardDep ); - pPrj->HasFixedDependencies( bFixedDep ); - - /* - if ( nStarMode == STAR_MODE_RECURSIVE_PARSE ) { - String sItem( aItem, RTL_TEXTENCODING_ASCII_US ); - InsertSolarList( sItem ); - } - */ - } - - } - break; - } - /* Wenn dieses Project noch nicht vertreten ist, in die Liste - der Solar-Projekte einfuegen */ - if ( i == -1 ) - { - aProjectName = aDirName.GetToken ( 0, 0x5c); - if ( HasProject( aProjectName )) - { - pPrj = GetPrj( aProjectName ); - // Projekt exist. schon, neue Eintraege anhaengen - } - else - { - // neues Project anlegen - pPrj = new Prj ( aProjectName ); - pPrj->SetPreFix( aPrefix ); - Insert(pPrj,LIST_APPEND); - } - - pCmdData = new CommandData; - pCmdData->SetPath( aDirName ); - pCmdData->SetCommandType( nCommandType ); - pCmdData->SetCommandPara( aCommandPara ); - pCmdData->SetOSType( nOSType ); - pCmdData->SetLogFile( aLogFileName ); - pCmdData->SetComment( aCommentString ); - pCmdData->SetClientRestriction( sClientRestriction ); - if ( pDepList2 ) - pCmdData->SetDependencies( pDepList2 ); - - pPrj->Insert ( pCmdData, LIST_APPEND ); - - } - i++; - - rString.Erase(0, aToken.Len()+1); - aToken = rString.GetToken( 0, '\t' ); - yytext = aToken.GetBuffer(); - - } - // und wer raeumt die depLst wieder ab ? - // macht CommandData selber + ByteString sProjectName = rTokenLine.GetToken(1,'\t'); + Prj* pPrj = GetPrj (sProjectName); // 0, if Prj not found; + Star::InsertTokenLine ( rTokenLine, &pPrj, sProjectName, sal_False ); } /*****************************************************************************/ diff --git a/soldep/inc/soldep/prj.hxx b/soldep/inc/soldep/prj.hxx index b04d6ac1fe4e..53feb3c03cf5 100644 --- a/soldep/inc/soldep/prj.hxx +++ b/soldep/inc/soldep/prj.hxx @@ -287,6 +287,7 @@ private: SDepInfoList* RemoveDepInfoList(SDepInfoList* pInfoList ); PrjList* pTempCommandDataList; BOOL bTempCommandDataListPermanent; + BOOL bError; public: Prj(); Prj( ByteString aName ); @@ -329,6 +330,9 @@ public: void SetTempCommandDataListPermanent (BOOL bVar = TRUE) {bTempCommandDataListPermanent = bVar;} BOOL IsTempCommandDataListPermanent() {return bTempCommandDataListPermanent;} + void SetError (BOOL bVar = TRUE) {bError = bVar;} + BOOL HasError () {return bError;} + Prj& operator<< ( SvStream& rStream ); Prj& operator>> ( SvStream& rStream ); }; @@ -396,6 +400,7 @@ protected: void Expand_Impl(); void ExpandPrj_Impl( Prj *pPrj, Prj *pDepPrj ); ULONG SearchFileEntry( StarFileList *pStarFiles, StarFile* pFile ); + void InsertTokenLine (const ByteString& rToken, Prj** ppPrj, const ByteString& rProjectName, const sal_Bool bExtendAlias = sal_True); public: Star(); @@ -421,7 +426,7 @@ public: BOOL RemovePrj ( Prj* pPrj ); void RemoveAllPrj (); - void InsertToken( char *pChar ); + StarFile* ReadBuildlist (const String& rFilename, BOOL bReadComments = FALSE, BOOL bExtendAlias = TRUE); BOOL NeedsUpdate(); SolarFileList* NeedsFilesForUpdate(); void ReplaceFileEntry( StarFileList *pStarFiles, StarFile* pFile ); @@ -472,7 +477,7 @@ public: USHORT Write( String aFileName ); USHORT WriteMultiple( String rSourceRoot ); - void InsertTokenLine( ByteString& rString ); + void InsertTokenLine ( const ByteString& rTokenLine ); }; #endif -- cgit From 70f0bc6b7d0cfd4202626c670433859156bc3d3a Mon Sep 17 00:00:00 2001 From: npower Developer Date: Thu, 8 Apr 2010 16:36:31 +0100 Subject: npower13_objectmodule: fold in review comments ( for basctl ) --- basctl/source/basicide/baside2.cxx | 8 ++++++++ basctl/source/basicide/basides1.cxx | 2 ++ basctl/source/basicide/basidesh.cxx | 2 +- basctl/source/basicide/bastype2.cxx | 17 +++++++++-------- basctl/source/basicide/bastypes.cxx | 30 ++++++++++++++++-------------- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index c71ddeed788c..95671cd8ae47 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -210,6 +210,14 @@ ModulWindow::ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDoc SbModuleRef ModulWindow::XModule() { + // ModuleWindows can now be created as a result of the + // modules getting created via the api. This is a result of an + // elementInserted event from the BasicLibrary container. + // However the SbModule is also created from a different listener to + // the same event ( in basmgr ) Therefore it is possible when we look + // for xModule it may not yet be available, here we keep tring to access + // the module until such time as it exists + if ( !xModule.Is() ) { BasicManager* pBasMgr = GetDocument().getBasicManager(); diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 31391297f564..909a28543fae 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -1201,7 +1201,9 @@ IDEBaseWindow* BasicIDEShell::FindWindow( const ScriptDocument& rDocument, const else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rName && ( ( pWin->IsA( TYPE( ModulWindow ) ) && nType == BASICIDE_TYPE_MODULE ) || ( pWin->IsA( TYPE( DialogWindow ) ) && nType == BASICIDE_TYPE_DIALOG ) ) ) + { return pWin; + } } pWin = aIDEWindowTable.Next(); } diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index 9a5204ff36cf..e22103e3503c 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -282,7 +282,7 @@ __EXPORT BasicIDEShell::~BasicIDEShell() delete pObjectCatalog; DestroyModulWindowLayout(); - ContainerListenerImpl* pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() ); + ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() ); // Destroy all ContainerListeners for Basic Container. if ( pListener ) pListener->removeContainerListener( m_aCurDocument, m_aCurLibName ); diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index 6009ad9f2385..6132d81f9c65 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -395,14 +395,15 @@ void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const void BasicTreeListBox::ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName ) { - ::std::map< BasicEntryType, ::rtl::OUString > aEntryMap; - aEntryMap.insert( ::std::make_pair( OBJ_TYPE_DOCUMENT_OBJECTS, String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ); - aEntryMap.insert( ::std::make_pair( OBJ_TYPE_USERFORMS, String( IDEResId( RID_STR_USERFORMS ) ) ) ); - aEntryMap.insert( ::std::make_pair( OBJ_TYPE_NORMAL_MODULES, String( IDEResId( RID_STR_NORMAL_MODULES ) ) ) ); - aEntryMap.insert( ::std::make_pair( OBJ_TYPE_CLASS_MODULES, String( IDEResId( RID_STR_CLASS_MODULES ) ) ) ); - - ::std::map< BasicEntryType, ::rtl::OUString >::iterator iter; - for( iter = aEntryMap.begin(); iter != aEntryMap.end(); ++iter ) + + ::std::vector< std::pair< BasicEntryType, ::rtl::OUString > > aEntries; + aEntries.push_back( ::std::make_pair( OBJ_TYPE_DOCUMENT_OBJECTS, String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ); + aEntries.push_back( ::std::make_pair( OBJ_TYPE_USERFORMS, String( IDEResId( RID_STR_USERFORMS ) ) ) ); + aEntries.push_back( ::std::make_pair( OBJ_TYPE_NORMAL_MODULES, String( IDEResId( RID_STR_NORMAL_MODULES ) ) ) ); + aEntries.push_back( ::std::make_pair( OBJ_TYPE_CLASS_MODULES, String( IDEResId( RID_STR_CLASS_MODULES ) ) ) ); + + ::std::vector< std::pair< BasicEntryType, ::rtl::OUString > >::iterator iter; + for( iter = aEntries.begin(); iter != aEntries.end(); ++iter ) { BasicEntryType eType = iter->first; ::rtl::OUString aEntryName = iter->second; diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index 53f33dfc7e89..85dfa146e178 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -585,24 +585,26 @@ void __EXPORT BasicIDETabBar::Command( const CommandEvent& rCEvt ) aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE ); aPopup.RemoveDisabledEntries(); } - - // disable to delete or remove object modules in IDE - BasicManager* pBasMgr = aDocument.getBasicManager(); - if ( pBasMgr ) + if ( aDocument.isInVBAMode() ) { - StarBASIC* pBasic = pBasMgr->GetLib( aOULibName ); - if( pBasic ) + // disable to delete or remove object modules in IDE + BasicManager* pBasMgr = aDocument.getBasicManager(); + if ( pBasMgr ) { - IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable(); - IDEBaseWindow* pWin = aIDEWindowTable.Get( GetCurPageId() ); - if( pWin && pWin->ISA( ModulWindow ) ) + StarBASIC* pBasic = pBasMgr->GetLib( aOULibName ); + if( pBasic ) { - SbModule* pActiveModule = (SbModule*)pBasic->FindModule( pWin->GetName() ); - if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::Document ) ) + IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable(); + IDEBaseWindow* pWin = aIDEWindowTable.Get( GetCurPageId() ); + if( pWin && pWin->ISA( ModulWindow ) ) { - aPopup.EnableItem( SID_BASICIDE_DELETECURRENT, FALSE ); - aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE ); - } + SbModule* pActiveModule = (SbModule*)pBasic->FindModule( pWin->GetName() ); + if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::Document ) ) + { + aPopup.EnableItem( SID_BASICIDE_DELETECURRENT, FALSE ); + aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE ); + } + } } } } -- cgit From d93091832789fc586916720da62a341a731fbd66 Mon Sep 17 00:00:00 2001 From: gh93821 Date: Fri, 9 Apr 2010 13:46:38 +0200 Subject: add controltype for tablecontrol for testtool --- automation/source/server/sta_list.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/automation/source/server/sta_list.cxx b/automation/source/server/sta_list.cxx index 7f346c298563..c0abcb057f8b 100644 --- a/automation/source/server/sta_list.cxx +++ b/automation/source/server/sta_list.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #define WINDOW_ANYTYPE WINDOW_BASE @@ -999,6 +1000,8 @@ String StatementList::ClientTree(Window *pBase, int Indent) WRITEc("/RoadMap") else if ( dynamic_cast< svt::IExtensionListBox* >(pBase) ) WRITEc("/ExtensionListBox") + else if ( dynamic_cast< svt::table::TableControl* >(pBase) ) + WRITEc("/TableControl") else WRITEc("/Unknown") } -- cgit From 536fef4b613ed07e96145fffcf61dc4d7d426496 Mon Sep 17 00:00:00 2001 From: Gregor Hartmann Date: Fri, 9 Apr 2010 14:09:30 +0200 Subject: add methods for tablecontrol --- automation/source/server/statemnt.cxx | 149 ++++++++++++++++++++++++++++++++-- 1 file changed, 143 insertions(+), 6 deletions(-) diff --git a/automation/source/server/statemnt.cxx b/automation/source/server/statemnt.cxx index 68ff61bbaa0d..3b29ddd93544 100644 --- a/automation/source/server/statemnt.cxx +++ b/automation/source/server/statemnt.cxx @@ -82,6 +82,7 @@ #include #include #include +#include #include #include // Hat keinen Includeschutz @@ -128,9 +129,10 @@ using namespace com::sun::star::frame; using namespace com::sun::star::uno; -using namespace com::sun::star::util; +//using namespace com::sun::star::util; geht wegen Color nicht using namespace com::sun::star::beans; using namespace svt; +//using namespace svt::table; #ifndef SBX_VALUE_DECL_DEFINED @@ -618,7 +620,7 @@ BOOL StatementSlot::Execute() AddReferer(); if ( !aUnoUrl.Len() ) aUnoUrl = CUniString("slot:").Append( String::CreateFromInt32( nFunctionId ) ); - URL aTargetURL; + ::com::sun::star::util::URL aTargetURL; aTargetURL.Complete = aUnoUrl; Reference < XFramesSupplier > xDesktop = Reference < XFramesSupplier >( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.frame.Desktop") ), UNO_QUERY ); Reference < XFrame > xFrame; @@ -664,7 +666,7 @@ BOOL StatementSlot::Execute() ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_FRAME, aTargetURL.Complete ) ); else { - Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.util.URLTransformer" )), UNO_QUERY ); + Reference < ::com::sun::star::util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.util.URLTransformer" )), UNO_QUERY ); xTrans->parseStrict( aTargetURL ); Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY ); @@ -865,6 +867,13 @@ void StatementCommand::WriteControlData( Window *pBase, ULONG nConf, BOOL bFirst if ( bFirst ) pRet->GenReturn ( RET_WinInfo, SmartId(), (comm_ULONG)nConf | DH_MODE_DATA_VALID, UniString(), TRUE ); + if ( bFirst ) + { + if ( pBase->GetType() == WINDOW_WINDOW && pBase->GetParent() && pBase->GetParent()->GetType() == WINDOW_CONTROL && + dynamic_cast< svt::table::TableControl* > ( pBase->GetParent() ) ) + pBase = pBase->GetParent(); + } + { // Klammerung, so daß der String nicht während der Rekursion bestehen bleibt String aName; BOOL bSkip = FALSE; @@ -958,6 +967,8 @@ void StatementCommand::WriteControlData( Window *pBase, ULONG nConf, BOOL bFirst aTypeSuffix.AppendAscii( "/RoadMap", 8 ); else if ( dynamic_cast< IExtensionListBox* >(pBase) ) aTypeSuffix.AppendAscii( "/ExtensionListBox" ); + else if ( dynamic_cast< svt::table::TableControl* >(pBase) ) + aTypeSuffix.AppendAscii( "/TableControl" ); else aTypeSuffix.AppendAscii( "/Unknown", 8 ); } @@ -3388,17 +3399,17 @@ BOOL StatementCommand::Execute() { if( (nParams & PARAM_USHORT_1) ) { - Reference < XCancellable > xPicker; + Reference < ::com::sun::star::util::XCancellable > xPicker; switch( nNr1 ) { case CONST_FilePicker: { - xPicker.set( Reference < XCancellable >( svt::GetTopMostFilePicker(), UNO_QUERY ) ); + xPicker.set( Reference < ::com::sun::star::util::XCancellable >( svt::GetTopMostFilePicker(), UNO_QUERY ) ); } break; case CONST_FolderPicker: { - xPicker.set( Reference < XCancellable >( svt::GetTopMostFolderPicker(), UNO_QUERY ) ); + xPicker.set( Reference < ::com::sun::star::util::XCancellable >( svt::GetTopMostFolderPicker(), UNO_QUERY ) ); } break; default: @@ -5807,6 +5818,8 @@ BOOL StatementControl::Execute() nRealControlType = CONST_CTORoadmap; else if ( dynamic_cast< IExtensionListBox* >(pControl) ) nRealControlType = CONST_CTIExtensionListBox; + else if ( dynamic_cast< ::svt::table::TableControl* >(pControl) ) + nRealControlType = CONST_CTTableControl; else nRealControlType = CONST_CTUnknown; @@ -6148,6 +6161,130 @@ protected: } } break; + + case CONST_CTTableControl: + { + ::svt::table::TableControl *pTC = dynamic_cast< ::svt::table::TableControl* >(pControl); + switch ( nMethodId ) + { + case M_GetItemType : + { + if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetColumnCount() ) && + ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() )) + { + ::svt::table::PTableModel pModel = pTC->GetModel(); + Any aCell = pModel->getCellContent()[nNr1-1][nNr2-1]; + pRet->GenReturn ( RET_Value, aUId, String( aCell.getValueTypeName() )); + } + } + break; + case M_GetItemText : + { + if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetColumnCount() ) && + ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() )) + { + ::svt::table::PTableModel pModel = pTC->GetModel(); + Any aCell = pModel->getCellContent()[nNr1-1][nNr2-1]; + ::rtl::OUString aContent; + aCell >>= aContent; + pRet->GenReturn ( RET_Value, aUId, aContent ); + } + } + break; + case M_GetColumnCount : + { + pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTC->GetColumnCount() ); + } + break; + case M_GetRowCount : + { + pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTC->GetRowCount() ); + } + break; +/* case M_IsEditing : + { + CellControllerRef aControler; + aControler = pEBBox->Controller(); + pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)aControler.Is() ); + } + break; + case M_Select : + { + if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pEBBox->GetRowCount() ) ) + { + USHORT nColCount = pEBBox->GetColumnCount(); + comm_USHORT nUnfrozenColCount = 0; + USHORT i; + for ( i=0 ; i < nColCount ; i++ ) + { + if ( !pEBBox->IsFrozen( pEBBox->GetColumnId( i ) ) ) + nUnfrozenColCount++; + } + if ( ValueOK(aUId, MethodString( nMethodId ),nNr2,nUnfrozenColCount ) ) + pEBBox->GoToRowColumnId( nNr1-1, pEBBox->GetColumnId( nNr2 ) ); + } + } + break; + + + + + case M_GetSelCount : + pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount())); + break; + case M_GetSelIndex : + if ( ! (nParams & PARAM_USHORT_1) ) + nNr1 = 1; + if ( ValueOK(aUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) ) + { + nNr1--; + COUNT_LBOX( FirstSelected, NextSelected, nNr1); + pRet->GenReturn ( RET_Value, aUId, comm_ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 ); + } + break; + case M_GetSelText : + if ( ! (nParams & PARAM_USHORT_1) ) + nNr1 = 1; + if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) ) + { + nNr1--; + COUNT_LBOX( FirstSelected, NextSelected, nNr1); + GetFirstValidTextItem( pThisEntry ); + pRet->GenReturn ( RET_Value, aUId, pItem->GetText() ); + } + break; + case M_Select : + if ( ! (nParams & PARAM_BOOL_1) ) + bBool1 = TRUE; + if( nParams & PARAM_STR_1 ) + { + / * ListBox *pLB = ((ListBox*)pControl); + if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND ) + ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) ); + else + { + pLB->SelectEntry( aString1, bBool1 ); + if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL + ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) ); + } + * / ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) ); + } + else + { + if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) ) + { + SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 ); + ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 ); + } + } + break;*/ + default: + ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RoadMap" ) ); + break; + } + } + break; + case CONST_CTUnknown: ReportError( aUId, GEN_RES_STR2( S_UNKNOWN_TYPE, UniString::CreateFromInt32( nRT ), MethodString(nMethodId) ) ); break; -- cgit From 91959a7278da32ef9e44abb2b9b2fd35eb3a6195 Mon Sep 17 00:00:00 2001 From: Gregor Hartmann Date: Fri, 9 Apr 2010 14:11:22 +0200 Subject: new define CONST_CTTableControl --- automation/source/inc/rcontrol.hxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/automation/source/inc/rcontrol.hxx b/automation/source/inc/rcontrol.hxx index 829dd320beb6..7313603096b4 100644 --- a/automation/source/inc/rcontrol.hxx +++ b/automation/source/inc/rcontrol.hxx @@ -305,7 +305,7 @@ #define RC_Profile ( M_SOFFICE | M_MOZILLA | 9 ) // (Popup)Menu #define RC_MenuSelect ( M_SOFFICE | M_MOZILLA | 10 ) -#define RC_SetControlType ( M_SOFFICE | 11 ) +#define RC_SetControlType ( M_SOFFICE | 11 ) // deprecated since RTTI // RemoteFileAccess #define RC_Kill ( M_SOFFICE | 12 ) #define RC_RmDir ( M_SOFFICE | 13 ) @@ -429,14 +429,14 @@ -// Konstanten die im Basic zur Verfügung stehen sollen +// Constants which are available in VCLTestTool scripts -// Verschiedene Typen von Controls für den Befehl SetControlType -// !!!!!!!!!!! Müssen alle bei SetControlType eingetragen werden !!!!!!!!!!!! +// Different types of controls recognized via RTTI #define CONST_CTBrowseBox 100 #define CONST_CTValueSet 103 #define CONST_CTORoadmap 104 #define CONST_CTIExtensionListBox 105 +#define CONST_CTTableControl 106 #define CONST_CTUnknown 199 // Konstanten für das ALignment des gesuchten Splitters -- cgit From 2b9a5547b87c46bae38fe69f68e859eb8b4f8afa Mon Sep 17 00:00:00 2001 From: Gregor Hartmann Date: Fri, 9 Apr 2010 14:15:44 +0200 Subject: export TableControl for usage in VCLTestTool --- svtools/inc/svtools/table/tablecontrol.hxx | 54 ++++++++------------------ svtools/inc/svtools/table/tablemodel.hxx | 51 ++++++++++++------------ svtools/prj/d.lst | 2 + svtools/source/inc/accessibletableimp.hxx | 62 ++++++++++++++++++++++++++++++ svtools/source/table/tablecontrol.cxx | 1 + svtools/source/uno/svtxgridcontrol.cxx | 1 + 6 files changed, 109 insertions(+), 62 deletions(-) create mode 100644 svtools/source/inc/accessibletableimp.hxx diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 839d4f73ebd6..cfb4357eb5ac 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -27,13 +27,14 @@ #ifndef SVTOOLS_INC_TABLE_TABLECONTROL_HXX #define SVTOOLS_INC_TABLE_TABLECONTROL_HXX +#include "svtools/svtdllapi.h" #include #include #include #include #include -#include "svtaccessiblefactory.hxx" #include +#include //........................................................................ namespace svt { namespace table @@ -65,24 +66,24 @@ namespace svt { namespace table // TODO: scrolling? */ - class TableControl : public Control, public IAccessibleTable + class SVT_DLLPUBLIC TableControl : public Control, public IAccessibleTable { private: - DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); TableControl_Impl* m_pImpl; - ::com::sun::star::uno::Sequence< sal_Int32 > m_nCols; - ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aText; - Link m_aSelectHdl; - bool m_bSelectionChanged; + ::com::sun::star::uno::Sequence< sal_Int32 > m_nCols; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aText; + Link m_aSelectHdl; + bool m_bSelectionChanged; public: - ::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable; + ::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable; TableControl( Window* _pParent, WinBits _nStyle ); ~TableControl(); /// sets a new table model - void SetModel( PTableModel _pModel ); + SVT_DLLPRIVATE void SetModel( PTableModel _pModel ); /// retrieves the current table model PTableModel GetModel() const; @@ -152,9 +153,9 @@ namespace svt { namespace table { return GoTo( GetCurrentColumn(), _nRow ); } - virtual void Resize(); + SVT_DLLPRIVATE virtual void Resize(); virtual void Select(); - void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } + SVT_DLLPRIVATE void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } const Link& GetSelectHdl() const { return m_aSelectHdl; } /**invalidates the table if table has been changed e.g. new row added @@ -176,11 +177,11 @@ namespace svt { namespace table //virtual long Notify(NotifyEvent& rNEvt); /** Creates and returns the accessible object of the whole GridControl. */ - virtual XACC CreateAccessible(); - virtual XACC CreateAccessibleControl( sal_Int32 _nIndex ); - virtual ::rtl::OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const; - virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow ); - virtual ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const; + SVT_DLLPRIVATE virtual XACC CreateAccessible(); + SVT_DLLPRIVATE virtual XACC CreateAccessibleControl( sal_Int32 _nIndex ); + SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const; + SVT_DLLPRIVATE virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow ); + SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const; virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet, AccessibleTableControlObjType eObjType ) const; @@ -230,27 +231,6 @@ namespace svt { namespace table TableControl& operator=( const TableControl& ); // never implemented }; - class AccessibleTableControl_Impl - { - public: - AccessibleFactoryAccess m_aFactoryAccess; - IAccessibleTableControl* m_pAccessible; - - public: - AccessibleTableControl_Impl() : m_pAccessible(NULL) - { - } - - - /// @see AccessibleTableControl::getTableRowHeader - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - getAccessibleTableHeader( AccessibleTableControlObjType _eObjType ); - /// @see AccessibleTableControl::getTable - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - getAccessibleTable( ); - - }; - //........................................................................ } } // namespace svt::table //........................................................................ diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 1492468871a3..fbc60fb7bc0e 100644 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -27,6 +27,7 @@ #ifndef SVTOOLS_INC_TABLE_TABLEMODEL_HXX #define SVTOOLS_INC_TABLE_TABLEMODEL_HXX +#include "svtools/svtdllapi.h" #include #include #include @@ -310,7 +311,7 @@ namespace svt { namespace table //==================================================================== /** declares the interface to implement by an abtract table model */ - class SAL_NO_VTABLE ITableModel + class SAL_NO_VTABLE SVT_DLLPUBLIC ITableModel { public: /** returns the number of columns in the table @@ -321,8 +322,8 @@ namespace svt { namespace table */ virtual TableSize getRowCount() const = 0; - virtual void setColumnCount(TableSize _nColCount) = 0; - virtual void setRowCount(TableSize _nRowCount) = 0; + SVT_DLLPRIVATE virtual void setColumnCount(TableSize _nColCount) = 0; + SVT_DLLPRIVATE virtual void setRowCount(TableSize _nRowCount) = 0; /** determines whether the table has column headers @@ -335,12 +336,12 @@ namespace svt { namespace table /** sets whether the table should have row headers @see IColumnRenderer */ - virtual void setRowHeaders( bool rowHeaders) = 0; + SVT_DLLPRIVATE virtual void setRowHeaders( bool rowHeaders) = 0; /** sets whether the table should have column headers @see IColumnRenderer */ - virtual void setColumnHeaders( bool columnHeaders) = 0; + SVT_DLLPRIVATE virtual void setColumnHeaders( bool columnHeaders) = 0; /** determines whether the table has row headers @@ -360,11 +361,11 @@ namespace svt { namespace table /** adds the given listener to the list of ->ITableModelListener's */ - virtual void addTableModelListener( const PTableModelListener& listener ) = 0; + SVT_DLLPRIVATE virtual void addTableModelListener( const PTableModelListener& listener ) = 0; /** revokes the given listener from the list of ->ITableModelListener's */ - virtual void removeTableModelListener( const PTableModelListener& listener ) = 0; + SVT_DLLPRIVATE virtual void removeTableModelListener( const PTableModelListener& listener ) = 0; /** returns a model for a certain column @@ -394,7 +395,7 @@ namespace svt { namespace table @return the renderer to use. Must not be */ - virtual PTableRenderer getRenderer() const = 0; + SVT_DLLPRIVATE virtual PTableRenderer getRenderer() const = 0; /** returns the component handling input in a view associated with the model */ @@ -406,9 +407,9 @@ namespace svt { namespace table the logical height of rows in the table, in 1/100 millimeters. The height must be greater 0. */ - virtual TableMetrics getRowHeight() const = 0; + SVT_DLLPRIVATE virtual TableMetrics getRowHeight() const = 0; - virtual void setRowHeight(TableMetrics _nRowHeight) = 0; + SVT_DLLPRIVATE virtual void setRowHeight(TableMetrics _nRowHeight) = 0; /** determines the height of the column header row @@ -419,7 +420,7 @@ namespace svt { namespace table the logical height of the column header row, in 1/100 millimeters. Must be greater than 0. */ - virtual TableMetrics getColumnHeaderHeight() const = 0; + SVT_DLLPRIVATE virtual TableMetrics getColumnHeaderHeight() const = 0; /** determines the width of the row header column @@ -430,7 +431,7 @@ namespace svt { namespace table the logical width of the row header column, in 1/100 millimeters. Must be greater than 0. */ - virtual TableMetrics getRowHeaderWidth() const = 0; + SVT_DLLPRIVATE virtual TableMetrics getRowHeaderWidth() const = 0; /** determines the visibility of the vertical scrollbar of the table control @param overAllHeight the height of the table with all rows @@ -454,22 +455,22 @@ namespace svt { namespace table virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0; /**sets title of header rows */ - virtual void setRowHeaderName(const std::vector& cellColumnContent)=0; + SVT_DLLPRIVATE virtual void setRowHeaderName(const std::vector& cellColumnContent)=0; /** gets title of header rows */ virtual std::vector& getRowHeaderName() = 0; - virtual ::com::sun::star::util::Color getLineColor() = 0; - virtual void setLineColor(::com::sun::star::util::Color _rColor) = 0; - virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0; - virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor) = 0; - virtual ::com::sun::star::util::Color getTextColor() = 0; - virtual void setTextColor(::com::sun::star::util::Color _rColor) = 0; - virtual ::com::sun::star::util::Color getOddRowBackgroundColor() = 0; - virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0; - virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() = 0; - virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0; - virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() = 0; - virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _xAlign) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getLineColor() = 0; + SVT_DLLPRIVATE virtual void setLineColor(::com::sun::star::util::Color _rColor) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0; + SVT_DLLPRIVATE virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getTextColor() = 0; + SVT_DLLPRIVATE virtual void setTextColor(::com::sun::star::util::Color _rColor) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getOddRowBackgroundColor() = 0; + SVT_DLLPRIVATE virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() = 0; + SVT_DLLPRIVATE virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() = 0; + SVT_DLLPRIVATE virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _xAlign) = 0; /// destroys the table model instance virtual ~ITableModel() { } diff --git a/svtools/prj/d.lst b/svtools/prj/d.lst index 0a3ccd8a9819..4a9e8314e0d8 100644 --- a/svtools/prj/d.lst +++ b/svtools/prj/d.lst @@ -1,6 +1,7 @@ mkdir: %COMMON_DEST%\bin%_EXT%\hid mkdir: %COMMON_DEST%\res%_EXT% mkdir: %_DEST%\inc%_EXT%\svtools +mkdir: %_DEST%\inc%_EXT%\svtools\table ..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid ..\%__SRC%\srs\ehdl.srs %_DEST%\res%_EXT%\svtools.srs @@ -25,6 +26,7 @@ mkdir: %_DEST%\inc%_EXT%\svtools ..\inc\svtools\*.hxx %_DEST%\inc%_EXT%\svtools\*.hxx ..\inc\svtools\*.h %_DEST%\inc%_EXT%\svtools\*.h ..\inc\svtools\*.hrc %_DEST%\inc%_EXT%\svtools\*.hrc +..\inc\svtools\table\*.hxx %_DEST%\inc%_EXT%\svtools\table\*.hxx ..\inc\*.hxx %_DEST%\inc%_EXT%\svtools\*.hxx ..\inc\*.h %_DEST%\inc%_EXT%\svtools\*.h ..\inc\*.hrc %_DEST%\inc%_EXT%\svtools\*.hrc diff --git a/svtools/source/inc/accessibletableimp.hxx b/svtools/source/inc/accessibletableimp.hxx new file mode 100644 index 000000000000..3a01c01567d3 --- /dev/null +++ b/svtools/source/inc/accessibletableimp.hxx @@ -0,0 +1,62 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX +#define SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX + +#include "svtaccessiblefactory.hxx" + +namespace svt { namespace table +{ +//........................................................................ + + + class AccessibleTableControl_Impl + { + public: + AccessibleFactoryAccess m_aFactoryAccess; + IAccessibleTableControl* m_pAccessible; + + public: + AccessibleTableControl_Impl() : m_pAccessible(NULL) + { + } + + + /// @see AccessibleTableControl::getTableRowHeader + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getAccessibleTableHeader( AccessibleTableControlObjType _eObjType ); + /// @see AccessibleTableControl::getTable + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getAccessibleTable( ); + + }; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 01da79e2056e..7452bda6d02a 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -30,6 +30,7 @@ #include "svtools/table/tablecontrol.hxx" #include "tablegeometry.hxx" #include "tablecontrol_impl.hxx" +#include "accessibletableimp.hxx" #include "svtools/table/tabledatawindow.hxx" #include #include diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 5be2c71c9f52..404caadd9fb7 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -28,6 +28,7 @@ #include "precompiled_svtools.hxx" #include "svtxgridcontrol.hxx" +#include "accessibletableimp.hxx" #include #include "svtools/table/gridtablerenderer.hxx" #include "svtools/table/defaultinputhandler.hxx" -- cgit From 44e0e3f4b2006a218f72b6be0e76bbd9fe834c10 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 12 Apr 2010 15:34:14 +0100 Subject: cmcfixes74: #i110565 use radio buttons for mutually exclusive options in menus --- sw/source/ui/app/mn.src | 7 +++++++ sw/source/ui/inc/swmn_tmpl.hrc | 1 - sw/source/ui/lingu/olmenu.cxx | 14 ++++++++++---- sw/uiconfig/sglobal/menubar/menubar.xml | 22 +++++++++++----------- sw/uiconfig/sweb/menubar/menubar.xml | 22 +++++++++++----------- sw/uiconfig/swform/menubar/menubar.xml | 22 +++++++++++----------- sw/uiconfig/swreport/menubar/menubar.xml | 22 +++++++++++----------- sw/uiconfig/swriter/menubar/menubar.xml | 26 +++++++++++++------------- sw/uiconfig/swxform/menubar/menubar.xml | 22 +++++++++++----------- 9 files changed, 85 insertions(+), 73 deletions(-) diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index 81dad77566b2..16e20f5725a2 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -597,6 +597,7 @@ Menu MN_TAB_POPUPMENU MN_EDIT_CONTOUR\ MenuItem\ {\ + Checkable = TRUE ; \ Identifier = FN_WRAP_ANCHOR_ONLY ; \ HelpID = FN_WRAP_ANCHOR_ONLY ; \ Text [ en-US ] = "~First Paragraph" ; \ @@ -661,6 +662,7 @@ String MN_DRAW_POPUPMENU MN_WRAP_CONTOUR_1\ MenuItem\ {\ + Checkable = TRUE ; \ Identifier = FN_WRAP_ANCHOR_ONLY ; \ HelpID = FN_WRAP_ANCHOR_ONLY ; \ Text [ en-US ] = "~First Paragraph" ; \ @@ -686,6 +688,7 @@ String MN_DRAW_POPUPMENU #define MN_AT_FRAME \ MenuItem\ {\ + RadioCheck = TRUE ; \ Identifier = FN_TOOL_ANKER_FRAME ; \ HelpID = FN_TOOL_ANKER_FRAME ; \ Text [ en-US ] = "To ~Frame" ; \ @@ -704,24 +707,28 @@ String MN_DRAW_POPUPMENU {\ MenuItem\ {\ + RadioCheck = TRUE ; \ Identifier = FN_TOOL_ANKER_PAGE ; \ HelpID = FN_TOOL_ANKER_PAGE ; \ Text [ en-US ] = "To P~age" ; \ };\ MenuItem\ {\ + RadioCheck = TRUE ; \ Identifier = FN_TOOL_ANKER_PARAGRAPH ; \ HelpID = FN_TOOL_ANKER_PARAGRAPH ; \ Text [ en-US ] = "To ~Paragraph" ; \ };\ MenuItem\ {\ + RadioCheck = TRUE ; \ Identifier = FN_TOOL_ANKER_AT_CHAR ; \ HelpID = FN_TOOL_ANKER_AT_CHAR ; \ Text [ en-US ] = "To ~Character" ; \ };\ MenuItem\ {\ + RadioCheck = TRUE ; \ Identifier = FN_TOOL_ANKER_CHAR ; \ HelpID = FN_TOOL_ANKER_CHAR ; \ Text [ en-US ] = "As C~haracter" ; \ diff --git a/sw/source/ui/inc/swmn_tmpl.hrc b/sw/source/ui/inc/swmn_tmpl.hrc index 3128f741be30..bf375e4ab010 100644 --- a/sw/source/ui/inc/swmn_tmpl.hrc +++ b/sw/source/ui/inc/swmn_tmpl.hrc @@ -131,7 +131,6 @@ HelpID = MN_FORMAT_ALGN ; \ Command = ".uno:AlignTextMenu" ; \ Text [ en-US ] = "A~lignment" ; \ - RadioCheck = TRUE ; \ SubMenu = Menu\ {\ ItemList = \ diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx index 351999015711..de8a9f9e6f4d 100644 --- a/sw/source/ui/lingu/olmenu.cxx +++ b/sw/source/ui/lingu/olmenu.cxx @@ -307,6 +307,9 @@ USHORT SwSpellPopup::fillLangPopupMenu( } } + bool bMultipleLanguages = (nLangTable != 0) || (curLang.compareToAscii( "*" ) == 0); + bool bNothingSelected = true; + MenuItemBits nMenuItemStyle = !bMultipleLanguages ? MIB_RADIOCHECK : 0; for (std::map< rtl::OUString, rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it) { rtl::OUString aEntryTxt( it->first ); @@ -322,22 +325,25 @@ USHORT SwSpellPopup::fillLangPopupMenu( else if (nLangTable == 2) // language for document aLangTable_Document[nItemId] = aEntryTxt; - pPopupMenu->InsertItem( nItemId, aEntryTxt, MIB_RADIOCHECK ); - if (aEntryTxt == curLang) + pPopupMenu->InsertItem( nItemId, aEntryTxt, nMenuItemStyle ); + if ((nLangTable == 0) && (aEntryTxt == curLang)) { //make a check mark for the current language pPopupMenu->CheckItem( nItemId, TRUE ); + bNothingSelected = false; } } } //7--none nItemId++; - pPopupMenu->InsertItem( nItemId, String(SW_RES( STR_LANGSTATUS_NONE )), MIB_RADIOCHECK ); + pPopupMenu->InsertItem( nItemId, String(SW_RES( STR_LANGSTATUS_NONE )), nMenuItemStyle ); + if (bNothingSelected && !bMultipleLanguages) + pPopupMenu->CheckItem( nItemId, TRUE ); //More... nItemId++; - pPopupMenu->InsertItem( nItemId, String(SW_RES( STR_LANGSTATUS_MORE )), MIB_RADIOCHECK ); + pPopupMenu->InsertItem( nItemId, String(SW_RES( STR_LANGSTATUS_MORE )) ); return nItemId - Lang_Start; // return number of inserted entries } diff --git a/sw/uiconfig/sglobal/menubar/menubar.xml b/sw/uiconfig/sglobal/menubar/menubar.xml index 4b46f4d46a2a..01fbb454bff5 100644 --- a/sw/uiconfig/sglobal/menubar/menubar.xml +++ b/sw/uiconfig/sglobal/menubar/menubar.xml @@ -65,8 +65,8 @@ - - + + @@ -240,11 +240,11 @@ - - - - - + + + + + @@ -264,10 +264,10 @@ - - - - + + + + diff --git a/sw/uiconfig/sweb/menubar/menubar.xml b/sw/uiconfig/sweb/menubar/menubar.xml index 4be8c6f8e791..b9368a94c273 100644 --- a/sw/uiconfig/sweb/menubar/menubar.xml +++ b/sw/uiconfig/sweb/menubar/menubar.xml @@ -54,8 +54,8 @@ - - + + @@ -187,11 +187,11 @@ - - - - - + + + + + @@ -211,10 +211,10 @@ - - - - + + + + diff --git a/sw/uiconfig/swform/menubar/menubar.xml b/sw/uiconfig/swform/menubar/menubar.xml index 13448e424754..2174db8a0cf4 100644 --- a/sw/uiconfig/swform/menubar/menubar.xml +++ b/sw/uiconfig/swform/menubar/menubar.xml @@ -66,8 +66,8 @@ - - + + @@ -240,11 +240,11 @@ - - - - - + + + + + @@ -264,10 +264,10 @@ - - - - + + + + diff --git a/sw/uiconfig/swreport/menubar/menubar.xml b/sw/uiconfig/swreport/menubar/menubar.xml index 1f94b7ced1c3..6cd3f3c8c7d7 100644 --- a/sw/uiconfig/swreport/menubar/menubar.xml +++ b/sw/uiconfig/swreport/menubar/menubar.xml @@ -66,8 +66,8 @@ - - + + @@ -240,11 +240,11 @@ - - - - - + + + + + @@ -264,10 +264,10 @@ - - - - + + + + diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index 7c44f84982a9..06af710d2fce 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -69,8 +69,8 @@ - - + + @@ -106,8 +106,8 @@ - - + + @@ -243,11 +243,11 @@ - - - - - + + + + + @@ -267,10 +267,10 @@ - - - - + + + + diff --git a/sw/uiconfig/swxform/menubar/menubar.xml b/sw/uiconfig/swxform/menubar/menubar.xml index b37a8e14d232..85008cae2471 100644 --- a/sw/uiconfig/swxform/menubar/menubar.xml +++ b/sw/uiconfig/swxform/menubar/menubar.xml @@ -67,8 +67,8 @@ - - + + @@ -241,11 +241,11 @@ - - - - - + + + + + @@ -265,10 +265,10 @@ - - - - + + + + -- cgit From 7062641db71988f68a1e144375d3cda8d90d77b4 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 12 Apr 2010 15:34:14 +0100 Subject: cmcfixes74: #i110565 use radio buttons for mutually exclusive options in menus --- .../uielement/langselectionmenucontroller.cxx | 10 ++++++++-- .../uielement/langselectionstatusbarcontroller.cxx | 21 ++++++++++++++------- framework/source/uielement/menubarmanager.cxx | 11 ++++++++--- framework/source/xml/menudocumenthandler.cxx | 14 +++++++++++--- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/framework/source/uielement/langselectionmenucontroller.cxx b/framework/source/uielement/langselectionmenucontroller.cxx index 9c8e68e24734..f2c905f237e8 100644 --- a/framework/source/uielement/langselectionmenucontroller.cxx +++ b/framework/source/uielement/langselectionmenucontroller.cxx @@ -344,6 +344,9 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup std::map< sal_Int16, ::rtl::OUString > LangTable; const ::rtl::OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*")); + bool bMultipleLanguages = (eMode != MODE_SetLanguageSelectionMenu) || m_aCurLang.compareToAscii( "*" ) == 0; + bool bNothingSelected = true; + MenuItemBits nItemBits = !bMultipleLanguages ? MIB_RADIOCHECK : 0; for(std::map< ::rtl::OUString, ::rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it) { if(it->first != ::rtl::OUString( aLangTable.GetString( LANGUAGE_NONE ) )&& @@ -351,12 +354,13 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup it->first.getLength()) { ++nItemId; - pPopupMenu->InsertItem( nItemId,it->first); + pPopupMenu->InsertItem( nItemId,it->first,nItemBits ); LangTable[nItemId] = it->first; if(it->first == m_aCurLang && eMode == MODE_SetLanguageSelectionMenu ) { //make a sign for the current language pPopupMenu->CheckItem(nItemId,TRUE); + bNothingSelected = false; } aCmd=aCmd_Language; aCmd+=(String)it->first; @@ -366,7 +370,9 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup //7--none nItemId++; - pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_LANGSTATUS_NONE )) ); + pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_LANGSTATUS_NONE )), nItemBits ); + if (bNothingSelected && !bMultipleLanguages) + pPopupMenu->CheckItem(nItemId,TRUE); aCmd=aCmd_Language; aCmd+=String::CreateFromAscii("LANGUAGE_NONE"); pPopupMenu->SetItemCommand(nItemId,aCmd); diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index 953470314785..544597261852 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -272,6 +272,9 @@ void LangSelectionStatusbarController::LangMenu()throw (::com::sun::star::uno::R } } std::map< sal_Int16, ::rtl::OUString > LangTable; + bool bMultipleLanguages = m_aCurLang.compareToAscii( "*" ) == 0; + bool bNothingSelected = true; + sal_Int16 nMenuItemStyle = !bMultipleLanguages ? css::awt::MenuItemStyle::RADIOCHECK : 0; for( std::set< ::rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it ) { @@ -281,22 +284,26 @@ void LangSelectionStatusbarController::LangMenu()throw (::com::sun::star::uno::R { //nItemId = xPopupMenu->getItemCount()+1; nItemId++; - xPopupMenu->insertItem( nItemId, *it, css::awt::MenuItemStyle::RADIOCHECK, nItemId ); + xPopupMenu->insertItem( nItemId, *it, nMenuItemStyle, nItemId ); LangTable[nItemId]=*it; if( *it == m_aCurLang ) { //make a sign for the current language xPopupMenu->checkItem( nItemId, TRUE ); + bNothingSelected = false; } } } //7--none nItemId++; - xPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, nItemId ); + xPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_NONE )), nMenuItemStyle, nItemId ); + if (bNothingSelected && !bMultipleLanguages) + xPopupMenu->checkItem( nItemId, TRUE ); + //More... nItemId++; - xPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_MORE )), css::awt::MenuItemStyle::RADIOCHECK, nItemId ); + xPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_MORE )), 0, nItemId ); for( ::std::set< ::rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it ) { @@ -305,22 +312,22 @@ void LangSelectionStatusbarController::LangMenu()throw (::com::sun::star::uno::R *it != ::rtl::OUString::createFromAscii( "" )) { nItemId++; - subPopupMenu->insertItem( nItemId, *it, css::awt::MenuItemStyle::RADIOCHECK, nItemId ); + subPopupMenu->insertItem( nItemId, *it, 0, nItemId ); LangTable[nItemId]=*it; } } //7--none nItemId++; - subPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, nItemId ); + subPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_NONE )), 0, nItemId ); //More nItemId++; - subPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_MORE )), css::awt::MenuItemStyle::RADIOCHECK, nItemId ); + subPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_MORE )), 0, nItemId ); nItemId++; xPopupMenu->insertSeparator(nItemId); nItemId++; - xPopupMenu->insertItem( nItemId, String( FwkResId( STR_SET_LANGUAGE_FOR_PARAGRAPH )), css::awt::MenuItemStyle::RADIOCHECK, nItemId ); + xPopupMenu->insertItem( nItemId, String( FwkResId( STR_SET_LANGUAGE_FOR_PARAGRAPH )), 0, nItemId ); xPopupMenu->setPopupMenu( nItemId, subPopupMenu ); //display the popup menu and execute every command diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 9fbdf87336cc..9d8aa9205c90 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -548,11 +548,14 @@ throw ( RuntimeException ) if ( Event.State >>= bCheckmark ) { - // Checkmark + // Checkmark or RadioButton m_pVCLMenu->ShowItem( pMenuItemHandler->nItemId, TRUE ); m_pVCLMenu->CheckItem( pMenuItemHandler->nItemId, bCheckmark ); - m_pVCLMenu->SetItemBits( pMenuItemHandler->nItemId, - m_pVCLMenu->GetItemBits( pMenuItemHandler->nItemId ) | MIB_CHECKABLE ); + + MenuItemBits nBits = m_pVCLMenu->GetItemBits( pMenuItemHandler->nItemId ); + //If not already designated RadioButton set as CheckMark + if (!(nBits & MIB_RADIOCHECK)) + m_pVCLMenu->SetItemBits( pMenuItemHandler->nItemId, nBits | MIB_CHECKABLE ); } else if ( Event.State >>= aItemText ) { @@ -1805,6 +1808,8 @@ void MenuBarManager::FillMenu( nBits |= MIB_ICON; if ( nStyle & ::com::sun::star::ui::ItemStyle::TEXT ) nBits |= MIB_TEXT; + if ( nStyle & ::com::sun::star::ui::ItemStyle::RADIO_CHECK ) + nBits |= MIB_RADIOCHECK; pMenu->SetItemBits( nId, nBits ); } if ( xIndexContainer.is() ) diff --git a/framework/source/xml/menudocumenthandler.cxx b/framework/source/xml/menudocumenthandler.cxx index 90f5fb25dec3..3fc5d1775be4 100644 --- a/framework/source/xml/menudocumenthandler.cxx +++ b/framework/source/xml/menudocumenthandler.cxx @@ -94,6 +94,7 @@ #define ATTRIBUTE_ITEMSTYLE_TEXT "text" #define ATTRIBUTE_ITEMSTYLE_IMAGE "image" +#define ATTRIBUTE_ITEMSTYLE_RADIO "radio" // Property names of a menu/menu item ItemDescriptor static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL"; @@ -134,6 +135,7 @@ struct MenuStyleItem MenuStyleItem MenuItemStyles[ ] = { { ::com::sun::star::ui::ItemStyle::ICON, ATTRIBUTE_ITEMSTYLE_IMAGE }, { ::com::sun::star::ui::ItemStyle::TEXT, ATTRIBUTE_ITEMSTYLE_TEXT }, + { ::com::sun::star::ui::ItemStyle::RADIO_CHECK, ATTRIBUTE_ITEMSTYLE_RADIO } }; @@ -437,8 +439,10 @@ throw( SAXException, RuntimeException ) { if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_TEXT ) ) ) nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT; - if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) ) + else if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) ) nItemBits |= ::com::sun::star::ui::ItemStyle::ICON; + else if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_RADIO ) ) ) + nItemBits |= ::com::sun::star::ui::ItemStyle::RADIO_CHECK; } } while ( nIndex >= 0 ); @@ -670,8 +674,10 @@ throw( SAXException, RuntimeException ) { if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_TEXT ) ) ) nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT; - if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) ) + else if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) ) nItemBits |= ::com::sun::star::ui::ItemStyle::ICON; + else if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_RADIO ) ) ) + nItemBits |= ::com::sun::star::ui::ItemStyle::RADIO_CHECK; } } while ( nIndex >= 0 ); @@ -725,8 +731,10 @@ throw( SAXException, RuntimeException ) { if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_TEXT ) ) ) nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT; - if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) ) + else if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) ) nItemBits |= ::com::sun::star::ui::ItemStyle::ICON; + else if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_RADIO ) ) ) + nItemBits |= ::com::sun::star::ui::ItemStyle::RADIO_CHECK; } } while ( nIndex >= 0 ); -- cgit From 6e9b33ba6aa7272f6ab81e6c54c319b2e5305cc7 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 12 Apr 2010 15:34:14 +0100 Subject: cmcfixes74: #i110565 use radio buttons for mutually exclusive options in menus --- sc/source/ui/drawfunc/drformsh.src | 2 ++ sc/source/ui/drawfunc/objdraw.src | 2 ++ sc/uiconfig/scalc/menubar/menubar.xml | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/sc/source/ui/drawfunc/drformsh.src b/sc/source/ui/drawfunc/drformsh.src index b20ceb9841a5..65e98eea7b2c 100644 --- a/sc/source/ui/drawfunc/drformsh.src +++ b/sc/source/ui/drawfunc/drformsh.src @@ -117,12 +117,14 @@ {\ MenuItem\ {\ + RadioCheck = TRUE ; \ Identifier = SID_ANCHOR_PAGE ; \ HelpId = SID_ANCHOR_PAGE ; \ Text [ en-US ] = "To P~age" ; \ };\ MenuItem\ {\ + RadioCheck = TRUE ; \ Identifier = SID_ANCHOR_CELL ; \ HelpId = SID_ANCHOR_CELL ; \ Text [ en-US ] = "To ~Cell" ; \ diff --git a/sc/source/ui/drawfunc/objdraw.src b/sc/source/ui/drawfunc/objdraw.src index 0cd8fdd54e4b..82649044b38c 100644 --- a/sc/source/ui/drawfunc/objdraw.src +++ b/sc/source/ui/drawfunc/objdraw.src @@ -339,6 +339,7 @@ {\ MenuItem\ {\ + RadioCheck = TRUE ; \ Identifier = SID_ANCHOR_PAGE ; \ HelpId = SID_ANCHOR_PAGE ; \ Text [ en-US ] = "To P~age" ; \ @@ -346,6 +347,7 @@ };\ MenuItem\ {\ + RadioCheck = TRUE ; \ Identifier = SID_ANCHOR_CELL ; \ HelpId = SID_ANCHOR_CELL ; \ Text [ en-US ] = "To ~Cell" ; \ diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index ab3f121809fa..faad1789a63f 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -109,8 +109,8 @@ - - + + @@ -247,21 +247,21 @@ - - + + - - - - - + + + + + - - - + + + -- cgit From e0b8a71c2131f90e1fbb442693c7124ce7d86597 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 12 Apr 2010 15:34:14 +0100 Subject: cmcfixes74: #i110565 use radio buttons for mutually exclusive options in menus --- sd/uiconfig/sdraw/menubar/menubar.xml | 10 +++++----- sd/uiconfig/simpress/menubar/menubar.xml | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sd/uiconfig/sdraw/menubar/menubar.xml b/sd/uiconfig/sdraw/menubar/menubar.xml index 9e5d927b263e..20ca059b16d5 100644 --- a/sd/uiconfig/sdraw/menubar/menubar.xml +++ b/sd/uiconfig/sdraw/menubar/menubar.xml @@ -75,14 +75,14 @@ - - + + - - - + + + diff --git a/sd/uiconfig/simpress/menubar/menubar.xml b/sd/uiconfig/simpress/menubar/menubar.xml index c1dacd33e0c0..03d4c238e360 100644 --- a/sd/uiconfig/simpress/menubar/menubar.xml +++ b/sd/uiconfig/simpress/menubar/menubar.xml @@ -76,12 +76,12 @@ - - - + + + - - + + @@ -93,9 +93,9 @@ - - - + + + -- cgit From 4d00311c1e0219988f8bcf8ff707cae6881905c4 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 12 Apr 2010 15:34:14 +0100 Subject: cmcfixes74: #i110565 use radio buttons for mutually exclusive options in menus --- dbaccess/uiconfig/dbapp/menubar/menubar.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dbaccess/uiconfig/dbapp/menubar/menubar.xml b/dbaccess/uiconfig/dbapp/menubar/menubar.xml index 629aa199f353..baafddcae8ad 100644 --- a/dbaccess/uiconfig/dbapp/menubar/menubar.xml +++ b/dbaccess/uiconfig/dbapp/menubar/menubar.xml @@ -59,10 +59,10 @@ - - - - + + + + @@ -70,9 +70,9 @@ - - - + + + -- cgit From 9631c4e031410ea86b28da64956b5909e8aa6678 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 13 Apr 2010 09:26:12 +0100 Subject: sdfindall: #i110565 revert this one to regain icons --- sw/uiconfig/swriter/menubar/menubar.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index 06af710d2fce..c88c0b327c7f 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -106,8 +106,8 @@ - - + + -- cgit From 8c3462853e40dae7801efae3ea8924ceb114efa0 Mon Sep 17 00:00:00 2001 From: tb121644 Date: Tue, 13 Apr 2010 13:20:32 +0200 Subject: #i109825# enable testautomation for gridcontrol --- .../optional/includes/basic_gridcontrol.inc | 74 +++------------------ .../framework/optional/input/gridcontrol.odt | Bin 11602 -> 11924 bytes testautomation/global/win/dial_d_h.win | 6 ++ 3 files changed, 16 insertions(+), 64 deletions(-) diff --git a/testautomation/framework/optional/includes/basic_gridcontrol.inc b/testautomation/framework/optional/includes/basic_gridcontrol.inc index dc96ef30e16c..f2d2f74cbdd4 100644 --- a/testautomation/framework/optional/includes/basic_gridcontrol.inc +++ b/testautomation/framework/optional/includes/basic_gridcontrol.inc @@ -54,72 +54,18 @@ testcase tGridcontrolLoad call sleep 1 printlog "Start the macro, that performs the test" - printlog "Tools->Macros->Run Macro..." - ToolsMacrosRunMacro - Kontext "ScriptSelector" - if ScriptSelector.exists(10) then - x = LibraryTreeList.getItemCount - printlog "Look for library 'gridcontrol'" - for i = 1 to x - sTemp = LibraryTreeList.getItemText(i) - 'printlog "("+i+"/"+x+"): '" + sTemp + "'" - if (instr(sTemp,"gridcontrol")>0 OR instr(sTemp,"GRIDCONTROL")) then - a = i - printlog "Found library ("+i+"/"+x+"): '" + sTemp + "'" - endif + Kontext "GridControlDialogStarter" + ShowGridcontrol.typeKeys "" + Kontext "GridControlDialog" + if GridControlDialog.exists(5) then + for i=1 to gridcontrolcontrol.getcolumncount + for a=1 to gridcontrolcontrol.getrowcount + printlog " " + i + ":"+a+": '" + gridcontrolcontrol.getitemtype (i,a) + "' '" + gridcontrolcontrol.getitemtext (i,a) + "'" + next a next i - if 0 <> a then - printlog "Select the library and unfold it" - LibraryTreeList.select(a) - LibraryTreeList.typeKeys("+") - printlog "Go to 'Standard' and unfold" - LibraryTreeList.typeKeys("") - LibraryTreeList.typeKeys("+") - printlog "Go to 'Module1'" - LibraryTreeList.typeKeys("") - - printlog "Select macro name 'VclTestTool'" - x = ScriptList.getItemCount - for i = 1 to x - sTemp = ScriptList.getItemText(i) - 'printlog "("+i+"/"+x+"): '" + sTemp + "'" - if "VclTestTool" = sTemp then - a = i - printlog "Found macro ("+i+"/"+x+"): '" + sTemp + "'" - endif - next i - if (0 <> a) then - printlog "Select the macro" - ScriptList.select(a) - printlog "Start the macro by pressing the button 'run'" - ScriptSelector.ok - printlog "sleep... at least 60 seconds" - call sleep(60) - printlog "If macro fails for whatever reason, a message comes up" - Kontext - if active.exists() then - warnlog "" + active.getText - active.ok - try - EditCopy - warnlog getclipboard() - catch - endcatch - printlog "close basic ide" - call hCloseDocument() - printlog "close document" - call hCloseDocument() - goto endsub - endif - - else - warnlog sLocation + "Macro not found: 'Main'" - endif - else - warnlog sLocation + "Library not found: 'gridcontrol'" - endif + GridControlDialog.close else - warnlog sLocation + "'Run macro dialog' didn't came up" + warnlog "Gridcontrol Dialog did not come up after pressing button" endif printlog "clean up" diff --git a/testautomation/framework/optional/input/gridcontrol.odt b/testautomation/framework/optional/input/gridcontrol.odt index b3e5c6fb40bb..31b43afb8969 100755 Binary files a/testautomation/framework/optional/input/gridcontrol.odt and b/testautomation/framework/optional/input/gridcontrol.odt differ diff --git a/testautomation/global/win/dial_d_h.win b/testautomation/global/win/dial_d_h.win index 1540dbd8743f..ab6183ad7724 100755 --- a/testautomation/global/win/dial_d_h.win +++ b/testautomation/global/win/dial_d_h.win @@ -483,6 +483,12 @@ Gruppenliste HID_TEMPLATE_FILTER Interlace filter:CheckBox:DLG_EXPORT_GIF:CBX_INTERLACED TransparentSpeichern filter:CheckBox:DLG_EXPORT_GIF:CBX_TRANSLUCENT +*GridControlDialogStarter ACTIVE +ShowGridcontrol sym:showGridcontrol + +*GridControlDialog sym:gridcontroldialog +gridcontrolcontrol sym:gridcontrolself + *GroupingDlg HID_SC_DPDATEGROUP AutoStart sc:RadioButton:RID_SCDLG_DPNUMGROUP:RB_AUTOSTART ManualStart sc:RadioButton:RID_SCDLG_DPNUMGROUP:RB_MANSTART -- cgit From f3d3abbe4f0df2a9b7fc6bc6c758611ea1e79ab2 Mon Sep 17 00:00:00 2001 From: Gregor Hartmann Date: Tue, 13 Apr 2010 13:33:30 +0200 Subject: fix some errors --- automation/source/server/statemnt.cxx | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/automation/source/server/statemnt.cxx b/automation/source/server/statemnt.cxx index 3b29ddd93544..71e76f146e10 100644 --- a/automation/source/server/statemnt.cxx +++ b/automation/source/server/statemnt.cxx @@ -6173,7 +6173,7 @@ protected: ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() )) { ::svt::table::PTableModel pModel = pTC->GetModel(); - Any aCell = pModel->getCellContent()[nNr1-1][nNr2-1]; + Any aCell = pModel->getCellContent()[nNr2-1][nNr1-1]; pRet->GenReturn ( RET_Value, aUId, String( aCell.getValueTypeName() )); } } @@ -6184,7 +6184,7 @@ protected: ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() )) { ::svt::table::PTableModel pModel = pTC->GetModel(); - Any aCell = pModel->getCellContent()[nNr1-1][nNr2-1]; + Any aCell = pModel->getCellContent()[nNr2-1][nNr1-1]; ::rtl::OUString aContent; aCell >>= aContent; pRet->GenReturn ( RET_Value, aUId, aContent ); @@ -6207,21 +6207,16 @@ protected: aControler = pEBBox->Controller(); pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)aControler.Is() ); } - break; + break;*/ case M_Select : { - if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pEBBox->GetRowCount() ) ) + if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetColumnCount() ) && + ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() )) { - USHORT nColCount = pEBBox->GetColumnCount(); - comm_USHORT nUnfrozenColCount = 0; - USHORT i; - for ( i=0 ; i < nColCount ; i++ ) - { - if ( !pEBBox->IsFrozen( pEBBox->GetColumnId( i ) ) ) - nUnfrozenColCount++; - } - if ( ValueOK(aUId, MethodString( nMethodId ),nNr2,nUnfrozenColCount ) ) - pEBBox->GoToRowColumnId( nNr1-1, pEBBox->GetColumnId( nNr2 ) ); + if ( pTC->GoTo( ::svt::table::ColPos( nNr1 ), ::svt::table::RowPos( nNr2 ) ) ) + pTC->Select(); + else + ReportError( aUId, GEN_RES_STR2c2( S_METHOD_FAILED, MethodString( nMethodId ), "GoTo" ) ); } } break; @@ -6229,7 +6224,7 @@ protected: - case M_GetSelCount : +/* case M_GetSelCount : pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount())); break; case M_GetSelIndex : @@ -6279,7 +6274,7 @@ protected: } break;*/ default: - ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RoadMap" ) ); + ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TableControl" ) ); break; } } -- cgit From fdd1c8f3861b366be58d9ffa3bf027ff3086b271 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 13 Apr 2010 18:30:31 +0200 Subject: npower13_objectmodules: compiler warnings --- basic/inc/basic/sbobjmod.hxx | 1 + basic/source/classes/eventatt.cxx | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/basic/inc/basic/sbobjmod.hxx b/basic/inc/basic/sbobjmod.hxx index ad83e4fbc44b..ad804dcfab38 100644 --- a/basic/inc/basic/sbobjmod.hxx +++ b/basic/inc/basic/sbobjmod.hxx @@ -55,6 +55,7 @@ public: TYPEINFO(); SbObjModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVbaCompatible ); virtual SbxVariable* Find( const XubString& rName, SbxClassType t ); + using SbxValue::GetObject; SbxVariable* GetObject(); void SetUnoObject( const com::sun::star::uno::Any& aObj )throw ( com::sun::star::uno::RuntimeException ) ; }; diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx index 1ffa6e374b9a..b1170baa2010 100644 --- a/basic/source/classes/eventatt.cxx +++ b/basic/source/classes/eventatt.cxx @@ -613,7 +613,10 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite ) Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( pINST->GetBasic(), xModel ); Sequence< Any > aArgs( 4 ); - aArgs[ 0 ] <<= bDocDialog ? xModel : uno::Reference< uno::XInterface >(); + if( bDocDialog ) + aArgs[ 0 ] <<= xModel; + else + aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); aArgs[ 1 ] <<= xInput; aArgs[ 2 ] = aDlgLibAny; aArgs[ 3 ] <<= xScriptListener; -- cgit From 8616787ccb5d3cd09bef7ad2a77d97155890173e Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 13 Apr 2010 19:44:24 +0100 Subject: npower13_objectmodules: #i110724# fix for union and some clean up for determining multicell property values ( using SfxItemSet ) --- sc/source/ui/vba/excelvbahelper.cxx | 7 ++-- sc/source/ui/vba/excelvbahelper.hxx | 4 +-- sc/source/ui/vba/vbaapplication.cxx | 70 ++++++++++++++++++++++++++----------- sc/source/ui/vba/vbaformat.cxx | 60 ++++++++++++++++++++++++++----- sc/source/ui/vba/vbaformat.hxx | 5 +++ sc/source/ui/vba/vbarange.cxx | 66 +++++++++------------------------- sc/source/ui/vba/vbarange.hxx | 11 +++--- 7 files changed, 132 insertions(+), 91 deletions(-) diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 4912863a446e..b1c4db637434 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -208,12 +208,11 @@ getViewFrame( const uno::Reference< frame::XModel >& xModel ) } SfxItemSet* -ScVbaCellRangeAccess::GetDataSet( ScCellRangeObj* pRangeObj ) +ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj ) { - SfxItemSet* pDataSet = pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : NULL ; - return pDataSet; - + return pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : 0; } + } //excel } //vba } //ooo diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx index 34b099e6db46..9af804ab169f 100644 --- a/sc/source/ui/vba/excelvbahelper.hxx +++ b/sc/source/ui/vba/excelvbahelper.hxx @@ -30,7 +30,7 @@ #include #include -class ScCellRangeObj; +class ScCellRangesBase; namespace ooo { @@ -51,7 +51,7 @@ namespace ooo class ScVbaCellRangeAccess { public: - static SfxItemSet* GetDataSet( ScCellRangeObj* pRangeObj ); + static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj ); }; } } diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 984c5b27c97b..3d5af01acef1 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -775,46 +775,74 @@ bool lcl_canJoin( ScRange& r1, ScRange& r2 ) void lcl_strip_containedRanges( Ranges& vRanges ) { // get rid of ranges that are surrounded by other ranges - for( Ranges::iterator it = vRanges.begin(); it != vRanges.end(); ++it ) + Ranges::iterator it_outer = vRanges.begin(); + while( it_outer != vRanges.end() ) { - for( Ranges::iterator it_inner = vRanges.begin(); it_inner != vRanges.end(); ++it_inner ) + bool it_outer_erased = false; // true = it_outer erased from vRanges + Ranges::iterator it_inner = vRanges.begin(); + /* Exit the inner loop if outer iterator has been erased in its last + iteration (this means it has been joined to last it_inner, or that + the it_inner contains it completely). The inner loop will restart + with next element of the outer loop, and all elements (from the + beginning of the list) will be checked against that new element. */ + while( !it_outer_erased && (it_inner != vRanges.end()) ) { - if ( it != it_inner ) + bool it_inner_erased = false; // true = it_inner erased from vRanges + if ( it_outer != it_inner ) { #ifdef DEBUG - String r1; - String r2; - it->Format( r1, SCA_VALID ) ; - it_inner->Format( r2, SCA_VALID ) ; - OSL_TRACE( "try strip/join address %s with %s ", - rtl::OUStringToOString( r1, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( r2, RTL_TEXTENCODING_UTF8 ).getStr() ); + String r1; + String r2; + it_outer->Format( r1, SCA_VALID ) ; + it_inner->Format( r2, SCA_VALID ) ; + OSL_TRACE( "try strip/join address %s with %s ", + rtl::OUStringToOString( r1, RTL_TEXTENCODING_UTF8 ).getStr(), + rtl::OUStringToOString( r2, RTL_TEXTENCODING_UTF8 ).getStr() ); #endif - if ( it->In( *it_inner ) ) + if ( it_outer->In( *it_inner ) ) + { it_inner = vRanges.erase( it_inner ); - else if ( it_inner->In( *it ) ) - it = vRanges.erase( it ); + it_inner_erased = true; + } + else if ( it_inner->In( *it_outer ) ) + { + it_outer = vRanges.erase( it_outer ); + it_outer_erased = true; + } #ifndef OWN_JOIN - else if ( (*it_inner).aStart.Row() == (*it).aStart.Row() - && (*it_inner).aEnd.Row() == (*it).aEnd.Row() ) + else if ( (*it_inner).aStart.Row() == (*it_outer).aStart.Row() + && (*it_inner).aEnd.Row() == (*it_outer).aEnd.Row() ) { - it->ExtendTo( *it_inner ); + it_outer->ExtendTo( *it_inner ); it_inner = vRanges.erase( it_inner ); + it_inner_erased = true; } #else - else if ( lcl_canJoin( *it, *it_inner ) ) + else if ( lcl_canJoin( *it_outer, *it_inner ) ) { - it->ExtendTo( *it_inner ); + it_outer->ExtendTo( *it_inner ); it_inner = vRanges.erase( it_inner ); + it_inner_erased = true; } - else if ( lcl_canJoin( *it_inner, *it) ) + else if ( lcl_canJoin( *it_inner, *it_outer) ) { - it_inner->ExtendTo( *it ); - it = vRanges.erase( it ); + it_inner->ExtendTo( *it_outer ); + it_outer = vRanges.erase( it_outer ); + it_outer_erased = true; } #endif } + /* If it_inner has not been erased from vRanges, continue inner + loop with next element. Otherwise, it_inner already points to + the next element (return value of list::erase()). */ + if( !it_inner_erased ) + ++it_inner; } + /* If it_outer has not been erased from vRanges, continue outer loop + with next element. Otherwise, it_outer already points to the next + element (return value of list::erase()). */ + if( !it_outer_erased ) + ++it_outer; } } diff --git a/sc/source/ui/vba/vbaformat.cxx b/sc/source/ui/vba/vbaformat.cxx index c98029fb1292..23c2bf96a810 100644 --- a/sc/source/ui/vba/vbaformat.cxx +++ b/sc/source/ui/vba/vbaformat.cxx @@ -45,7 +45,10 @@ #include "vbafont.hxx" #include "vbainterior.hxx" -#include "unonames.hxx" +#include +#include +#include +#include using namespace ::ooo::vba; using namespace ::com::sun::star; @@ -571,14 +574,24 @@ ScVbaFormat::getLocked( ) throw (script::BasicErrorException, uno::Runtim uno::Any aCellProtection = aNULL(); try { - rtl::OUString sCellProt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLPRO ) ); + if (!isAmbiguous(sCellProt)) { - util::CellProtection cellProtection; - mxPropertySet->getPropertyValue(sCellProt) >>= cellProtection; - - aCellProtection = uno::makeAny( cellProtection.IsLocked ); + SfxItemSet* pDataSet = getCurrentDataSet(); + if ( pDataSet ) + { + const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, TRUE); + SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL); + if(eState != SFX_ITEM_DONTCARE) + aCellProtection = uno::makeAny(rProtAttr.GetProtection()); + } + else // fallback to propertyset + { + util::CellProtection cellProtection; + mxPropertySet->getPropertyValue(sCellProt) >>= aCellProtection; + aCellProtection = uno::makeAny( cellProtection.IsLocked ); + } } } catch (uno::Exception& ) @@ -598,9 +611,20 @@ ScVbaFormat::getFormulaHidden( ) throw (script::BasicErrorException, uno: rtl::OUString sCellProt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLPRO ) ); if (!isAmbiguous(sCellProt)) { - util::CellProtection aCellProtection; - mxPropertySet->getPropertyValue(sCellProt) >>= aCellProtection; - aBoolRet = uno::makeAny( aCellProtection.IsFormulaHidden ); + SfxItemSet* pDataSet = getCurrentDataSet(); + if ( pDataSet ) + { + const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, TRUE); + SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL); + if(eState != SFX_ITEM_DONTCARE) + aBoolRet = uno::makeAny(rProtAttr.GetHideFormula()); + } + else + { + util::CellProtection aCellProtection; + mxPropertySet->getPropertyValue(sCellProt) >>= aCellProtection; + aBoolRet = uno::makeAny( aCellProtection.IsFormulaHidden ); + } } } catch (uno::Exception e) @@ -794,6 +818,24 @@ ScVbaFormat::getServiceNames() return aServiceNames; } +template< typename Ifc1 > +ScCellRangesBase* +ScVbaFormat::getCellRangesBase() throw ( ::uno::RuntimeException ) +{ + return ScCellRangesBase::getImplementation( mxPropertySet ); +} + +template< typename Ifc1 > +SfxItemSet* +ScVbaFormat::getCurrentDataSet( ) throw ( uno::RuntimeException ) +{ + SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( getCellRangesBase() ); + if ( !pDataSet ) + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't access Itemset for XPropertySet" ) ), uno::Reference< uno::XInterface >() ); + return pDataSet; +} + + template class ScVbaFormat< excel::XStyle >; template class ScVbaFormat< excel::XRange >; diff --git a/sc/source/ui/vba/vbaformat.hxx b/sc/source/ui/vba/vbaformat.hxx index e024cd68b9ad..bfa88d6c7cb8 100644 --- a/sc/source/ui/vba/vbaformat.hxx +++ b/sc/source/ui/vba/vbaformat.hxx @@ -38,6 +38,8 @@ #include #include +class ScCellRangesBase; + template< typename Ifc1 > class ScVbaFormat : public InheritedHelperInterfaceImpl1< Ifc1 > { @@ -60,6 +62,9 @@ protected: css::uno::Reference< css::beans::XPropertyState > getXPropertyState() throw ( css::uno::RuntimeException ); void initializeNumberFormats() throw ( css::script::BasicErrorException ); void setNumberFormat( css::lang::Locale _aLocale, const rtl::OUString& _sFormatString) throw( css::script::BasicErrorException ); + SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException ); +protected: + virtual ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException ); public: ScVbaFormat( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet, const css::uno::Reference< css::frame::XModel >& xModel, bool bCheckAmbiguoity ) throw ( css::script::BasicErrorException ); virtual ~ScVbaFormat() {} diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index b3307ffdc55d..1a153b440b15 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -238,21 +238,28 @@ uno::Reference< excel::XRange > lcl_makeXRangeFromSheetCellRanges( const uno::Re return xRange; } -ScCellRangeObj* ScVbaRange::getCellRangeObj() throw ( uno::RuntimeException ) +ScCellRangesBase* ScVbaRange::getCellRangesBase() throw ( uno::RuntimeException ) { - uno::Reference< uno::XInterface > xIf; - if ( mxRanges.is() ) - xIf.set( mxRanges, uno::UNO_QUERY_THROW ); - else - xIf.set( mxRange, uno::UNO_QUERY_THROW ); - ScCellRangeObj* pUnoCellRange = dynamic_cast< ScCellRangeObj* >( xIf.get() ); - return pUnoCellRange; + if( mxRanges.is() ) + return ScCellRangesBase::getImplementation( mxRanges ); + if( mxRange.is() ) + return ScCellRangesBase::getImplementation( mxRange ); + throw uno::RuntimeException( rtl::OUString::createFromAscii("General Error creating range - Unknown" ), uno::Reference< uno::XInterface >() ); +} + +ScCellRangeObj* ScVbaRange::getCellRangeObj() throw ( uno::RuntimeException ) +{ + return dynamic_cast< ScCellRangeObj* >( getCellRangesBase() ); +} + +ScCellRangesObj* ScVbaRange::getCellRangesObj() throw ( uno::RuntimeException ) +{ + return dynamic_cast< ScCellRangesObj* >( getCellRangesBase() ); } SfxItemSet* ScVbaRange::getCurrentDataSet( ) throw ( uno::RuntimeException ) { - ScCellRangeObj* pUnoCellRange = getCellRangeObj(); - SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( pUnoCellRange ); + SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( getCellRangesBase() ); if ( !pDataSet ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't access Itemset for range" ) ), uno::Reference< uno::XInterface >() ); return pDataSet; @@ -3852,25 +3859,6 @@ ScVbaRange::getWorksheet() throw (uno::RuntimeException) return xSheet; } -ScCellRangesBase* -ScVbaRange::getCellRangesBase() throw( uno::RuntimeException ) -{ - ScCellRangesBase* pUnoRangesBase = NULL; - if ( mxRanges.is() ) - { - uno::Reference< uno::XInterface > xIf( mxRanges, uno::UNO_QUERY_THROW ); - pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() ); - } - else if ( mxRange.is() ) - { - uno::Reference< uno::XInterface > xIf( mxRange, uno::UNO_QUERY_THROW ); - pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() ); - } - else - throw uno::RuntimeException( rtl::OUString::createFromAscii("General Error creating range - Unknown" ), uno::Reference< uno::XInterface >() ); - return pUnoRangesBase; -} - // #TODO remove this ugly application processing // Process an application Range request e.g. 'Range("a1,b2,a4:b6") uno::Reference< excel::XRange > @@ -4589,26 +4577,6 @@ ScVbaRange::getValidation() throw (css::uno::RuntimeException) return m_xValidation; } -uno::Any ScVbaRange::getFormulaHidden() throw ( script::BasicErrorException, css::uno::RuntimeException) -{ - SfxItemSet* pDataSet = getCurrentDataSet(); - const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) - pDataSet->Get(ATTR_PROTECTION, TRUE); - SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL); - if(eState == SFX_ITEM_DONTCARE) - return aNULL(); - return uno::makeAny(rProtAttr.GetHideFormula()); - -} -void ScVbaRange::setFormulaHidden(const uno::Any& Hidden) throw ( script::BasicErrorException, css::uno::RuntimeException) -{ - uno::Reference< beans::XPropertySet > xProps(mxRange, ::uno::UNO_QUERY_THROW); - util::CellProtection rCellAttr; - xProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLPRO))) >>= rCellAttr; - Hidden >>= rCellAttr.IsFormulaHidden; - xProps->setPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLPRO)), uno::makeAny(rCellAttr)); -} - uno::Any ScVbaRange::getShowDetail() throw ( css::uno::RuntimeException) { // #FIXME, If the specified range is in a PivotTable report diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index 89ae741c7535..1f161a79d973 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -57,6 +57,7 @@ class ScTableSheetsObj; class ScCellRangesBase; class ScCellRangeObj; +class ScCellRangesObj; class ScDocShell; class ScDocument; @@ -111,14 +112,16 @@ class ScVbaRange : public ScVbaRange_BASE virtual css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar ) throw (css::uno::RuntimeException); virtual void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar ) throw ( css::uno::RuntimeException); css::uno::Reference< ov::excel::XRange > getArea( sal_Int32 nIndex ) throw( css::uno::RuntimeException ); - ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException ); ScCellRangeObj* getCellRangeObj( ) throw ( css::uno::RuntimeException ); - SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException ); + ScCellRangesObj* getCellRangesObj() throw ( css::uno::RuntimeException ); css::uno::Reference< ov::XCollection >& getBorders(); void groupUnGroup( bool bUnGroup = false ) throw ( css::script::BasicErrorException, css::uno::RuntimeException ); css::uno::Reference< ov::excel::XRange > PreviousNext( bool bIsPrevious ); css::uno::Reference< ov::excel::XRange > SpecialCellsImpl( sal_Int32 nType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException ); css::awt::Point getPosition() throw ( css::uno::RuntimeException ); +protected: + virtual ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException ); + virtual SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException ); public: ScVbaRange( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::table::XCellRange >& xRange, sal_Bool bIsRows = false, sal_Bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException ); ScVbaRange( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges, sal_Bool bIsRows = false, sal_Bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException ); @@ -170,10 +173,6 @@ public: virtual css::uno::Any SAL_CALL getPageBreak() throw (css::uno::RuntimeException); virtual void SAL_CALL setPageBreak( const css::uno::Any& _pagebreak ) throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XValidation > SAL_CALL getValidation() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getFormulaHidden() throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL setFormulaHidden(const css::uno::Any& aHidden) throw (css::script::BasicErrorException, css::uno::RuntimeException); - //virtual css::uno::Any SAL_CALL getLocked() throw (css::script::BasicErrorException, css::uno::RuntimeException); - //virtual void SAL_CALL setLocked(const css::uno::Any& aLocked) throw (css::script::BasicErrorException, css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getShowDetail() throw (css::uno::RuntimeException); virtual void SAL_CALL setShowDetail(const css::uno::Any& aShowDetail) throw (css::uno::RuntimeException); // Methods -- cgit From 0e17741fb26f9aa7d6ec986c5b03e2846da6a964 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 14 Apr 2010 12:31:52 +0100 Subject: npower13_objectmodules: add a CodeName property for Sheet and Document/Model objects --- sc/inc/unonames.hxx | 1 + sc/inc/unowids.hxx | 3 ++- sc/source/ui/unoobj/cellsuno.cxx | 17 +++++++++++++++++ sc/source/ui/unoobj/docuno.cxx | 13 +++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index f5de35c9d033..5bcc22ae72d3 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -484,6 +484,7 @@ #define SC_UNO_ISEXECUTELINKENABLED "IsExecuteLinkEnabled" #define SC_UNO_ISCHANGEREADONLYENABLED "IsChangeReadOnlyEnabled" #define SC_UNO_REFERENCEDEVICE "ReferenceDevice" +#define SC_UNO_CODENAME "CodeName" // document properties from FormModel #define SC_UNO_APPLYFMDES "ApplyFormDesignMode" diff --git a/sc/inc/unowids.hxx b/sc/inc/unowids.hxx index 1765b9d06361..f58c3248bf81 100644 --- a/sc/inc/unowids.hxx +++ b/sc/inc/unowids.hxx @@ -77,7 +77,8 @@ #define SC_WID_UNO_TABLAYOUT ( SC_WID_UNO_START + 37 ) #define SC_WID_UNO_AUTOPRINT ( SC_WID_UNO_START + 38 ) #define SC_WID_UNO_ABSNAME ( SC_WID_UNO_START + 39 ) -#define SC_WID_UNO_END ( SC_WID_UNO_START + 39 ) +#define SC_WID_UNO_CODENAME ( SC_WID_UNO_START + 40 ) +#define SC_WID_UNO_END ( SC_WID_UNO_START + 40 ) inline BOOL IsScUnoWid( USHORT nWid ) diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index c61a6443af99..2c1774b8994d 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -769,6 +769,7 @@ const SfxItemPropertySet* lcl_GetSheetPropertySet() {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((table::CellVertJustify*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNO_CODENAME), SC_WID_UNO_CODENAME, &getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0}, {0,0,0,0,0,0} }; static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl ); @@ -8467,6 +8468,15 @@ void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEn pDoc->ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag. } } + else if ( pEntry->nWID == SC_WID_UNO_CODENAME ) + { + rtl::OUString aCodeName; + if ( pDocSh && ( aValue >>= aCodeName ) ) + { + String sNewName( aCodeName ); + pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), sNewName ); + } + } else ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID } @@ -8605,6 +8615,13 @@ void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEn BOOL bAutoPrint = pDoc->IsPrintEntireSheet( nTab ); ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint ); } + else if ( pEntry->nWID == SC_WID_UNO_CODENAME ) + { + String aCodeName; + if ( pDocSh ) + pDocSh->GetDocument()->GetCodeName( GetTab_Impl(), aCodeName ); + rAny <<= rtl::OUString( aCodeName ); + } else ScCellRangeObj::GetOnePropertyValue(pEntry, rAny); } diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 8e857adca09c..826f7b59bf32 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -152,6 +152,7 @@ const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap() {MAP_CHAR_LEN(SC_UNO_ISCHANGEREADONLYENABLED), 0, &getBooleanCppuType(), 0, 0}, {MAP_CHAR_LEN(SC_UNO_REFERENCEDEVICE), 0, &getCppuType((uno::Reference*)0), beans::PropertyAttribute::READONLY, 0}, {MAP_CHAR_LEN("BuildId"), 0, &::getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0}, + {MAP_CHAR_LEN(SC_UNO_CODENAME), 0, &getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0}, {0,0,0,0,0,0} }; @@ -1651,6 +1652,12 @@ void SAL_CALL ScModelObj::setPropertyValue( pDoc->SetLanguage( eLatin, eCjk, eCtl ); } } + else if ( aString.EqualsAscii( SC_UNO_CODENAME ) ) + { + rtl::OUString sCodeName; + if ( aValue >>= sCodeName ) + pDoc->SetCodeName( sCodeName ); + } else if ( aString.EqualsAscii( SC_UNO_CJK_CLOCAL ) ) { lang::Locale aLocale; @@ -1783,6 +1790,12 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyNa ScUnoConversion::FillLocale( aLocale, eLatin ); aRet <<= aLocale; } + else if ( aString.EqualsAscii( SC_UNO_CODENAME ) ) + { + rtl::OUString sCodeName = pDoc->GetCodeName(); + aRet <<= sCodeName; + } + else if ( aString.EqualsAscii( SC_UNO_CJK_CLOCAL ) ) { LanguageType eLatin, eCjk, eCtl; -- cgit From 319c08647f115aaba7f5633376531cbfb4746b2f Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 17:31:33 +0200 Subject: npower13_objectmodules: make vba import available in oox filters --- oox/inc/oox/core/filterbase.hxx | 22 +- .../oox/drawingml/chart/chartdrawingfragment.hxx | 6 +- oox/inc/oox/drawingml/color.hxx | 4 +- oox/inc/oox/drawingml/customshapeproperties.hxx | 5 +- oox/inc/oox/drawingml/fillproperties.hxx | 9 +- oox/inc/oox/drawingml/lineproperties.hxx | 4 +- oox/inc/oox/dump/biffdumper.hxx | 8 +- oox/inc/oox/dump/dumperbase.hxx | 109 +- oox/inc/oox/dump/oledumper.hxx | 418 +++++-- oox/inc/oox/dump/xlsbdumper.hxx | 2 +- oox/inc/oox/helper/binaryinputstream.hxx | 69 ++ oox/inc/oox/helper/binaryoutputstream.hxx | 5 - oox/inc/oox/helper/binarystreambase.hxx | 15 +- oox/inc/oox/helper/containerhelper.hxx | 131 ++- oox/inc/oox/helper/graphichelper.hxx | 74 +- oox/inc/oox/helper/helper.hxx | 24 +- oox/inc/oox/helper/modelobjecthelper.hxx | 2 +- oox/inc/oox/helper/olestorage.hxx | 103 -- oox/inc/oox/helper/propertyset.hxx | 4 + oox/inc/oox/helper/storagebase.hxx | 65 +- oox/inc/oox/helper/textinputstream.hxx | 58 + oox/inc/oox/helper/zipstorage.hxx | 6 +- oox/inc/oox/ole/axbinaryreader.hxx | 109 +- oox/inc/oox/ole/axcontrol.hxx | 568 +++++++-- oox/inc/oox/ole/axcontrolfragment.hxx | 14 +- oox/inc/oox/ole/axcontrolhelper.hxx | 118 -- oox/inc/oox/ole/olehelper.hxx | 79 +- oox/inc/oox/ole/olestorage.hxx | 116 ++ oox/inc/oox/ole/vbacontrol.hxx | 205 ++++ oox/inc/oox/ole/vbahelper.hxx | 233 ++++ oox/inc/oox/ole/vbamodule.hxx | 96 ++ oox/inc/oox/ole/vbaproject.hxx | 289 +++++ oox/inc/oox/ppt/pptimport.hxx | 5 +- oox/inc/oox/vml/vmldrawing.hxx | 14 +- oox/inc/oox/vml/vmlformatting.hxx | 21 +- oox/inc/oox/xls/biffhelper.hxx | 2 + oox/inc/oox/xls/excelfilter.hxx | 22 +- oox/inc/oox/xls/excelvbaproject.hxx | 73 ++ oox/inc/oox/xls/stylesbuffer.hxx | 19 +- oox/inc/oox/xls/workbookfragment.hxx | 3 + oox/inc/oox/xls/workbookhelper.hxx | 107 +- oox/inc/oox/xls/worksheetsettings.hxx | 2 + oox/prj/build.lst | 2 +- oox/prj/d.lst | 5 + oox/source/core/binaryfilterbase.cxx | 6 +- oox/source/core/filterbase.cxx | 105 +- oox/source/core/filterdetect.cxx | 4 +- oox/source/core/recordparser.cxx | 7 +- oox/source/docprop/docprophandler.cxx | 2 +- .../drawingml/chart/chartdrawingfragment.cxx | 6 +- oox/source/drawingml/chart/objectformatter.cxx | 8 +- oox/source/drawingml/clrschemecontext.cxx | 2 +- oox/source/drawingml/color.cxx | 12 +- oox/source/drawingml/customshapeproperties.cxx | 5 +- oox/source/drawingml/fillproperties.cxx | 54 +- .../drawingml/fillpropertiesgroupcontext.cxx | 12 +- oox/source/drawingml/lineproperties.cxx | 15 +- oox/source/drawingml/linepropertiescontext.cxx | 2 +- oox/source/drawingml/shape.cxx | 17 +- oox/source/drawingml/table/tablecell.cxx | 4 +- oox/source/drawingml/textcharacterproperties.cxx | 4 +- oox/source/drawingml/textfont.cxx | 4 +- oox/source/drawingml/textparagraphproperties.cxx | 2 +- oox/source/dump/biffdumper.cxx | 333 +++--- oox/source/dump/biffdumper.ini | 4 +- oox/source/dump/dffdumper.cxx | 32 +- oox/source/dump/dumperbase.cxx | 371 +++--- oox/source/dump/oledumper.cxx | 1237 ++++++++++++++------ oox/source/dump/oledumper.ini | 439 +++++-- oox/source/dump/pptxdumper.cxx | 9 +- oox/source/dump/xlsbdumper.cxx | 241 ++-- oox/source/helper/binaryinputstream.cxx | 97 +- oox/source/helper/binaryoutputstream.cxx | 20 - oox/source/helper/binarystreambase.cxx | 21 +- oox/source/helper/graphichelper.cxx | 224 +++- oox/source/helper/makefile.mk | 2 +- oox/source/helper/modelobjecthelper.cxx | 10 +- oox/source/helper/olestorage.cxx | 180 --- oox/source/helper/propertyset.cxx | 44 +- oox/source/helper/storagebase.cxx | 145 ++- oox/source/helper/textinputstream.cxx | 128 ++ oox/source/helper/zipstorage.cxx | 56 +- oox/source/ole/axbinaryreader.cxx | 100 +- oox/source/ole/axcontrol.cxx | 1120 ++++++++++++------ oox/source/ole/axcontrolfragment.cxx | 35 +- oox/source/ole/axcontrolhelper.cxx | 175 --- oox/source/ole/makefile.mk | 8 +- oox/source/ole/olehelper.cxx | 113 +- oox/source/ole/olestorage.cxx | 420 +++++++ oox/source/ole/vbacontrol.cxx | 811 +++++++++++++ oox/source/ole/vbahelper.cxx | 248 ++++ oox/source/ole/vbamodule.cxx | 241 ++++ oox/source/ole/vbaproject.cxx | 519 ++++++++ oox/source/ppt/animvariantcontext.cxx | 2 +- oox/source/ppt/pptimport.cxx | 30 + oox/source/ppt/slidepersist.cxx | 2 +- oox/source/ppt/timenodelistcontext.cxx | 12 +- oox/source/token/properties.txt | 18 + oox/source/vml/vmldrawing.cxx | 20 +- oox/source/vml/vmlformatting.cxx | 41 +- oox/source/vml/vmlshape.cxx | 22 +- oox/source/vml/vmlshapecontainer.cxx | 1 - oox/source/xls/biffdetector.cxx | 6 +- oox/source/xls/biffhelper.cxx | 97 +- oox/source/xls/excelfilter.cxx | 56 +- oox/source/xls/excelvbaproject.cxx | 214 ++++ oox/source/xls/formulaparser.cxx | 3 - oox/source/xls/makefile.mk | 1 + oox/source/xls/sheetdatacontext.cxx | 4 - oox/source/xls/stylesbuffer.cxx | 77 +- oox/source/xls/unitconverter.cxx | 2 +- oox/source/xls/viewsettings.cxx | 2 +- oox/source/xls/workbookfragment.cxx | 73 +- oox/source/xls/workbookhelper.cxx | 202 +--- oox/source/xls/workbooksettings.cxx | 5 +- oox/source/xls/worksheetfragment.cxx | 3 +- oox/source/xls/worksheethelper.cxx | 63 +- oox/source/xls/worksheetsettings.cxx | 11 + oox/util/makefile.mk | 3 +- 119 files changed, 8634 insertions(+), 3235 deletions(-) delete mode 100644 oox/inc/oox/helper/olestorage.hxx create mode 100755 oox/inc/oox/helper/textinputstream.hxx delete mode 100644 oox/inc/oox/ole/axcontrolhelper.hxx create mode 100755 oox/inc/oox/ole/olestorage.hxx create mode 100755 oox/inc/oox/ole/vbacontrol.hxx create mode 100755 oox/inc/oox/ole/vbahelper.hxx create mode 100755 oox/inc/oox/ole/vbamodule.hxx create mode 100755 oox/inc/oox/ole/vbaproject.hxx create mode 100755 oox/inc/oox/xls/excelvbaproject.hxx delete mode 100644 oox/source/helper/olestorage.cxx create mode 100755 oox/source/helper/textinputstream.cxx delete mode 100644 oox/source/ole/axcontrolhelper.cxx create mode 100755 oox/source/ole/olestorage.cxx create mode 100755 oox/source/ole/vbacontrol.cxx create mode 100755 oox/source/ole/vbahelper.cxx create mode 100755 oox/source/ole/vbamodule.cxx create mode 100755 oox/source/ole/vbaproject.cxx create mode 100755 oox/source/xls/excelvbaproject.cxx diff --git a/oox/inc/oox/core/filterbase.hxx b/oox/inc/oox/core/filterbase.hxx index b086538db73e..b2709ea4b33b 100644 --- a/oox/inc/oox/core/filterbase.hxx +++ b/oox/inc/oox/core/filterbase.hxx @@ -145,12 +145,12 @@ public: @param rStorageName The name of the embedded storage. The name may contain slashes to open storages from embedded substorages. - @param bCreate + @param bCreateMissing True = create missing sub storages (for export filters). */ StorageRef openSubStorage( const ::rtl::OUString& rStorageName, - bool bCreate ) const; + bool bCreateMissing ) const; /** Opens and returns the specified input stream from the base storage. @@ -189,20 +189,6 @@ public: /** Returns a helper for the handling of OLE obejcts. */ ::oox::ole::OleObjectHelper& getOleObjectHelper() const; - /** Returns information about the output device. */ - const ::com::sun::star::awt::DeviceInfo& getDeviceInfo() const; - /** Converts the passed value from horizontal screen pixels to 1/100 mm. */ - sal_Int32 convertScreenPixelX( double fPixelX ) const; - /** Converts the passed value from vertical screen pixels to 1/100 mm. */ - sal_Int32 convertScreenPixelY( double fPixelY ) const; - - /** Returns a system color specified by the passed XML token identifier. */ - sal_Int32 getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb = API_RGB_TRANSPARENT ) const; - /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */ - virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; - /** Derived classes may implement to resolve a palette index to an RGB color. */ - virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; - /** Requests a password from the media descriptor or from the user. On success, the password will be inserted into the media descriptor. */ ::rtl::OUString requestPassword( ::comphelper::IDocPasswordVerifier& rVerifier ) const; @@ -282,6 +268,10 @@ private: void setMediaDescriptor( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rMediaDescSeq ); + /** Derived classes may create a specialized graphic helper, e.g. for + resolving palette colors. */ + virtual GraphicHelper* implCreateGraphicHelper() const; + virtual ::rtl::OUString implGetImplementationName() const = 0; virtual StorageRef implCreateStorage( diff --git a/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx b/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx index e38311394046..0b5a7f6374a4 100644 --- a/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx +++ b/oox/inc/oox/drawingml/chart/chartdrawingfragment.hxx @@ -2,14 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: chartdrawingfragment.hxx,v $ - * - * $Revision: 1.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/oox/inc/oox/drawingml/color.hxx b/oox/inc/oox/drawingml/color.hxx index 830959b77db9..51e9501205cf 100644 --- a/oox/inc/oox/drawingml/color.hxx +++ b/oox/inc/oox/drawingml/color.hxx @@ -35,7 +35,7 @@ #include #include "oox/helper/helper.hxx" -namespace oox { namespace core { class FilterBase; } } +namespace oox { class GraphicHelper; } namespace oox { namespace drawingml { @@ -90,7 +90,7 @@ public: bool isPlaceHolder() const { return meMode == COLOR_PH; } /** Returns the final RGB color value. @param nPhClr Actual color for the phClr placeholder color used in theme style lists. */ - sal_Int32 getColor( const ::oox::core::FilterBase& rFilter, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; + sal_Int32 getColor( const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Returns true, if the color has a transparence set. */ bool hasTransparence() const; diff --git a/oox/inc/oox/drawingml/customshapeproperties.hxx b/oox/inc/oox/drawingml/customshapeproperties.hxx index 4e4b82cd5acd..44e91d6e797b 100644 --- a/oox/inc/oox/drawingml/customshapeproperties.hxx +++ b/oox/inc/oox/drawingml/customshapeproperties.hxx @@ -43,9 +43,7 @@ #include #include #include -#ifndef __com_sun_star_beans_PropertyValues_hpp__ #include -#endif #include #include @@ -69,8 +67,7 @@ public: virtual ~CustomShapeProperties(); void apply( const CustomShapePropertiesPtr& ); - void pushToPropSet( const ::oox::core::FilterBase& rFilterBase, - const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, + void pushToPropSet( const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > & xShape) const; void setShapePresetType( const rtl::OUString& rShapePresetType ){ maShapePresetType = rShapePresetType; }; diff --git a/oox/inc/oox/drawingml/fillproperties.hxx b/oox/inc/oox/drawingml/fillproperties.hxx index be6561c970d3..42457e6f4dde 100644 --- a/oox/inc/oox/drawingml/fillproperties.hxx +++ b/oox/inc/oox/drawingml/fillproperties.hxx @@ -35,6 +35,7 @@ #include "oox/helper/helper.hxx" namespace oox { + class GraphicHelper; class ModelObjectHelper; class PropertyMap; class PropertySet; @@ -156,8 +157,8 @@ struct FillProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nShapeRotation = 0, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; @@ -165,8 +166,8 @@ struct FillProperties /** Writes the properties to the passed property set. */ void pushToPropSet( PropertySet& rPropSet, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nShapeRotation = 0, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; @@ -184,13 +185,13 @@ struct GraphicProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Writes the properties to the passed property set. */ void pushToPropSet( PropertySet& rPropSet, - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; diff --git a/oox/inc/oox/drawingml/lineproperties.hxx b/oox/inc/oox/drawingml/lineproperties.hxx index 9a538db30156..0f034a89f65b 100644 --- a/oox/inc/oox/drawingml/lineproperties.hxx +++ b/oox/inc/oox/drawingml/lineproperties.hxx @@ -104,16 +104,16 @@ struct LineProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Writes the properties to the passed property map. */ void pushToPropSet( PropertySet& rPropSet, - const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; diff --git a/oox/inc/oox/dump/biffdumper.hxx b/oox/inc/oox/dump/biffdumper.hxx index 5a7e390d19a4..e9016fdf0b2b 100644 --- a/oox/inc/oox/dump/biffdumper.hxx +++ b/oox/inc/oox/dump/biffdumper.hxx @@ -217,7 +217,7 @@ protected: void dumpDffClientRect(); void dumpEmbeddedDff(); - void dumpOcxControl(); + void dumpControl(); private: typedef ::boost::shared_ptr< BiffSharedData > BiffSharedDataRef; @@ -242,7 +242,7 @@ void BiffObjectBase::writeRectItem( const String& rName, Type nLeft, Type nTop, Type nWidth, Type nHeight, const NameListWrapper& rListWrp, FormatType eFmtType ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName ); writeValueItem( "x-pos", nLeft, eFmtType, rListWrp ); writeValueItem( "y-pos", nTop, eFmtType, rListWrp ); @@ -508,6 +508,10 @@ protected: const StorageRef& rxStrg, const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rSysPath ); + + virtual void implDumpBaseStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); }; // ============================================================================ diff --git a/oox/inc/oox/dump/dumperbase.hxx b/oox/inc/oox/dump/dumperbase.hxx index ecca5751c16c..f65eeceebf27 100644 --- a/oox/inc/oox/dump/dumperbase.hxx +++ b/oox/inc/oox/dump/dumperbase.hxx @@ -61,6 +61,7 @@ namespace comphelper { namespace oox { class BinaryOutputStream; + class TextInputStream; } namespace oox { namespace core { @@ -576,43 +577,41 @@ protected: // ============================================================================ // ============================================================================ -typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream > ConfigInputStreamRef; - class ConfigItemBase { public: virtual ~ConfigItemBase(); - void readConfigBlock( const ConfigInputStreamRef& rxStrm ); + void readConfigBlock( TextInputStream& rStrm ); protected: inline explicit ConfigItemBase() {} virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); virtual void implProcessConfigItemInt( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, sal_Int64 nKey, const ::rtl::OUString& rData ); void readConfigBlockContents( - const ConfigInputStreamRef& rxStrm ); + TextInputStream& rStrm ); private: enum LineType { LINETYPE_DATA, LINETYPE_END }; LineType readConfigLine( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, ::rtl::OUString& orKey, ::rtl::OUString& orData ) const; LineType readConfigLine( - const ConfigInputStreamRef& rxStrm ) const; + TextInputStream& rStrm ) const; void processConfigItem( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); }; @@ -673,12 +672,12 @@ protected: virtual bool implIsValid() const; virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); virtual void implProcessConfigItemInt( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, sal_Int64 nKey, const ::rtl::OUString& rData ); @@ -721,7 +720,7 @@ public: protected: virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); @@ -750,7 +749,7 @@ public: protected: virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); @@ -777,7 +776,7 @@ public: protected: virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); @@ -917,14 +916,14 @@ public: protected: virtual bool implIsValid() const; virtual void implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, + TextInputStream& rStrm, const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); private: bool readConfigFile( const ::rtl::OUString& rFileUrl ); template< typename ListType > - void readNameList( const ConfigInputStreamRef& rxStrm, const ::rtl::OUString& rListName ); + void readNameList( TextInputStream& rStrm, const ::rtl::OUString& rListName ); void createShortList( const ::rtl::OUString& rData ); void createUnitConverter( const ::rtl::OUString& rData ); @@ -960,11 +959,11 @@ template< typename ListType > } template< typename ListType > -void SharedConfigData::readNameList( const ConfigInputStreamRef& rxStrm, const ::rtl::OUString& rListName ) +void SharedConfigData::readNameList( TextInputStream& rStrm, const ::rtl::OUString& rListName ) { NameListRef xList = createNameList< ListType >( rListName ); if( xList.get() ) - xList->readConfigBlock( rxStrm ); + xList->readConfigBlock( rStrm ); } // ============================================================================ @@ -1182,7 +1181,7 @@ typedef ::boost::shared_ptr< Output > OutputRef; class IndentGuard { public: - inline explicit IndentGuard( Output& rOut ) : mrOut( rOut ) { mrOut.incIndent(); } + inline explicit IndentGuard( const OutputRef& rxOut ) : mrOut( *rxOut ) { mrOut.incIndent(); } inline ~IndentGuard() { mrOut.decIndent(); } private: IndentGuard( const IndentGuard& ); @@ -1196,17 +1195,17 @@ private: class TableGuard { public: - inline explicit TableGuard( Output& rOut, sal_Int32 nW1 ) : - mrOut( rOut ) { mrOut.startTable( nW1 ); } - inline explicit TableGuard( Output& rOut, sal_Int32 nW1, sal_Int32 nW2 ) : - mrOut( rOut ) { mrOut.startTable( nW1, nW2 ); } - inline explicit TableGuard( Output& rOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3 ) : - mrOut( rOut ) { mrOut.startTable( nW1, nW2, nW3 ); } - inline explicit TableGuard( Output& rOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 ) : - mrOut( rOut ) { mrOut.startTable( nW1, nW2, nW3, nW4 ); } - inline explicit TableGuard( Output& rOut, size_t nColCount, + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1 ); } + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1, nW2 ); } + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1, nW2, nW3 ); } + inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 ) : + mrOut( *rxOut ) { mrOut.startTable( nW1, nW2, nW3, nW4 ); } + inline explicit TableGuard( const OutputRef& rxOut, size_t nColCount, const sal_Int32* pnColWidths ) : - mrOut( rOut ) { mrOut.startTable( nColCount, pnColWidths ); } + mrOut( *rxOut ) { mrOut.startTable( nColCount, pnColWidths ); } inline ~TableGuard() { mrOut.endTable(); } inline void tab() { mrOut.tab(); } inline void tab( size_t nCol ) { mrOut.tab( nCol ); } @@ -1222,8 +1221,8 @@ private: class ItemGuard { public: - inline explicit ItemGuard( Output& rOut, const String& rName = EMPTY_STRING ) : - mrOut( rOut ) { mrOut.startItem( rName ); } + inline explicit ItemGuard( const OutputRef& rxOut, const String& rName = EMPTY_STRING ) : + mrOut( *rxOut ) { mrOut.startItem( rName ); } inline ~ItemGuard() { mrOut.endItem(); } inline void cont() { mrOut.contItem(); } private: @@ -1238,7 +1237,7 @@ private: class MultiItemsGuard { public: - inline explicit MultiItemsGuard( Output& rOut ) : mrOut( rOut ) { mrOut.startMultiItems(); } + inline explicit MultiItemsGuard( const OutputRef& rxOut ) : mrOut( *rxOut ) { mrOut.startMultiItems(); } inline ~MultiItemsGuard() { mrOut.endMultiItems(); } private: MultiItemsGuard( const MultiItemsGuard& ); @@ -1280,7 +1279,8 @@ class ObjectBase : public Base public: virtual ~ObjectBase(); - inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getFactory() const { return mxConfig->getFactory(); } + inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& + getFactory() const { return mxConfig->getFactory(); } void dump(); @@ -1333,6 +1333,10 @@ protected: const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rSysPath ); + virtual void implDumpBaseStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); + void addPreferredStream( const String& rStrmName ); void addPreferredStorage( const String& rStrgPath ); @@ -1355,7 +1359,7 @@ private: const StorageRef& rxStrg, const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rItemName, - const ::rtl::OUString& rSysOutPath, + const ::rtl::OUString& rSysPath, bool bIsStrg, bool bIsStrm ); private: @@ -1397,10 +1401,6 @@ protected: // ------------------------------------------------------------------------ - inline Output& out() const { return *mxOut; } - - // ------------------------------------------------------------------------ - void writeEmptyItem( const String& rName ); void writeInfoItem( const String& rName, const String& rData ); void writeCharItem( const String& rName, sal_Unicode cData ); @@ -1451,7 +1451,7 @@ protected: template< typename Type > void writeHexPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep = ',' ); -private: +protected: OutputRef mxOut; }; @@ -1472,14 +1472,14 @@ void OutputObjectBase::addNameToItem( Type nData, const NameListWrapper& rListWr template< typename Type > void OutputObjectBase::writeNameItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeName( cfg(), nData, rListWrp ); } template< typename Type > void OutputObjectBase::writeDecItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDec( nData ); addNameToItem( nData, rListWrp ); } @@ -1487,7 +1487,7 @@ void OutputObjectBase::writeDecItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeHex( nData ); addNameToItem( nData, rListWrp ); } @@ -1495,7 +1495,7 @@ void OutputObjectBase::writeHexItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeShortHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeShortHex( nData ); addNameToItem( nData, rListWrp ); } @@ -1503,7 +1503,7 @@ void OutputObjectBase::writeShortHexItem( const String& rName, Type nData, const template< typename Type > void OutputObjectBase::writeBinItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeBin( nData ); addNameToItem( nData, rListWrp ); } @@ -1511,7 +1511,7 @@ void OutputObjectBase::writeBinItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeFixItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeFix( nData ); addNameToItem( nData, rListWrp ); } @@ -1519,7 +1519,7 @@ void OutputObjectBase::writeFixItem( const String& rName, Type nData, const Name template< typename Type > void OutputObjectBase::writeDecBoolItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDec( nData ); aItem.cont(); mxOut->writeBool( nData != 0 ); @@ -1533,7 +1533,7 @@ void OutputObjectBase::writeValueItem( const String& rName, Type nData, FormatTy writeDecBoolItem( rName, nData, rListWrp ); else { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeValue( nData, eFmtType ); addNameToItem( nData, rListWrp ); } @@ -1549,7 +1549,7 @@ void OutputObjectBase::writeValueItem( const ItemFormat& rItemFmt, Type nData ) template< typename Type > void OutputObjectBase::writeDecPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDec( nData1 ); mxOut->writeChar( cSep ); mxOut->writeDec( nData2 ); @@ -1558,7 +1558,7 @@ void OutputObjectBase::writeDecPairItem( const String& rName, Type nData1, Type template< typename Type > void OutputObjectBase::writeHexPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeHex( nData1 ); mxOut->writeChar( cSep ); mxOut->writeHex( nData2 ); @@ -1586,7 +1586,6 @@ protected: // ------------------------------------------------------------------------ - inline BinaryInputStream& in() const { return *mxStrm; } ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > getXInputStream() const; @@ -1655,7 +1654,7 @@ protected: template< typename Type > void dumpHexPair( const String& rName, sal_Unicode cSep = ',' ); -private: +protected: BinaryInputStreamRef mxStrm; }; @@ -1822,16 +1821,12 @@ public: rtl_TextEncoding eTextEnc ); protected: + virtual bool implIsValid() const; virtual void implDump(); virtual void implDumpLine( const ::rtl::OUString& rLine, sal_uInt32 nLine ); private: - bool readCharLine( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); - bool readUcs2Line( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); - bool readLine( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); - -private: - rtl_TextEncoding meTextEnc; + ::boost::shared_ptr< TextInputStream > mxTextStrm; }; // ============================================================================ diff --git a/oox/inc/oox/dump/oledumper.hxx b/oox/inc/oox/dump/oledumper.hxx index 539ca2a412d1..a0e9cd55e337 100644 --- a/oox/inc/oox/dump/oledumper.hxx +++ b/oox/inc/oox/dump/oledumper.hxx @@ -43,7 +43,26 @@ namespace dump { // ============================================================================ // ============================================================================ -class StdFontObject : public InputObjectBase +class OleInputObjectBase : public InputObjectBase +{ +protected: + inline explicit OleInputObjectBase() {} + + ::rtl::OUString dumpAnsiString32( const String& rName ); + ::rtl::OUString dumpUniString32( const String& rName ); + + sal_Int32 dumpStdClipboardFormat( const String& rName = EMPTY_STRING ); + ::rtl::OUString dumpAnsiString32OrStdClip( const String& rName ); + ::rtl::OUString dumpUniString32OrStdClip( const String& rName ); + + void writeOleColorItem( const String& rName, sal_uInt32 nColor ); + sal_uInt32 dumpOleColor( const String& rName ); +}; + +// ============================================================================ +// ============================================================================ + +class StdFontObject : public OleInputObjectBase { public: explicit StdFontObject( const InputObjectBase& rParent ); @@ -54,7 +73,7 @@ protected: // ============================================================================ -class StdPicObject : public InputObjectBase +class StdPicObject : public OleInputObjectBase { public: explicit StdPicObject( const InputObjectBase& rParent ); @@ -65,7 +84,7 @@ protected: // ============================================================================ -class StdHlinkObject : public InputObjectBase +class StdHlinkObject : public OleInputObjectBase { public: explicit StdHlinkObject( const InputObjectBase& rParent ); @@ -87,7 +106,27 @@ private: // ============================================================================ // ============================================================================ -class OlePropertyStreamObject : public BinaryStreamObject +class OleStreamObject : public OleInputObjectBase +{ +public: + explicit OleStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); +}; + +// ============================================================================ + +class OleCompObjObject : public OleStreamObject +{ +public: + explicit OleCompObjObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); + +protected: + virtual void implDump(); +}; + +// ============================================================================ +// ============================================================================ + +class OlePropertyStreamObject : public InputObjectBase { public: explicit OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); @@ -146,35 +185,140 @@ protected: // ============================================================================ // ============================================================================ -struct OcxFormSiteInfo +class ComCtlObjectBase : public OleInputObjectBase { - ::rtl::OUString maProgId; - sal_Int32 mnId; - sal_uInt32 mnLength; - bool mbInStream; +protected: + explicit ComCtlObjectBase( + const InputObjectBase& rParent, + sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion, + bool bCommonPart, bool bComplexPart ); + + virtual void implDump(); + virtual void implDumpProperties() = 0; + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + virtual void implDumpCommonTrailing(); + +private: + bool dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor = SAL_MAX_UINT16, sal_uInt16 nExpMinor = SAL_MAX_UINT16 ); + bool dumpComCtlSize(); + bool dumpComCtlData( sal_uInt32& ornCommonPartSize ); + bool dumpComCtlCommon( sal_uInt32 nPartSize ); + bool dumpComCtlComplex(); - inline explicit OcxFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {} +protected: + sal_uInt32 mnDataId5; + sal_uInt32 mnDataId6; + sal_uInt16 mnVersion; + bool mbCommonPart; + bool mbComplexPart; }; -typedef ::std::vector< OcxFormSiteInfo > OcxFormSiteInfoVector; +// ============================================================================ -// ---------------------------------------------------------------------------- +class ComCtlScrollBarObject : public ComCtlObjectBase +{ +public: + explicit ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); -struct OcxFormSharedData +protected: + virtual void implDumpProperties(); +}; + +// ============================================================================ + +class ComCtlProgressBarObject : public ComCtlObjectBase { - OUStringVector maClassInfoProgIds; - OcxFormSiteInfoVector maSiteInfos; +public: + explicit ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); +}; + +// ============================================================================ + +class ComCtlSliderObject : public ComCtlObjectBase +{ +public: + explicit ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); }; // ============================================================================ + +class ComCtlUpDownObject : public ComCtlObjectBase +{ +public: + explicit ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); +}; + // ============================================================================ -class OcxPropertyObjectBase : public InputObjectBase +class ComCtlImageListObject : public ComCtlObjectBase { +public: + explicit ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + protected: - inline explicit OcxPropertyObjectBase() {} + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + virtual void implDumpCommonTrailing(); +}; + +// ============================================================================ + +class ComCtlTabStripObject : public ComCtlObjectBase +{ +public: + explicit ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); +}; + +// ============================================================================ + +class ComCtlTreeViewObject : public ComCtlObjectBase +{ +public: + explicit ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + +private: + sal_uInt32 mnStringFlags; +}; + +// ============================================================================ + +class ComCtlStatusBarObject : public ComCtlObjectBase +{ +public: + explicit ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ); + +protected: + virtual void implDumpProperties(); + virtual void implDumpCommonExtra( sal_Int64 nEndPos ); + virtual void implDumpCommonTrailing(); +}; - using InputObjectBase::construct; +// ============================================================================ +// ============================================================================ + +class AxPropertyObjectBase : public OleInputObjectBase +{ +protected: + inline explicit AxPropertyObjectBase() {} + + using OleInputObjectBase::construct; void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, @@ -213,19 +357,19 @@ protected: inline bool dumpBoolProperty() { return startNextProperty(); } inline sal_Int32 dumpHmmProperty() { return dumpDecProperty< sal_Int32 >( 0, "CONV-HMM-TO-CM" ); } - inline sal_uInt8 dumpMousePtrProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OCX-MOUSEPTR" ); } + inline sal_uInt8 dumpMousePtrProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OLE-MOUSEPTR" ); } template< typename Type > - inline Type dumpBorderStyleProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "OCX-BORDERSTYLE" ); } + inline Type dumpBorderStyleProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "AX-BORDERSTYLE" ); } template< typename Type > - inline Type dumpSpecialEffectProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "OCX-SPECIALEFFECT" ); } - inline sal_uInt32 dumpEnabledProperty() { return dumpDecProperty< sal_uInt32 >( 1, "OCX-ENABLED" ); } - inline sal_Int32 dumpOrientationProperty() { return dumpDecProperty< sal_Int32 >( -1, "OCX-ORIENTATION" ); } - inline sal_Int32 dumpDelayProperty() { return dumpDecProperty< sal_Int32 >( 50, "OCX-CONV-MS" ); } - inline sal_uInt32 dumpImagePosProperty() { return dumpHexProperty< sal_uInt32 >( 0x00070001, "OCX-IMAGEPOS" ); } - inline sal_uInt8 dumpImageSizeModeProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OCX-IMAGESIZEMODE" ); } - inline sal_uInt8 dumpImageAlignProperty() { return dumpDecProperty< sal_uInt8 >( 2, "OCX-IMAGEALIGN" ); } - - sal_uInt32 dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList = "OCX-FLAGS" ); + inline Type dumpSpecialEffectProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "AX-SPECIALEFFECT" ); } + inline sal_uInt32 dumpEnabledProperty() { return dumpDecProperty< sal_uInt32 >( 1, "AX-ENABLED" ); } + inline sal_Int32 dumpOrientationProperty() { return dumpDecProperty< sal_Int32 >( -1, "AX-ORIENTATION" ); } + inline sal_Int32 dumpDelayProperty() { return dumpDecProperty< sal_Int32 >( 50, "AX-CONV-MS" ); } + inline sal_uInt32 dumpImagePosProperty() { return dumpHexProperty< sal_uInt32 >( 0x00070001, "AX-IMAGEPOS" ); } + inline sal_uInt8 dumpImageSizeModeProperty() { return dumpDecProperty< sal_uInt8 >( 0, "AX-IMAGESIZEMODE" ); } + inline sal_uInt8 dumpImageAlignProperty() { return dumpDecProperty< sal_uInt8 >( 2, "AX-IMAGEALIGN" ); } + + sal_uInt32 dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList = "AX-FLAGS" ); sal_uInt32 dumpColorProperty( sal_uInt32 nDefault ); sal_Unicode dumpUnicodeProperty(); void dumpUnknownProperty(); @@ -241,7 +385,7 @@ protected: void dumpToPosition( sal_Int64 nPos ); private: - void constructOcxPropObj( const String& rPropNameList, bool b64BitPropFlags ); + void constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags ); void dumpVersion(); ::rtl::OUString dumpString( const String& rName, sal_uInt32 nSize, bool bArray ); @@ -285,13 +429,13 @@ private: // ---------------------------------------------------------------------------- template< typename Type > -void OcxPropertyObjectBase::alignInput() +void AxPropertyObjectBase::alignInput() { - in().skip( (sizeof( Type ) - ((in().tell() - mnPropertiesStart) % sizeof( Type ))) % sizeof( Type ) ); + mxStrm->skip( (sizeof( Type ) - ((mxStrm->tell() - mnPropertiesStart) % sizeof( Type ))) % sizeof( Type ) ); } template< typename Type > -Type OcxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp ) +Type AxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp ) { if( startNextProperty() ) { @@ -302,7 +446,7 @@ Type OcxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrappe } template< typename Type > -Type OcxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp ) +Type AxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp ) { if( startNextProperty() ) { @@ -314,10 +458,10 @@ Type OcxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrappe // ============================================================================ -class OcxCFontNewObject : public OcxPropertyObjectBase +class AxCFontNewObject : public AxPropertyObjectBase { public: - explicit OcxCFontNewObject( const InputObjectBase& rParent ); + explicit AxCFontNewObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -325,10 +469,10 @@ protected: // ============================================================================ -class OcxColumnInfoObject : public OcxPropertyObjectBase +class AxColumnInfoObject : public AxPropertyObjectBase { public: - explicit OcxColumnInfoObject( const InputObjectBase& rParent ); + explicit AxColumnInfoObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -336,10 +480,10 @@ protected: // ============================================================================ -class OcxCommandButtonObject : public OcxPropertyObjectBase +class AxCommandButtonObject : public AxPropertyObjectBase { public: - explicit OcxCommandButtonObject( const InputObjectBase& rParent ); + explicit AxCommandButtonObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -348,10 +492,10 @@ protected: // ============================================================================ -class OcxMorphControlObject : public OcxPropertyObjectBase +class AxMorphControlObject : public AxPropertyObjectBase { public: - explicit OcxMorphControlObject( const InputObjectBase& rParent ); + explicit AxMorphControlObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -367,10 +511,10 @@ private: // ============================================================================ -class OcxLabelObject : public OcxPropertyObjectBase +class AxLabelObject : public AxPropertyObjectBase { public: - explicit OcxLabelObject( const InputObjectBase& rParent ); + explicit AxLabelObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -379,10 +523,10 @@ protected: // ============================================================================ -class OcxImageObject : public OcxPropertyObjectBase +class AxImageObject : public AxPropertyObjectBase { public: - explicit OcxImageObject( const InputObjectBase& rParent ); + explicit AxImageObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -390,10 +534,10 @@ protected: // ============================================================================ -class OcxScrollBarObject : public OcxPropertyObjectBase +class AxScrollBarObject : public AxPropertyObjectBase { public: - explicit OcxScrollBarObject( const InputObjectBase& rParent ); + explicit AxScrollBarObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -401,10 +545,10 @@ protected: // ============================================================================ -class OcxSpinButtonObject : public OcxPropertyObjectBase +class AxSpinButtonObject : public AxPropertyObjectBase { public: - explicit OcxSpinButtonObject( const InputObjectBase& rParent ); + explicit AxSpinButtonObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -412,10 +556,10 @@ protected: // ============================================================================ -class OcxTabStripObject : public OcxPropertyObjectBase +class AxTabStripObject : public AxPropertyObjectBase { public: - explicit OcxTabStripObject( const InputObjectBase& rParent ); + explicit AxTabStripObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); @@ -425,182 +569,189 @@ private: sal_Int32 mnTabFlagCount; }; +// ============================================================================ // ============================================================================ -class OcxControlObject : public InputObjectBase +class FormControlStreamObject : public OleInputObjectBase { public: - explicit OcxControlObject( - const InputObjectBase& rParent, - const ::rtl::OUString& rProgId, - sal_Int64 nLength ); + explicit FormControlStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + const ::rtl::OUString* pProgId = 0 ); + explicit FormControlStreamObject( + const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString* pProgId = 0 ); protected: virtual void implDump(); +private: + void constructFormCtrlStrmObj( const ::rtl::OUString* pProgId ); + private: ::rtl::OUString maProgId; - sal_Int64 mnLength; + bool mbReadGuid; }; +// ============================================================================ // ============================================================================ -class OcxGuidControlObject : public InputObjectBase +struct VbaFormSiteInfo { -public: - explicit OcxGuidControlObject( - const InputObjectBase& rParent, - sal_Int64 nLength ); - explicit OcxGuidControlObject( - const OutputObjectBase& rParent, - const BinaryInputStreamRef& rxStrm ); - explicit OcxGuidControlObject( - const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, - const ::rtl::OUString& rSysFileName ); + ::rtl::OUString maProgId; + sal_Int32 mnId; + sal_uInt32 mnLength; + bool mbInStream; -protected: - virtual void implDump(); + inline explicit VbaFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {} +}; -private: - sal_Int64 mnLength; +typedef ::std::vector< VbaFormSiteInfo > VbaFormSiteInfoVector; + +// ============================================================================ + +struct VbaFormSharedData +{ + OUStringVector maClassInfoProgIds; + VbaFormSiteInfoVector maSiteInfos; }; // ============================================================================ -class OcxControlsStreamObject : public InputObjectBase +class VbaFormClassInfoObject : public AxPropertyObjectBase { public: - explicit OcxControlsStreamObject( - const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, - const ::rtl::OUString& rSysFileName, - OcxFormSharedData& rFormData ); + explicit VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ); protected: - virtual void implDump(); + virtual void implDumpShortProperties(); private: - OcxFormSharedData& mrFormData; + VbaFormSharedData& mrFormData; }; -// ============================================================================ // ============================================================================ -class OcxPageObject : public OcxPropertyObjectBase +class VbaFormSiteObject : public AxPropertyObjectBase { public: - explicit OcxPageObject( const InputObjectBase& rParent ); + explicit VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ); protected: virtual void implDumpShortProperties(); + +private: + VbaFormSharedData& mrFormData; }; // ============================================================================ -class OcxMultiPageObject : public OcxPropertyObjectBase +class VbaFormDesignExtObject : public AxPropertyObjectBase { public: - explicit OcxMultiPageObject( const InputObjectBase& rParent ); + explicit VbaFormDesignExtObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); - virtual void implDumpExtended(); - -private: - sal_Int32 mnPageCount; }; // ============================================================================ -class OcxMultiPageStreamObject : public InputObjectBase +class VbaFStreamObject : public AxPropertyObjectBase { public: - explicit OcxMultiPageStreamObject( + explicit VbaFStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName, - OcxFormSharedData& rFormData ); + VbaFormSharedData& rFormData ); protected: - virtual void implDump(); + virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + +private: + void dumpClassInfos(); + void dumpFormSites( sal_uInt32 nCount ); + void dumpSiteData(); + void dumpDesignExtender(); private: - OcxFormSharedData& mrFormData; + VbaFormSharedData& mrFormData; + sal_uInt32 mnFlags; }; -// ============================================================================ // ============================================================================ -class OcxFormClassInfoObject : public OcxPropertyObjectBase +class VbaOStreamObject : public OleInputObjectBase { public: - explicit OcxFormClassInfoObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ); + explicit VbaOStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + VbaFormSharedData& rFormData ); protected: - virtual void implDumpShortProperties(); + virtual void implDump(); private: - OcxFormSharedData& mrFormData; + VbaFormSharedData& mrFormData; }; // ============================================================================ -class OcxFormSiteObject : public OcxPropertyObjectBase +class VbaPageObject : public AxPropertyObjectBase { public: - explicit OcxFormSiteObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ); + explicit VbaPageObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); - -private: - OcxFormSharedData& mrFormData; }; // ============================================================================ -class OcxFormDesignExtObject : public OcxPropertyObjectBase +class VbaMultiPageObject : public AxPropertyObjectBase { public: - explicit OcxFormDesignExtObject( const InputObjectBase& rParent ); + explicit VbaMultiPageObject( const InputObjectBase& rParent ); protected: virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + +private: + sal_Int32 mnPageCount; }; // ============================================================================ -class OcxFormObject : public OcxPropertyObjectBase +class VbaXStreamObject : public InputObjectBase { public: - explicit OcxFormObject( + explicit VbaXStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName, - OcxFormSharedData& rFormData ); + VbaFormSharedData& rFormData ); protected: - virtual void implDumpShortProperties(); - virtual void implDumpExtended(); - -private: - void dumpClassInfos(); - void dumpFormSites( sal_uInt32 nCount ); - void dumpSiteData(); - void dumpDesignExtender(); + virtual void implDump(); private: - OcxFormSharedData& mrFormData; - sal_uInt32 mnFlags; + VbaFormSharedData& mrFormData; }; // ============================================================================ -class OcxFormStorageObject : public OleStorageObject +class VbaContainerStorageObject : public OleStorageObject { public: - explicit OcxFormStorageObject( + explicit VbaContainerStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const ::rtl::OUString& rSysPath ); @@ -621,7 +772,7 @@ private: bool isFormStorage( const ::rtl::OUString& rStrgPath ) const; private: - OcxFormSharedData maFormData; + VbaFormSharedData maFormData; }; // ============================================================================ @@ -713,7 +864,7 @@ private: // ============================================================================ -class VbaFormStorageObject : public OcxFormStorageObject +class VbaFormStorageObject : public VbaContainerStorageObject { public: explicit VbaFormStorageObject( @@ -759,6 +910,23 @@ private: // ============================================================================ // ============================================================================ +class ActiveXStorageObject : public VbaContainerStorageObject +{ +public: + explicit ActiveXStorageObject( + const ObjectBase& rParent, + const StorageRef& rxStrg, + const ::rtl::OUString& rSysPath ); + +protected: + virtual void implDumpBaseStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); +}; + +// ============================================================================ +// ============================================================================ + } // namespace dump } // namespace oox diff --git a/oox/inc/oox/dump/xlsbdumper.hxx b/oox/inc/oox/dump/xlsbdumper.hxx index 95723f6b8d4e..345202f67a4a 100644 --- a/oox/inc/oox/dump/xlsbdumper.hxx +++ b/oox/inc/oox/dump/xlsbdumper.hxx @@ -98,7 +98,7 @@ private: private: typedef ::boost::shared_ptr< RecordInputStream > RecordInputStreamRef; - RecordInputStreamRef mxStrm; + RecordInputStreamRef mxBiffStrm; NameListRef mxErrCodes; }; diff --git a/oox/inc/oox/helper/binaryinputstream.hxx b/oox/inc/oox/helper/binaryinputstream.hxx index 19933ca03c04..8f58e2de4d9e 100644 --- a/oox/inc/oox/helper/binaryinputstream.hxx +++ b/oox/inc/oox/helper/binaryinputstream.hxx @@ -34,6 +34,8 @@ namespace oox { +class BinaryOutputStream; + // ============================================================================ /** Interface for binary input stream classes. @@ -108,6 +110,8 @@ public: False = NUL characters are replaced by question marks (default). */ ::rtl::OUString readUnicodeArray( sal_Int32 nChars, bool bAllowNulChars = false ); + /** Copies nBytes bytes from the current position to the passed output stream. */ + void copyToStream( BinaryOutputStream& rOutStrm, sal_Int64 nBytes = SAL_MAX_INT64 ); private: /** Used by the readValue() template functions to read built-in types. @@ -216,6 +220,71 @@ typedef ::boost::shared_ptr< SequenceInputStream > SequenceInputStreamRef; // ============================================================================ +/** Wraps a BinaryInputStream and provides access to a specific part of the + stream data. + + @descr + Provides access to the stream data block starting at the current + position of the stream, and with a specific length. If the wrapped + stream is seekable, this wrapper will treat the position the wrapped + has at construction time as position "0" (therefore the class name). + */ +class RelativeInputStream : public BinaryInputStream +{ +public: + /** Constructs the wrapper object for the passed stream. + + @attention + The passed input stream MUST live at least as long as this stream + wrapper. The stream MUST NOT be changed from outside as long as + this stream wrapper is used to read from it. + + @param nLength + If specified, restricts the amount of data that can be read from + the passed input stream. + */ + explicit RelativeInputStream( + BinaryInputStream& rInStrm, + sal_Int64 nLength = SAL_MAX_INT64 ); + + /** Returns whether the wrapped stream is seekable. */ + virtual bool isSeekable() const; + /** Returns the size of the data block in the wrapped stream offered by + this wrapper. */ + virtual sal_Int64 getLength() const; + /** Returns the current relative stream position. */ + virtual sal_Int64 tell() const; + /** Seeks the stream to the passed relative position, if the wrapped stream + is seekable. */ + virtual void seek( sal_Int64 nPos ); + + /** Reads nBytes bytes to the passed sequence. Does not read out of the + data block whose size has been specified on construction. + @return Number of bytes really read. */ + virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ); + /** Reads nBytes bytes to the (existing) buffer opMem. Does not read out of + the data block whose size has been specified on construction. + @return Number of bytes really read. */ + virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes ); + /** Seeks the stream forward by the passed number of bytes. This works for + non-seekable streams too. Does not seek out of the data block. */ + virtual void skip( sal_Int32 nBytes ); + + /** Stream operator for integral and floating-point types. */ + template< typename Type > + inline RelativeInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } + +private: + BinaryInputStream& mrInStrm; + sal_Int64 mnStartPos; + sal_Int64 mnRelPos; + sal_Int64 mnLength; +}; + +typedef ::boost::shared_ptr< RelativeInputStream > RelativeInputStreamRef; + +// ============================================================================ + } // namespace oox #endif diff --git a/oox/inc/oox/helper/binaryoutputstream.hxx b/oox/inc/oox/helper/binaryoutputstream.hxx index b229dbd18901..d2f0f8b36ffa 100644 --- a/oox/inc/oox/helper/binaryoutputstream.hxx +++ b/oox/inc/oox/helper/binaryoutputstream.hxx @@ -34,8 +34,6 @@ namespace oox { -class BinaryInputStream; - // ============================================================================ /** Interface for binary output stream classes. @@ -50,9 +48,6 @@ public: /** Derived classes implement writing from the (existing) buffer pMem. */ virtual void writeMemory( const void* pMem, sal_Int32 nBytes ) = 0; - /** Copies nBytes bytes from the current position of the passed input stream. */ - void copyStream( BinaryInputStream& rInStrm, sal_Int64 nBytes = SAL_MAX_INT64 ); - /** Writes a value to the stream and converts it to platform byte order. Supported types: SAL integers (8 to 64 bit), float, double. */ template< typename Type > diff --git a/oox/inc/oox/helper/binarystreambase.hxx b/oox/inc/oox/helper/binarystreambase.hxx index 18d868660faa..5cebdc681e8d 100644 --- a/oox/inc/oox/helper/binarystreambase.hxx +++ b/oox/inc/oox/helper/binarystreambase.hxx @@ -38,7 +38,8 @@ typedef ::com::sun::star::uno::Sequence< sal_Int8 > StreamDataSequence; // ============================================================================ -/** Base interface for seekable binary stream classes. */ +/** Base interface for binary stream classes. Implemenetations may or may not + support seeking the stream. */ class BinaryStreamBase { public: @@ -46,11 +47,14 @@ public: /** Derived classes return whether the stream is seekable. Default: false. */ virtual bool isSeekable() const; - /** Derived classes returns the size of the stream, if seekable, otherwise/default: -1. */ + /** Derived classes return the size of the stream, if possible, + otherwise/default: -1. May return something for unseekable streams. */ virtual sal_Int64 getLength() const; - /** Derived classes return the current stream position, if seekable, otherwise/default: -1. */ + /** Derived classes return the current stream position, if possible, + otherwise/default: -1. May return something for unseekable streams. */ virtual sal_Int64 tell() const; - /** Derived classes implement seeking the stream to the passed position, if seekable. */ + /** Derived classes implement seeking the stream to the passed position, if + the stream is seekable. */ virtual void seek( sal_Int64 nPos ); /** Returns true, if the stream position is invalid (EOF). This flag turns @@ -63,6 +67,9 @@ public: inline void seekToStart() { seek( 0 ); } /** Seeks the stream to the end, if stream is seekable. */ inline void seekToEnd() { seek( getLength() ); } + /** Seeks the stream forward to a position that is a multiple of the passed + block size, relative to the passed stream position, if stream is seekable. */ + void align( sal_Int32 nBlockSize, sal_Int64 nAnchorPos = 0 ); protected: inline explicit BinaryStreamBase() : mbEof( false ) {} diff --git a/oox/inc/oox/helper/containerhelper.hxx b/oox/inc/oox/helper/containerhelper.hxx index a077c667ae4c..f4f3717eac3f 100644 --- a/oox/inc/oox/helper/containerhelper.hxx +++ b/oox/inc/oox/helper/containerhelper.hxx @@ -84,34 +84,86 @@ public: Does *not* check whether the last element is an empty reference. */ inline sal_Int32 getLastIndex() const { return static_cast< sal_Int32 >( this->size() ) - 1; } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed functor for every contained object, automatically + skips all elements that are empty references. */ template< typename FunctorType > - inline void forEach( const FunctorType& rFunctor ) const + inline void forEach( FunctorType aFunctor ) const { - ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( rFunctor ) ); + ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( aFunctor ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType > inline void forEachMem( FuncType pFunc ) const { forEach( ::boost::bind( pFunc, _1 ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType > inline void forEachMem( FuncType pFunc, ParamType aParam ) const { forEach( ::boost::bind( pFunc, _1, aParam ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType1, typename ParamType2 > inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const { forEach( ::boost::bind( pFunc, _1, aParam1, aParam2 ) ); } + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) ); + } + + /** Calls the passed functor for every contained object. Passes the index as + first argument and the object reference as second argument to rFunctor. */ + template< typename FunctorType > + inline void forEachWithIndex( const FunctorType& rFunctor ) const + { + ::std::for_each( this->begin(), this->end(), ForEachFunctorWithIndex< FunctorType >( rFunctor ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index to the member function. */ + template< typename FuncType > + inline void forEachMemWithIndex( FuncType pFunc ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1 ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index as first argument to the member function. */ + template< typename FuncType, typename ParamType > + inline void forEachMemWithIndex( FuncType pFunc, ParamType aParam ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index as first argument to the member function. */ + template< typename FuncType, typename ParamType1, typename ParamType2 > + inline void forEachMemWithIndex( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam1, aParam2 ) ); + } + + /** Calls the passed member function of ObjType on every contained object. + Passes the vector index as first argument to the member function. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMemWithIndex( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam1, aParam2, aParam3 ) ); + } + /** Searches for an element by using the passed functor that takes a constant reference of the object type (const ObjType&). */ template< typename FunctorType > @@ -125,17 +177,26 @@ private: template< typename FunctorType > struct ForEachFunctor { - const FunctorType& mrFunctor; - inline explicit ForEachFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rxValue ) const { if( rxValue.get() ) mrFunctor( *rxValue ); } + FunctorType maFunctor; + inline explicit ForEachFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline void operator()( const value_type& rxValue ) { if( rxValue.get() ) maFunctor( *rxValue ); } + }; + + template< typename FunctorType > + struct ForEachFunctorWithIndex + { + FunctorType maFunctor; + sal_Int32 mnIndex; + inline explicit ForEachFunctorWithIndex( const FunctorType& rFunctor ) : maFunctor( rFunctor ), mnIndex( 0 ) {} + inline void operator()( const value_type& rxValue ) { if( rxValue.get() ) maFunctor( mnIndex, *rxValue ); ++mnIndex; } }; template< typename FunctorType > struct FindFunctor { - const FunctorType& mrFunctor; - inline explicit FindFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline bool operator()( const value_type& rxValue ) const { return rxValue.get() && mrFunctor( *rxValue ); } + FunctorType maFunctor; + inline explicit FindFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline bool operator()( const value_type& rxValue ) { return rxValue.get() && maFunctor( *rxValue ); } }; inline const value_type* getRef( sal_Int32 nIndex ) const @@ -173,41 +234,53 @@ public: return pxRef && pxRef->get(); } - /** Returns a reference to the object accossiated to the passed key, or 0 on error. */ + /** Returns a reference to the object accossiated to the passed key, or an + empty reference on error. */ inline mapped_type get( key_type nKey ) const { if( const mapped_type* pxRef = getRef( nKey ) ) return *pxRef; return mapped_type(); } - /** Calls the passed functor for every contained object. */ + /** Calls the passed functor for every contained object, automatically + skips all elements that are empty references. */ template< typename FunctorType > inline void forEach( const FunctorType& rFunctor ) const { ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( rFunctor ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType > inline void forEachMem( FuncType pFunc ) const { forEach( ::boost::bind( pFunc, _1 ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType > inline void forEachMem( FuncType pFunc, ParamType aParam ) const { forEach( ::boost::bind( pFunc, _1, aParam ) ); } - /** Calls the passed member function of ObjType on every contained object. */ + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ template< typename FuncType, typename ParamType1, typename ParamType2 > inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const { forEach( ::boost::bind( pFunc, _1, aParam1, aParam2 ) ); } + /** Calls the passed member function of ObjType on every contained object, + automatically skips all elements that are empty references. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) ); + } /** Calls the passed functor for every contained object. Passes the key as first argument and the object reference as second argument to rFunctor. */ template< typename FunctorType > @@ -240,21 +313,29 @@ public: forEachWithKey( ::boost::bind( pFunc, _2, _1, aParam1, aParam2 ) ); } + /** Calls the passed member function of ObjType on every contained object. + Passes the object key as first argument to the member function. */ + template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 > + inline void forEachMemWithKey( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const + { + forEachWithKey( ::boost::bind( pFunc, _2, _1, aParam1, aParam2, aParam3 ) ); + } + private: template< typename FunctorType > struct ForEachFunctor { - const FunctorType& mrFunctor; - inline explicit ForEachFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rValue ) const { if( rValue.second.get() ) mrFunctor( *rValue.second ); } + FunctorType maFunctor; + inline explicit ForEachFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline void operator()( const value_type& rValue ) { if( rValue.second.get() ) maFunctor( *rValue.second ); } }; template< typename FunctorType > struct ForEachFunctorWithKey { - const FunctorType& mrFunctor; - inline explicit ForEachFunctorWithKey( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rValue ) const { if( rValue.second.get() ) mrFunctor( rValue.first, *rValue.second ); } + FunctorType maFunctor; + inline explicit ForEachFunctorWithKey( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {} + inline void operator()( const value_type& rValue ) { if( rValue.second.get() ) maFunctor( rValue.first, *rValue.second ); } }; inline const mapped_type* getRef( key_type nKey ) const @@ -453,7 +534,7 @@ public: /** Returns the reference to an existing element of the passed vector, or the passed default value, if the passed index is out of bounds. */ template< typename Type > - static Type& getVectorElement( const ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ); + static Type& getVectorElement( ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ); /** Returns the pointer to an existing element of the passed map, or a null pointer, if an element with the passed key does not exist. */ @@ -522,7 +603,7 @@ const Type& ContainerHelper::getVectorElement( const ::std::vector< Type >& rVec } template< typename Type > -Type& ContainerHelper::getVectorElement( const ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ) +Type& ContainerHelper::getVectorElement( ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault ) { return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? rVector[ static_cast< size_t >( nIndex ) ] : rDefault; } diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx index d6e01d0fff6b..dc9dddfea7e8 100644 --- a/oox/inc/oox/helper/graphichelper.hxx +++ b/oox/inc/oox/helper/graphichelper.hxx @@ -29,24 +29,30 @@ #define OOX_HELPER_GRAPHICHELPER_HXX #include +#include #include +#include #include #include "oox/helper/binarystreambase.hxx" namespace com { namespace sun { namespace star { - namespace uno { class XComponentContext; } - namespace lang { class XMultiServiceFactory; } + namespace awt { struct Point; } + namespace awt { struct Size; } + namespace awt { class XUnitConversion; } namespace io { class XInputStream; } namespace graphic { class XGraphic; } namespace graphic { class XGraphicObject; } namespace graphic { class XGraphicProvider; } + namespace lang { class XMultiServiceFactory; } + namespace uno { class XComponentContext; } } } } namespace oox { // ============================================================================ -/** Provides helper functions for graphics and graphic objects handling. +/** Provides helper functions for colors, device measurement conversion, + graphics, and graphic objects handling. All createGraphicObject() and importGraphicObject() functions create persistent graphic objects internally and store them in an internal @@ -60,39 +66,83 @@ class GraphicHelper { public: explicit GraphicHelper( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory ); - ~GraphicHelper(); + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory ); + virtual ~GraphicHelper(); + + /** Returns a system color specified by the passed XML token identifier. */ + sal_Int32 getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb = API_RGB_TRANSPARENT ) const; + /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */ + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + /** Derived classes may implement to resolve a palette index to an RGB color. */ + virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; + + /** Returns information about the output device. */ + const ::com::sun::star::awt::DeviceInfo& getDeviceInfo() const; + + /** Converts the passed value from horizontal screen pixels to 1/100 mm. */ + sal_Int32 convertScreenPixelXToHmm( double fPixelX ) const; + /** Converts the passed value from vertical screen pixels to 1/100 mm. */ + sal_Int32 convertScreenPixelYToHmm( double fPixelY ) const; + /** Converts the passed point from screen pixels to 1/100 mm. */ + ::com::sun::star::awt::Point convertScreenPixelToHmm( const ::com::sun::star::awt::Point& rPixel ) const; + /** Converts the passed size from screen pixels to 1/100 mm. */ + ::com::sun::star::awt::Size convertScreenPixelToHmm( const ::com::sun::star::awt::Size& rPixel ) const; + + /** Converts the passed value from 1/100 mm to horizontal screen pixels. */ + double convertHmmToScreenPixelX( sal_Int32 nHmmX ) const; + /** Converts the passed value from 1/100 mm to vertical screen pixels. */ + double convertHmmToScreenPixelY( sal_Int32 nHmmY ) const; + /** Converts the passed point from 1/100 mm to screen pixels. */ + ::com::sun::star::awt::Point convertHmmToScreenPixel( const ::com::sun::star::awt::Point& rHmm ) const; + /** Converts the passed size from 1/100 mm to screen pixels. */ + ::com::sun::star::awt::Size convertHmmToScreenPixel( const ::com::sun::star::awt::Size& rHmm ) const; + + /** Converts the passed point from AppFont units to 1/100 mm. */ + ::com::sun::star::awt::Point convertAppFontToHmm( const ::com::sun::star::awt::Point& rAppFont ) const; + /** Converts the passed point from AppFont units to 1/100 mm. */ + ::com::sun::star::awt::Size convertAppFontToHmm( const ::com::sun::star::awt::Size& rAppFont ) const; + + /** Converts the passed point from 1/100 mm to AppFont units. */ + ::com::sun::star::awt::Point convertHmmToAppFont( const ::com::sun::star::awt::Point& rHmm ) const; + /** Converts the passed size from 1/100 mm to AppFont units. */ + ::com::sun::star::awt::Size convertHmmToAppFont( const ::com::sun::star::awt::Size& rHmm ) const; /** Imports a graphic from the passed input stream. */ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > importGraphic( - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ); + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) const; /** Imports a graphic from the passed binary memory block. */ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > - importGraphic( const StreamDataSequence& rGraphicData ); + importGraphic( const StreamDataSequence& rGraphicData ) const; /** Creates a persistent graphic object from the passed graphic. @return The URL of the created and internally cached graphic object. */ ::rtl::OUString createGraphicObject( - const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ); + const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ) const; /** Creates a persistent graphic object from the passed input stream. @return The URL of the created and internally cached graphic object. */ ::rtl::OUString importGraphicObject( - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ); + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) const; /** Creates a persistent graphic object from the passed binary memory block. @return The URL of the created and internally cached graphic object. */ - ::rtl::OUString importGraphicObject( const StreamDataSequence& rGraphicData ); + ::rtl::OUString importGraphicObject( const StreamDataSequence& rGraphicData ) const; private: + typedef ::std::map< sal_Int32, sal_Int32 > SystemPalette; typedef ::std::deque< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject > > GraphicObjectDeque; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxCompContext; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicProvider > mxGraphicProvider; - GraphicObjectDeque maGraphicObjects; - const ::rtl::OUString maGraphicObjScheme; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnitConversion > mxUnitConversion; + ::com::sun::star::awt::DeviceInfo maDeviceInfo; /// Current output device info. + SystemPalette maSystemPalette; /// Maps system colors (XML tokens) to RGB color values. + mutable GraphicObjectDeque maGraphicObjects; /// Caches all created graphic objects to keep them alive. + const ::rtl::OUString maGraphicObjScheme; /// The URL scheme name for graphic objects. + double mfPixelPerHmmX; /// Number of screen pixels per 1/100 mm in X direction. + double mfPixelPerHmmY; /// Number of screen pixels per 1/100 mm in Y direction. }; // ============================================================================ diff --git a/oox/inc/oox/helper/helper.hxx b/oox/inc/oox/helper/helper.hxx index 5884855bc50d..c68fe9ce83f8 100644 --- a/oox/inc/oox/helper/helper.hxx +++ b/oox/inc/oox/helper/helper.hxx @@ -69,7 +69,29 @@ namespace oox { #define OUSTRING_TO_CSTR( str ) \ ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ).getStr() -// ============================================================================ +// Common constants =========================================================== + +const sal_uInt8 WINDOWS_CHARSET_ANSI = 0; +const sal_uInt8 WINDOWS_CHARSET_DEFAULT = 1; +const sal_uInt8 WINDOWS_CHARSET_SYMBOL = 2; +const sal_uInt8 WINDOWS_CHARSET_APPLE_ROMAN = 77; +const sal_uInt8 WINDOWS_CHARSET_SHIFTJIS = 128; +const sal_uInt8 WINDOWS_CHARSET_HANGEUL = 129; +const sal_uInt8 WINDOWS_CHARSET_JOHAB = 130; +const sal_uInt8 WINDOWS_CHARSET_GB2312 = 134; +const sal_uInt8 WINDOWS_CHARSET_BIG5 = 136; +const sal_uInt8 WINDOWS_CHARSET_GREEK = 161; +const sal_uInt8 WINDOWS_CHARSET_TURKISH = 162; +const sal_uInt8 WINDOWS_CHARSET_VIETNAMESE = 163; +const sal_uInt8 WINDOWS_CHARSET_HEBREW = 177; +const sal_uInt8 WINDOWS_CHARSET_ARABIC = 178; +const sal_uInt8 WINDOWS_CHARSET_BALTIC = 186; +const sal_uInt8 WINDOWS_CHARSET_RUSSIAN = 204; +const sal_uInt8 WINDOWS_CHARSET_THAI = 222; +const sal_uInt8 WINDOWS_CHARSET_EASTERN = 238; +const sal_uInt8 WINDOWS_CHARSET_OEM = 255; + +// ---------------------------------------------------------------------------- const sal_Int32 API_RGB_TRANSPARENT = -1; /// Transparent color for API calls. const sal_Int32 API_RGB_BLACK = 0x00000; /// Black color for API calls. diff --git a/oox/inc/oox/helper/modelobjecthelper.hxx b/oox/inc/oox/helper/modelobjecthelper.hxx index cead2ad74fb1..a9ef27e8cb98 100644 --- a/oox/inc/oox/helper/modelobjecthelper.hxx +++ b/oox/inc/oox/helper/modelobjecthelper.hxx @@ -53,7 +53,7 @@ class ModelObjectHelper { public: explicit ModelObjectHelper( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory ); + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory ); /** Returns true, if the model contains a line marker with the passed name. */ bool hasLineMarker( const ::rtl::OUString& rMarkerName ) const; diff --git a/oox/inc/oox/helper/olestorage.hxx b/oox/inc/oox/helper/olestorage.hxx deleted file mode 100644 index a8174a167729..000000000000 --- a/oox/inc/oox/helper/olestorage.hxx +++ /dev/null @@ -1,103 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef OOX_HELPER_OLESTORAGE_HXX -#define OOX_HELPER_OLESTORAGE_HXX - -#include "oox/helper/storagebase.hxx" - -namespace com { namespace sun { namespace star { - namespace lang { class XMultiServiceFactory; } - namespace container { class XNameContainer; } - namespace container { class XNameAccess; } -} } } - -namespace oox { - -// ============================================================================ - -/** Implements stream access for binary OLE storages. */ -class OleStorage : public StorageBase -{ -public: - explicit OleStorage( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream, - bool bBaseStreamAccess ); - - explicit OleStorage( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxStream, - bool bBaseStreamAccess ); - - virtual ~OleStorage(); - -private: - explicit OleStorage( - const OleStorage& rParentStorage, - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxElementsAccess, - const ::rtl::OUString& rElementName ); - - /** Returns true, if the object represents a valid storage. */ - virtual bool implIsStorage() const; - - /** Returns the com.sun.star.embed.XStorage interface of the current storage. - - @attention - This function is not implemented for binary OLE storages. - */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > - implGetXStorage() const; - - /** Returns the names of all elements of this storage. */ - virtual void implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; - - /** Opens and returns the specified sub storage from the storage. */ - virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreate ); - - /** Opens and returns the specified input stream from the storage. */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > - implOpenInputStream( const ::rtl::OUString& rElementName ); - - /** Opens and returns the specified output stream from the storage. */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > - implOpenOutputStream( const ::rtl::OUString& rElementName ); - -private: - typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > XNameContainerRef; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > XNameAccessRef; - - XNameContainerRef mxStorage; /// Complete storage based on input or output stream. - XNameAccessRef mxElements; /// Access to elements of current sub storage. -}; - -// ============================================================================ - -} // namespace oox - -#endif - diff --git a/oox/inc/oox/helper/propertyset.hxx b/oox/inc/oox/helper/propertyset.hxx index bdb81c6c3e83..a1769374d959 100644 --- a/oox/inc/oox/helper/propertyset.hxx +++ b/oox/inc/oox/helper/propertyset.hxx @@ -92,6 +92,10 @@ public: template< typename Type > inline bool getProperty( Type& orValue, sal_Int32 nPropId ) const; + /** Gets the specified property from the property set. + @return the property value, or an empty Any, if the property is missing. */ + ::com::sun::star::uno::Any getAnyProperty( sal_Int32 nPropId ) const; + /** Gets the specified boolean property from the property set. @return true = property contains true; false = property contains false or error occured. */ bool getBoolProperty( sal_Int32 nPropId ) const; diff --git a/oox/inc/oox/helper/storagebase.hxx b/oox/inc/oox/helper/storagebase.hxx index b23032fe2ac0..5a179e73cf75 100644 --- a/oox/inc/oox/helper/storagebase.hxx +++ b/oox/inc/oox/helper/storagebase.hxx @@ -28,12 +28,8 @@ #ifndef OOX_HELPER_STORAGEBASE_HXX #define OOX_HELPER_STORAGEBASE_HXX -#include -#include -#include -#include -#include -#include +#include "oox/dllapi.h" +#include "oox/helper/containerhelper.hxx" namespace com { namespace sun { namespace star { namespace embed { class XStorage; } @@ -71,6 +67,13 @@ public: /** Returns true, if the object represents a valid storage. */ bool isStorage() const; + /** Returns true, if the object represents the root storage. */ + bool isRootStorage() const; + + /** Returns true, if the storage operates in read-only mode (based on an + input stream). */ + bool isReadOnly() const; + /** Returns the com.sun.star.embed.XStorage interface of the current storage. */ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getXStorage() const; @@ -81,7 +84,8 @@ public: /** Returns the full path of this storage. */ ::rtl::OUString getPath() const; - /** Fills the passed vector with the names of all elements of this storage. */ + /** Fills the passed vector with the names of all direct elements of this + storage. */ void getElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; /** Opens and returns the specified sub storage from the storage. @@ -89,10 +93,11 @@ public: @param rStorageName The name of the embedded storage. The name may contain slashes to open storages from embedded substorages. - @param bCreate - True = create missing sub storages (for export filters). + @param bCreateMissing + True = create missing sub storages (for export filters). Must be + false for storages based on input streams. */ - StorageRef openSubStorage( const ::rtl::OUString& rStorageName, bool bCreate ); + StorageRef openSubStorage( const ::rtl::OUString& rStorageName, bool bCreateMissing ); /** Opens and returns the specified input stream from the storage. @@ -116,13 +121,27 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > openOutputStream( const ::rtl::OUString& rStreamName ); - /** Commits the changes to the storage and all the substorages. (in case it is transacted object) + /** Copies the specified element from this storage to the passed + destination storage. + + @param rElementName + The name of the embedded storage or stream. The name may contain + slashes to specify an element in an embedded substorage. In this + case, the element will be copied to the same substorage in the + destination storage. */ - void commit(); + void copyToStorage( StorageBase& rDestStrg, const ::rtl::OUString& rElementName ); + + /** Copies all streams of this storage and of all substorages to the passed + destination. */ + void copyStorageToStorage( StorageBase& rDestStrg ); + + /** Commits the changes to the storage and all substorages. */ + void commit(); protected: /** Special constructor for sub storage objects. */ - explicit StorageBase( const StorageBase& rParentStorage, const ::rtl::OUString& rStorageName ); + explicit StorageBase( const StorageBase& rParentStorage, const ::rtl::OUString& rStorageName, bool bReadOnly ); private: StorageBase( const StorageBase& ); @@ -149,19 +168,24 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > implOpenOutputStream( const ::rtl::OUString& rElementName ) = 0; - StorageRef getSubStorage( const ::rtl::OUString& rElementName, bool bCreate ); + /** Commits the current storage. */ + virtual void implCommit() const = 0; + + /** Helper that opens and caches the specified direct substorage. */ + StorageRef getSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing ); private: - typedef ::std::map< ::rtl::OUString, StorageRef > SubStorageMap; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > XInputStreamRef; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > XStreamRef; + typedef RefMap< ::rtl::OUString, StorageBase > SubStorageMap; SubStorageMap maSubStorages; /// Map of direct sub storages. - XInputStreamRef mxInStream; /// Cached base input stream (to keep it alive). - XStreamRef mxOutStream; /// Cached base output stream (to keep it alive). + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + mxInStream; /// Cached base input stream (to keep it alive). + ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > + mxOutStream; /// Cached base output stream (to keep it alive). + ::rtl::OUString maParentPath; /// Full path of parent storage. ::rtl::OUString maStorageName; /// Name of this storage, if it is a substorage. - const StorageBase* mpParentStorage; /// Parent storage if this is a sub storage. bool mbBaseStreamAccess; /// True = access base streams with empty stream name. + bool mbReadOnly; /// True = storage opened read-only (based on input stream). }; // ============================================================================ @@ -169,4 +193,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/helper/textinputstream.hxx b/oox/inc/oox/helper/textinputstream.hxx new file mode 100755 index 000000000000..1e74825ee713 --- /dev/null +++ b/oox/inc/oox/helper/textinputstream.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_HELPER_RECORDINPUTSTREAM_HXX +#define OOX_HELPER_RECORDINPUTSTREAM_HXX + +#include "oox/helper/binaryinputstream.hxx" + +namespace oox { + +// ============================================================================ + +class TextInputStream +{ +public: + explicit TextInputStream( BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc ); + + /** Returns true, if the wrapped input stream is in EOF state. */ + bool isEof() const; + /** Reads a text line from the stream. */ + ::rtl::OUString readLine(); + +private: + BinaryInputStream& mrInStrm; + rtl_TextEncoding meTextEnc; + sal_Unicode mcLastEolChar; +}; + +// ============================================================================ + +} // namespace oox + +#endif + diff --git a/oox/inc/oox/helper/zipstorage.hxx b/oox/inc/oox/helper/zipstorage.hxx index b6eef63b47de..0c9a15c10077 100644 --- a/oox/inc/oox/helper/zipstorage.hxx +++ b/oox/inc/oox/helper/zipstorage.hxx @@ -69,7 +69,7 @@ private: virtual void implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; /** Opens and returns the specified sub storage from the storage. */ - virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreate ); + virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing ); /** Opens and returns the specified input stream from the storage. */ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > @@ -79,6 +79,9 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > implOpenOutputStream( const ::rtl::OUString& rElementName ); + /** Commits the current storage. */ + virtual void implCommit() const; + private: typedef ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > XStorageRef; @@ -90,4 +93,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/ole/axbinaryreader.hxx b/oox/inc/oox/ole/axbinaryreader.hxx index 3db0bae7cee4..d036e958a446 100644 --- a/oox/inc/oox/ole/axbinaryreader.hxx +++ b/oox/inc/oox/ole/axbinaryreader.hxx @@ -28,6 +28,7 @@ #ifndef OOX_OLE_AXBINARYREADER_HXX #define OOX_OLE_AXBINARYREADER_HXX +#include #include "oox/helper/binaryinputstream.hxx" #include "oox/helper/containerhelper.hxx" @@ -36,15 +37,24 @@ namespace ole { // ============================================================================ -/** A wrapper for an unseekable binary input stream. */ +/** A wrapper for a binary input stream that supports aligned read operations. + + The implementation does not support seeking back the wrapped stream. All + seeking operations (tell, seek, align) are performed relative to the + position of the wrapped stream at construction time of this wrapper. It is + possible to construct this wrapper with an unseekable input stream without + loosing any functionality. + */ class AxAlignedInputStream : public BinaryInputStream { public: explicit AxAlignedInputStream( BinaryInputStream& rInStrm ); - /** Return the current stream position (relative to position at construction time). */ + /** Return the current relative stream position (relative to position of + the wrapped stream at construction time). */ virtual sal_Int64 tell() const; - /** Seeks the stream to the passed position, if it is behind the current position. */ + /** Seeks the stream to the passed relative position, if it is behind the + current position. */ virtual void seek( sal_Int64 nPos ); /** Reads nBytes bytes to the passed sequence. @@ -56,7 +66,8 @@ public: /** Seeks the stream forward by the passed number of bytes. */ virtual void skip( sal_Int32 nBytes ); - /** Aligns the stream to a multiple of the passed size. */ + /** Aligns the stream to a multiple of the passed size (relative to the + position of the wrapped stream at construction time). */ void align( size_t nSize ); /** Aligns the stream according to the passed type and reads an atomar value. */ @@ -73,6 +84,50 @@ private: // ============================================================================ +/** A pair of integer values as a property. */ +typedef ::std::pair< sal_Int32, sal_Int32 > AxPairData; + +// ============================================================================ + +const sal_uInt32 AX_FONTDATA_BOLD = 0x00000001; +const sal_uInt32 AX_FONTDATA_ITALIC = 0x00000002; +const sal_uInt32 AX_FONTDATA_UNDERLINE = 0x00000004; +const sal_uInt32 AX_FONTDATA_STRIKEOUT = 0x00000008; +const sal_uInt32 AX_FONTDATA_DISABLED = 0x00002000; +const sal_uInt32 AX_FONTDATA_AUTOCOLOR = 0x40000000; + +const sal_Int32 AX_FONTDATA_LEFT = 1; +const sal_Int32 AX_FONTDATA_RIGHT = 2; +const sal_Int32 AX_FONTDATA_CENTER = 3; + +/** All entries of a font property. */ +struct AxFontData +{ + ::rtl::OUString maFontName; /// Name of the used font. + sal_uInt32 mnFontEffects; /// Font effect flags. + sal_Int32 mnFontHeight; /// Height of the font (not really twips, see code). + sal_Int32 mnFontCharSet; /// Windows character set of the font. + sal_Int32 mnHorAlign; /// Horizontal text alignment. + + explicit AxFontData(); + + /** Converts the internal representation of the font height to points. */ + sal_Int16 getHeightPoints() const; + /** Converts the passed font height from points to the internal representation. */ + void setHeightPoints( sal_Int16 nPoints ); + + /** Reads the font data settings from the passed input stream. */ + bool importBinaryModel( BinaryInputStream& rInStrm ); + /** Reads the font data settings from the passed input stream that contains + an OLE StdFont structure. */ + bool importStdFont( BinaryInputStream& rInStrm ); + /** Reads the font data settings from the passed input stream depending on + the GUID preceding the actual font data. */ + bool importGuidAndFont( BinaryInputStream& rInStrm ); +}; + +// ============================================================================ + /** Import helper to read simple and complex ActiveX form control properties from a binary input stream. */ class AxBinaryPropertyReader @@ -90,10 +145,16 @@ public: void readBoolProperty( bool& orbValue, bool bReverse = false ); /** Reads the next pair property from the stream, if the respective flag in the property mask is set. */ - void readPairProperty( sal_Int32& ornValue1, sal_Int32& ornValue2 ); + void readPairProperty( AxPairData& orPairData ); /** Reads the next string property from the stream, if the respective flag in the property mask is set. */ void readStringProperty( ::rtl::OUString& orValue ); + /** Reads the next GUID property from the stream, if the respective flag + in the property mask is set. The GUID will be enclosed in braces. */ + void readGuidProperty( ::rtl::OUString& orGuid ); + /** Reads the next font property from the stream, if the respective flag in + the property mask is set. */ + void readFontProperty( AxFontData& orFontData ); /** Reads the next picture property from the stream, if the respective flag in the property mask is set. */ void readPictureProperty( StreamDataSequence& orPicData ); @@ -105,9 +166,18 @@ public: /** Skips the next boolean property value in the stream, if the respective flag in the property mask is set. */ inline void skipBoolProperty() { startNextProperty(); } + /** Skips the next pair property in the stream, if the respective flag in + the property mask is set. */ + void skipPairProperty() { readPairProperty( maDummyPairData ); } /** Skips the next string property in the stream, if the respective flag in the property mask is set. */ inline void skipStringProperty() { readStringProperty( maDummyString ); } + /** Skips the next GUID property in the stream, if the respective flag in + the property mask is set. */ + inline void skipGuidProperty() { readGuidProperty( maDummyString ); } + /** Skips the next font property in the stream, if the respective flag in + the property mask is set. */ + inline void skipFontProperty() { readFontProperty( maDummyFontData ); } /** Skips the next picture property in the stream, if the respective flag in the property mask is set. */ inline void skipPictureProperty() { readPictureProperty( maDummyPicData ); } @@ -133,11 +203,10 @@ private: /** Complex property for a 32-bit value pair, e.g. point or size. */ struct PairProperty : public ComplexProperty { - sal_Int32& mrnValue1; - sal_Int32& mrnValue2; + AxPairData& mrPairData; - inline explicit PairProperty( sal_Int32& rnValue1, sal_Int32& rnValue2 ) : - mrnValue1( rnValue1 ), mrnValue2( rnValue2 ) {} + inline explicit PairProperty( AxPairData& rPairData ) : + mrPairData( rPairData ) {} virtual bool readProperty( AxAlignedInputStream& rInStrm ); }; @@ -152,6 +221,26 @@ private: virtual bool readProperty( AxAlignedInputStream& rInStrm ); }; + /** Complex property for a GUID value. */ + struct GuidProperty : public ComplexProperty + { + ::rtl::OUString& mrGuid; + + inline explicit GuidProperty( ::rtl::OUString& rGuid ) : + mrGuid( rGuid ) {} + virtual bool readProperty( AxAlignedInputStream& rInStrm ); + }; + + /** Stream property for a font structure. */ + struct FontProperty : public ComplexProperty + { + AxFontData& mrFontData; + + inline explicit FontProperty( AxFontData& rFontData ) : + mrFontData( rFontData ) {} + virtual bool readProperty( AxAlignedInputStream& rInStrm ); + }; + /** Stream property for a picture or mouse icon. */ struct PictureProperty : public ComplexProperty { @@ -168,6 +257,8 @@ private: AxAlignedInputStream maInStrm; /// The input stream to read from. ComplexPropVector maLargeProps; /// Stores info for all used large properties. ComplexPropVector maStreamProps; /// Stores info for all used stream data properties. + AxPairData maDummyPairData; /// Dummy pair for unsupported properties. + AxFontData maDummyFontData; /// Dummy font for unsupported properties. StreamDataSequence maDummyPicData; /// Dummy picture for unsupported properties. ::rtl::OUString maDummyString; /// Dummy string for unsupported properties. sal_Int64 mnPropFlags; /// Flags specifying existing properties. diff --git a/oox/inc/oox/ole/axcontrol.hxx b/oox/inc/oox/ole/axcontrol.hxx index b5a5741d134d..7c533334cc49 100644 --- a/oox/inc/oox/ole/axcontrol.hxx +++ b/oox/inc/oox/ole/axcontrol.hxx @@ -28,82 +28,389 @@ #ifndef OOX_OLE_AXCONTROL_HXX #define OOX_OLE_AXCONTROL_HXX -#include +#include #include "oox/helper/binarystreambase.hxx" +#include "oox/ole/axbinaryreader.hxx" +#include "oox/ole/olehelper.hxx" namespace com { namespace sun { namespace star { namespace awt { class XControlModel; } + namespace container { class XIndexContainer; } + namespace drawing { class XDrawPage; } + namespace form { class XFormsSupplier; } + namespace lang { class XMultiServiceFactory; } } } } namespace oox { class BinaryInputStream; + class GraphicHelper; class PropertyMap; } namespace oox { namespace ole { -class AxControlHelper; +// ============================================================================ + +const sal_Char* const COMCTL_GUID_SCROLLBAR_60 = "{FE38753A-44A3-11D1-B5B7-0000C09000C4}"; +const sal_Char* const COMCTL_GUID_PROGRESSBAR_50 = "{0713E8D2-850A-101B-AFC0-4210102A8DA7}"; +const sal_Char* const COMCTL_GUID_PROGRESSBAR_60 = "{35053A22-8589-11D1-B16A-00C0F0283628}"; + +// ---------------------------------------------------------------------------- + +const sal_Char* const AX_GUID_COMMANDBUTTON = "{D7053240-CE69-11CD-A777-00DD01143C57}"; +const sal_Char* const AX_GUID_LABEL = "{978C9E23-D4B0-11CE-BF2D-00AA003F40D0}"; +const sal_Char* const AX_GUID_IMAGE = "{4C599241-6926-101B-9992-00000B65C6F9}"; +const sal_Char* const AX_GUID_TOGGLEBUTTON = "{8BD21D60-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_CHECKBOX = "{8BD21D40-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_OPTIONBUTTON = "{8BD21D50-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_TEXTBOX = "{8BD21D10-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_LISTBOX = "{8BD21D20-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_COMBOBOX = "{8BD21D30-EC42-11CE-9E0D-00AA006002F3}"; +const sal_Char* const AX_GUID_SPINBUTTON = "{79176FB0-B7F2-11CE-97EF-00AA006D2776}"; +const sal_Char* const AX_GUID_SCROLLBAR = "{DFD181E0-5E2F-11CE-A449-00AA004A803D}"; +const sal_Char* const AX_GUID_FRAME = "{6E182020-F460-11CE-9BCD-00AA00608E01}"; + +const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005; +const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006; +const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008; +const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F; +const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012; + +const sal_Int32 AX_BORDERSTYLE_NONE = 0; +const sal_Int32 AX_BORDERSTYLE_SINGLE = 1; + +const sal_Int32 AX_SPECIALEFFECT_FLAT = 0; +const sal_Int32 AX_SPECIALEFFECT_RAISED = 1; +const sal_Int32 AX_SPECIALEFFECT_SUNKEN = 2; +const sal_Int32 AX_SPECIALEFFECT_ETCHED = 3; +const sal_Int32 AX_SPECIALEFFECT_BUMPED = 6; + +const sal_Int32 AX_PICSIZE_CLIP = 0; +const sal_Int32 AX_PICSIZE_STRETCH = 1; +const sal_Int32 AX_PICSIZE_ZOOM = 3; + +const sal_Int32 AX_PICALIGN_TOPLEFT = 0; +const sal_Int32 AX_PICALIGN_TOPRIGHT = 1; +const sal_Int32 AX_PICALIGN_CENTER = 2; +const sal_Int32 AX_PICALIGN_BOTTOMLEFT = 3; +const sal_Int32 AX_PICALIGN_BOTTOMRIGHT = 4; + +// ---------------------------------------------------------------------------- + +/** Enumerates all UNO API control types supported by these filters. */ +enum ApiControlType +{ + API_CONTROL_BUTTON, + API_CONTROL_FIXEDTEXT, + API_CONTROL_IMAGE, + API_CONTROL_CHECKBOX, + API_CONTROL_RADIOBUTTON, + API_CONTROL_EDIT, + API_CONTROL_LISTBOX, + API_CONTROL_COMBOBOX, + API_CONTROL_SPINBUTTON, + API_CONTROL_SCROLLBAR, + API_CONTROL_PROGRESSBAR, + API_CONTROL_GROUPBOX, + API_CONTROL_DIALOG +}; + +// ============================================================================ + +/** Specifies how a form control supports transparent background. */ +enum ApiTransparencyMode +{ + API_TRANSPARENCY_NOTSUPPORTED, /// Control does not support transparency. + API_TRANSPARENCY_VOID, /// Transparency is enabled by missing fill color. + API_TRANSPARENCY_PAINTTRANSPARENT /// Transparency is enabled by the 'PaintTransparent' property. +}; + +/** Specifies how a form control supports the DefaultState property. */ +enum ApiDefaultStateMode +{ + API_DEFAULTSTATE_BOOLEAN, /// Control does not support tri-state, state is given as boolean. + API_DEFAULTSTATE_SHORT, /// Control does not support tri-state, state is given as short. + API_DEFAULTSTATE_TRISTATE /// Control supports tri-state, state is given as short. +}; + +// ---------------------------------------------------------------------------- + +/** A base class with useful helper functions for something that is able to + convert ActiveX and ComCtl form controls. + */ +class ControlConverter +{ +public: + explicit ControlConverter( + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + virtual ~ControlConverter(); + + // Generic conversion ----------------------------------------------------- + + /** Converts the passed position in 1/100 mm to UNO properties. */ + void convertPosition( + PropertyMap& rPropMap, + const AxPairData& rPos ) const; + + /** Converts the passed size in 1/100 mm to UNO properties. */ + void convertSize( + PropertyMap& rPropMap, + const AxPairData& rSize ) const; + + /** Converts the passed encoded OLE color to UNO properties. */ + void convertColor( + PropertyMap& rPropMap, + sal_Int32 nPropId, + sal_uInt32 nOleColor ) const; + + /** Converts the passed StdPic picture stream to UNO properties. */ + void convertPicture( + PropertyMap& rPropMap, + const StreamDataSequence& rPicData ) const; + + /** Converts the control orientation to UNO properties. */ + void convertOrientation( + PropertyMap& rPropMap, + bool bHorizontal ) const; + + /** Converts common scrollbar settings to UNO properties. */ + void convertScrollBar( + PropertyMap& rPropMap, + sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition, + sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const; + + // ActiveX (Forms 2.0) specific conversion -------------------------------- + + /** Converts the Forms 2.0 background formatting to UNO properties. */ + void convertAxBackground( + PropertyMap& rPropMap, + sal_uInt32 nBackColor, + sal_uInt32 nFlags, + ApiTransparencyMode eTranspMode ) const; + + /** Converts the Forms 2.0 border formatting to UNO properties. */ + void convertAxBorder( + PropertyMap& rPropMap, + sal_uInt32 nBorderColor, + sal_Int32 nBorderStyle, + sal_Int32 nSpecialEffect ) const; + + /** Converts the Forms 2.0 special effect to UNO properties. */ + void convertAxVisualEffect( + PropertyMap& rPropMap, + sal_Int32 nSpecialEffect ) const; + + /** Converts the passed picture stream and Forms 2.0 position to UNO + properties. */ + void convertAxPicture( + PropertyMap& rPropMap, + const StreamDataSequence& rPicData, + sal_uInt32 nPicPos ) const; + + /** Converts the passed picture stream and Forms 2.0 position to UNO + properties. */ + void convertAxPicture( + PropertyMap& rPropMap, + const StreamDataSequence& rPicData, + sal_Int32 nPicSizeMode, + sal_Int32 nPicAlign, + bool bPicTiling ) const; + + /** Converts the Forms 2.0 value for checked/unchecked/dontknow to UNO + properties. */ + void convertAxState( + PropertyMap& rPropMap, + const ::rtl::OUString& rValue, + sal_Int32 nMultiSelect, + ApiDefaultStateMode eDefStateMode, + bool bAwtModel ) const; + + /** Converts the Forms 2.0 control orientation to UNO properties. */ + void convertAxOrientation( + PropertyMap& rPropMap, + const AxPairData& rSize, + sal_Int32 nOrientation ) const; + +private: + const GraphicHelper& mrGraphicHelper; + bool mbDefaultColorBgr; +}; // ============================================================================ -/** Base class for all models of ActiveX form controls. */ -class AxControlModelBase +/** Base class for all models of form controls. */ +class ControlModelBase { public: - virtual ~AxControlModelBase(); + explicit ControlModelBase(); + virtual ~ControlModelBase(); + + /** Sets this control model to AWT model mode. */ + inline void setAwtModelMode() { mbAwtModel = true; } + /** Sets this control model to form component mode. */ + inline void setFormComponentMode() { mbAwtModel = false; } + + /** Returns the UNO service name used to construct the AWT control model, + or the control form component. */ + ::rtl::OUString getServiceName() const; /** Derived classes set specific OOXML properties at the model structure. */ virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); /** Derived classes set binary data (picture, mouse icon) at the model structure. */ virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); /** Derived classes import a form control model from the passed input stream. */ - virtual void importBinaryModel( BinaryInputStream& rInStrm ); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ) = 0; - /** Derived classes return the UNO service name used to construct the control component. */ - virtual ::rtl::OUString getServiceName() const = 0; + /** Derived classes return the UNO control type enum value. */ + virtual ApiControlType getControlType() const = 0; /** Derived classes convert all control properties. */ - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + + /** Converts the control size to UNO properties. */ + void convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const; protected: - explicit AxControlModelBase(); + AxPairData maSize; /// Size of the control in 1/100 mm. + bool mbAwtModel; /// True = AWT control model, false = form component. +}; + +typedef ::boost::shared_ptr< ControlModelBase > ControlModelRef; + +// ============================================================================ + +/** Base class for all models of ComCtl form controls. */ +class ComCtlModelBase : public ControlModelBase +{ +public: + explicit ComCtlModelBase( + sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6, sal_uInt16 nVersion, + bool bCommonPart, bool bComplexPart ); + + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +protected: + virtual void importControlData( BinaryInputStream& rInStrm ) = 0; + virtual void importCommonExtraData( BinaryInputStream& rInStrm ); + virtual void importCommonTrailingData( BinaryInputStream& rInStrm ); + +private: + /** Returns the data part identifier according to the model version. */ + sal_uInt32 getDataPartId() const; + + bool readPartHeader( BinaryInputStream& rInStrm, + sal_uInt32 nExpPartId, + sal_uInt16 nExpMajor = SAL_MAX_UINT16, + sal_uInt16 nExpMinor = SAL_MAX_UINT16 ); + + bool importSizePart( BinaryInputStream& rInStrm ); + bool importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize ); + bool importComplexPart( BinaryInputStream& rInStrm ); + +protected: + StdFontInfo maFontData; /// Font formatting. + StreamDataSequence maMouseIcon; /// Binary picture stream for mouse icon. + sal_uInt32 mnFlags; /// Common flags for ComCtl controls. + const sal_uInt16 mnVersion; /// Current version of the ComCtl control model. + +private: + sal_uInt32 mnDataPartId5; /// Identifier for version 5.0 control data. + sal_uInt32 mnDataPartId6; /// Identifier for version 6.0 control data. + bool mbCommonPart; /// True = the COMCTL_COMMONDATA part exists. + bool mbComplexPart; /// True = the COMCTL_COMPLEXDATA part exists. +}; + +// ============================================================================ + +/** Model for a ComCtl scroll bar. */ +class ComCtlScrollBarModel : public ComCtlModelBase +{ +public: + explicit ComCtlScrollBarModel( sal_uInt16 nVersion ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; + +protected: + virtual void importControlData( BinaryInputStream& rInStrm ); + +private: + sal_uInt32 mnScrollBarFlags; /// Special flags for scroll bar model. + sal_Int32 mnLargeChange; /// Increment step size (thumb). + sal_Int32 mnSmallChange; /// Increment step size (buttons). + sal_Int32 mnMin; /// Minimum of the value range. + sal_Int32 mnMax; /// Maximum of the value range. + sal_Int32 mnPosition; /// Value of the spin button. +}; + +// ============================================================================ + +/** Model for a ComCtl progress bar. */ +class ComCtlProgressBarModel : public ComCtlModelBase +{ +public: + explicit ComCtlProgressBarModel( sal_uInt16 nVersion ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; protected: - sal_Int32 mnWidth; - sal_Int32 mnHeight; + virtual void importControlData( BinaryInputStream& rInStrm ); + +private: + float mfMin; /// Minimum of the value range. + float mfMax; /// Maximum of the value range. + sal_uInt16 mnVertical; /// 0 = horizontal, 1 = vertical. + sal_uInt16 mnSmooth; /// 0 = progress blocks, 1 = pixel resolution. }; // ============================================================================ +/** Base class for all models of Form 2.0 form controls. */ +class AxControlModelBase : public ControlModelBase +{ +public: + explicit AxControlModelBase(); + + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); +}; + +// ============================================================================ + +/** Base class for Forms 2.0 controls supporting text formatting. */ class AxFontDataModel : public AxControlModelBase { public: - explicit AxFontDataModel(); + explicit AxFontDataModel( bool bSupportsAlign = true ); virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; -private: - ::rtl::OUString maFontName; /// Name of the used font. - sal_uInt32 mnFontEffects; /// Font effect flags. - sal_Int32 mnFontHeight; /// Height of the font (not really twips, see code). - sal_Int32 mnFontCharSet; /// Windows character set of the font. - sal_Int32 mnHorAlign; /// Horizontal text alignment. + /** Returns the font height in points. */ + inline sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); } + +protected: + AxFontData maFontData; /// The font settings. + bool mbSupportsAlign; /// True = UNO model supports Align property. }; // ============================================================================ +/** Model for a Forms 2.0 command button. */ class AxCommandButtonModel : public AxFontDataModel { public: explicit AxCommandButtonModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: StreamDataSequence maPictureData; /// Binary picture stream. @@ -117,15 +424,17 @@ private: // ============================================================================ +/** Model for a Forms 2.0 label. */ class AxLabelModel : public AxFontDataModel { public: explicit AxLabelModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: ::rtl::OUString maCaption; /// Visible caption of the button. @@ -139,16 +448,18 @@ private: // ============================================================================ +/** Model for a Forms 2.0 image. */ class AxImageModel : public AxControlModelBase { public: explicit AxImageModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: StreamDataSequence maPictureData; /// Binary picture stream. @@ -164,15 +475,16 @@ private: // ============================================================================ -class AxMorphDataModel : public AxFontDataModel +/** Base class for a Forms 2.0 morph data control. */ +class AxMorphDataModelBase : public AxFontDataModel { public: - explicit AxMorphDataModel(); + explicit AxMorphDataModelBase(); virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; protected: StreamDataSequence maPictureData; /// Binary picture stream. @@ -198,81 +510,92 @@ protected: // ============================================================================ -class AxToggleButtonModel : public AxMorphDataModel +/** Model for a Forms 2.0 toggle button. */ +class AxToggleButtonModel : public AxMorphDataModelBase { public: explicit AxToggleButtonModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxCheckBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 check box. */ +class AxCheckBoxModel : public AxMorphDataModelBase { public: explicit AxCheckBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxOptionButtonModel : public AxMorphDataModel +/** Model for a Forms 2.0 option button. */ +class AxOptionButtonModel : public AxMorphDataModelBase { public: explicit AxOptionButtonModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + /** Returns the group name used to goup several option buttons gogether. */ + inline const ::rtl::OUString& getGroupName() const { return maGroupName; } + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxTextBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 text box. */ +class AxTextBoxModel : public AxMorphDataModelBase { public: explicit AxTextBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxListBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 list box. */ +class AxListBoxModel : public AxMorphDataModelBase { public: explicit AxListBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ -class AxComboBoxModel : public AxMorphDataModel +/** Model for a Forms 2.0 combo box. */ +class AxComboBoxModel : public AxMorphDataModelBase { public: explicit AxComboBoxModel(); - virtual ::rtl::OUString getServiceName() const; - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; // ============================================================================ +/** Model for a Forms 2.0 spin button. */ class AxSpinButtonModel : public AxControlModelBase { public: explicit AxSpinButtonModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: sal_uInt32 mnArrowColor; /// Button arrow color. @@ -288,15 +611,17 @@ private: // ============================================================================ +/** Model for a Forms 2.0 scroll bar. */ class AxScrollBarModel : public AxControlModelBase { public: explicit AxScrollBarModel(); - virtual ::rtl::OUString getServiceName() const; virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); - virtual void importBinaryModel( BinaryInputStream& rInStrm ); - virtual void convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const; + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; private: sal_uInt32 mnArrowColor; /// Button arrow color. @@ -314,39 +639,130 @@ private: // ============================================================================ -/** Container for all ActiveX form control model implementations. */ -class AxControl +typedef ::std::vector< ::rtl::OUString > AxClassTable; + +/** Base class for ActiveX container controls. */ +class AxContainerModelBase : public AxFontDataModel { public: - explicit AxControl( const ::rtl::OUString& rName ); - ~AxControl(); + explicit AxContainerModelBase(); + + /** Allows to set single properties specified by XML token identifier. */ + virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + /** Reads the leading structure in the 'f' stream containing the model for + this control. */ + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + /** Reads the class table structure for embedded controls following the own + model from the 'f' stream. */ + bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable ); + +protected: + StreamDataSequence maPictureData; /// Binary picture stream. + ::rtl::OUString maCaption; /// Visible caption of the form. + AxPairData maLogicalSize; /// Logical form size (scroll area). + AxPairData maScrollPos; /// Scroll position. + sal_uInt32 mnBackColor; /// Fill color. + sal_uInt32 mnTextColor; /// Text color. + sal_uInt32 mnFlags; /// Various flags. + sal_uInt32 mnBorderColor; /// Flat border color. + sal_Int32 mnBorderStyle; /// Flat border style. + sal_Int32 mnScrollBars; /// Horizontal/vertical scroll bar. + sal_Int32 mnCycleType; /// Cycle in all forms or in this form. + sal_Int32 mnSpecialEffect; /// 3D border effect. + sal_Int32 mnPicAlign; /// Anchor position of the picture. + sal_Int32 mnPicSizeMode; /// Clip, stretch, zoom. + bool mbPicTiling; /// True = picture is repeated. +}; + +typedef ::boost::shared_ptr< AxContainerModelBase > AxContainerModelRef; + +// ============================================================================ + +/** Model for a Forms 2.0 frame (group box). */ +class AxFrameModel : public AxContainerModelBase +{ +public: + explicit AxFrameModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** Model for a Forms 2.0 user form. */ +class AxUserFormModel : public AxContainerModelBase +{ +public: + explicit AxUserFormModel(); + + virtual ApiControlType getControlType() const; + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +// ============================================================================ + +/** A form control embedded in a document draw page. Contains a specific model + structure according to the type of the control. */ +class EmbeddedControl +{ +public: + explicit EmbeddedControl( const ::rtl::OUString& rName ); + ~EmbeddedControl(); /** Creates and returns the internal control model according to the passed MS class identifier. */ - AxControlModelBase* createModel( const ::rtl::OUString& rClassId ); - /** Imports a form control model from the passed input stream. */ - void importBinaryModel( BinaryInputStream& rInStrm ); + ControlModelRef createModel( const ::rtl::OUString& rClassId ); - /** Returns the internal control model. */ - inline const AxControlModelBase* getModel() const { return mxModel.get(); } - /** Returns the MS class identifier used to create the internal control model. */ - inline const ::rtl::OUString& getClassId() const { return maClassId; } + /** Returns true, if the internal control model exists. */ + inline bool hasModel() const { return mxModel.get() != 0; } + /** Returns the UNO service name needed to construct the control model. */ + ::rtl::OUString getServiceName() const; - /** Creates and returns the UNO form component object for this control and - inserts it into the form wrapped by the passed helper. */ - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > - convertAndInsert( AxControlHelper& rHelper ) const; + /** Converts all control properties and inserts them into the passed model. */ + bool convertProperties( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, + const ControlConverter& rConv ) const; private: - ::std::auto_ptr< AxControlModelBase > mxModel; - ::rtl::OUString maClassId; /// Class identifier of the control model. + ControlModelRef mxModel; /// Control model containing the properties. ::rtl::OUString maName; /// Name of the control. }; // ============================================================================ +/** A wrapper for a control form embedded directly in a draw page. */ +class EmbeddedForm : public ControlConverter +{ +public: + explicit EmbeddedForm( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage, + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + + /** Converts the passed ActiveX control and inserts it into the form. + @return The API control model, if conversion was successful. */ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > + convertAndInsert( const EmbeddedControl& rControl ); + +private: + /** Tries to insert the passed control model into the form. */ + bool insertControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel ); + + /** Creates the form that will hold the form controls. */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > + createForm(); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxModelFactory; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier > mxFormsSupp; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > mxFormIC; +}; + +// ============================================================================ + } // namespace ole } // namespace oox #endif - diff --git a/oox/inc/oox/ole/axcontrolfragment.hxx b/oox/inc/oox/ole/axcontrolfragment.hxx index 9bccbd11a0de..3c9aed61bd3e 100644 --- a/oox/inc/oox/ole/axcontrolfragment.hxx +++ b/oox/inc/oox/ole/axcontrolfragment.hxx @@ -33,8 +33,8 @@ namespace oox { namespace ole { -class AxControl; -class AxControlModelBase; +class ControlModelBase; +class EmbeddedControl; // ============================================================================ @@ -44,32 +44,32 @@ class AxControlPropertyContext : public ::oox::core::ContextHandler2 public: explicit AxControlPropertyContext( ::oox::core::FragmentHandler2& rFragment, - AxControlModelBase& rModel ); + ControlModelBase& rModel ); virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); private: - AxControlModelBase& mrModel; + ControlModelBase& mrModel; sal_Int32 mnPropId; /// Identifier of currently processed property. }; // ============================================================================ -/** Fragment handler for an ActiveX form control fragment. */ +/** Fragment handler for an embedded ActiveX form control fragment. */ class AxControlFragment : public ::oox::core::FragmentHandler2 { public: explicit AxControlFragment( ::oox::core::XmlFilterBase& rFilter, const ::rtl::OUString& rFragmentPath, - AxControl& rControl ); + EmbeddedControl& rControl ); virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); private: - AxControl& mrControl; + EmbeddedControl& mrControl; }; // ============================================================================ diff --git a/oox/inc/oox/ole/axcontrolhelper.hxx b/oox/inc/oox/ole/axcontrolhelper.hxx deleted file mode 100644 index d34cf45f3654..000000000000 --- a/oox/inc/oox/ole/axcontrolhelper.hxx +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef OOX_OLE_AXCONTROLHELPER_HXX -#define OOX_OLE_AXCONTROLHELPER_HXX - -#include - -namespace com { namespace sun { namespace star { - namespace graphic { class XGraphic; } - namespace drawing { class XDrawPage; } - namespace form { class XForm; } -} } } - -namespace oox { namespace core { class FilterBase; } } - -namespace oox { -namespace ole { - -// ============================================================================ - -const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005; -const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006; -const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008; -const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F; -const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012; - -// ============================================================================ - -enum AxDefaultColorMode -{ - AX_DEFAULTCOLORMODE_BGR, /// OLE default color type is interpreted as BGR color. - AX_DEFAULTCOLORMODE_PALETTE /// OLE default color type is interpreted as palette color. -}; - -// ============================================================================ - -/** Helper functions and callbacks for ActiveX form control filters. */ -class AxControlHelper -{ -public: - explicit AxControlHelper( - const ::oox::core::FilterBase& rFilter, - AxDefaultColorMode eColorMode = AX_DEFAULTCOLORMODE_BGR ); - virtual ~AxControlHelper(); - - /** Returns the filter object that imports/exports the form controls. */ - inline const ::oox::core::FilterBase& getFilter() const { return mrFilter; } - /** Returns the UNO form used to insert the control models. */ - ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > - getControlForm() const; - /** Returns the UNO RGB color from the passed encoded OLE color. */ - sal_Int32 convertColor( sal_uInt32 nAxColor ) const; - -protected: - /** Derived classes returns the UNO form of the current context. Called exactly once. */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > - createControlForm() const = 0; - -private: - const ::oox::core::FilterBase& mrFilter; - const AxDefaultColorMode meColorMode; - mutable ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > mxForm; - mutable bool mbHasFormQuerried; -}; - -// ============================================================================ - -/** Helper functions and callbacks for ActiveX form controls embedded in a - document. */ -class AxEmbeddedControlHelper : public AxControlHelper -{ -public: - explicit AxEmbeddedControlHelper( - const ::oox::core::FilterBase& rFilter, - const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage, - AxDefaultColorMode eColorMode = AX_DEFAULTCOLORMODE_BGR ); - -protected: - /** Creates and returns the standard UNO form in the wrapped draw page. */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > - createControlForm() const; - -private: - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxDrawPage; -}; - -// ============================================================================ - -} // namespace ole -} // namespace oox - -#endif - diff --git a/oox/inc/oox/ole/olehelper.hxx b/oox/inc/oox/ole/olehelper.hxx index 91ca73a38a67..ba46d3baf6df 100644 --- a/oox/inc/oox/ole/olehelper.hxx +++ b/oox/inc/oox/ole/olehelper.hxx @@ -31,13 +31,49 @@ #include #include "oox/helper/binarystreambase.hxx" -namespace oox { class BinaryInputStream; } +namespace oox { + class BinaryInputStream; + class GraphicHelper; +} namespace oox { namespace ole { // ============================================================================ +const sal_Char* const OLE_GUID_STDFONT = "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"; +const sal_Char* const OLE_GUID_STDPIC = "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"; +const sal_Char* const OLE_GUID_STDHLINK = "{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}"; + +// ============================================================================ + +const sal_uInt16 OLE_STDFONT_NORMAL = 400; +const sal_uInt16 OLE_STDFONT_BOLD = 700; + +const sal_uInt8 OLE_STDFONT_ITALIC = 0x02; +const sal_uInt8 OLE_STDFONT_UNDERLINE = 0x04; +const sal_uInt8 OLE_STDFONT_STRIKE = 0x08; + +/** Stores data about a StdFont font structure. */ +struct StdFontInfo +{ + ::rtl::OUString maName; /// Font name. + sal_uInt32 mnHeight; /// Font height (1/10,000 points). + sal_uInt16 mnWeight; /// Font weight (normal/bold). + sal_uInt16 mnCharSet; /// Font charset. + sal_uInt8 mnFlags; /// Font flags. + + explicit StdFontInfo(); + explicit StdFontInfo( + const ::rtl::OUString& rName, + sal_uInt32 nHeight, + sal_uInt16 nWeight = OLE_STDFONT_NORMAL, + sal_uInt16 nCharSet = WINDOWS_CHARSET_ANSI, + sal_uInt8 nFlags = 0 ); +}; + +// ============================================================================ + /** Stores data about a StdHlink hyperlink. */ struct StdHlinkInfo { @@ -53,14 +89,45 @@ struct StdHlinkInfo class OleHelper { public: - /** Imports a GUID from the passed binary stream and returns its string representation. */ + /** Returns the UNO RGB color from the passed encoded OLE color. + + @param bDefaultColorBgr + True = OLE default color type is treated as BGR color. + False = OLE default color type is treated as palette color. + */ + static sal_Int32 decodeOleColor( + const GraphicHelper& rGraphicHelper, + sal_uInt32 nOleColor, + bool bDefaultColorBgr = true ); + + /** Imports a GUID from the passed binary stream and returns its string + representation (in uppercase characters). + */ static ::rtl::OUString importGuid( BinaryInputStream& rInStrm ); - /** Imports an OLE StdPic picture from the current position of the passed binary stream. */ - static bool importStdPic( StreamDataSequence& orGraphicData, BinaryInputStream& rInStrm, bool bWithGuid ); + /** Imports an OLE StdFont font structure from the current position of the + passed binary stream. + */ + static bool importStdFont( + StdFontInfo& orFontInfo, + BinaryInputStream& rInStrm, + bool bWithGuid ); + + /** Imports an OLE StdPic picture from the current position of the passed + binary stream. + */ + static bool importStdPic( + StreamDataSequence& orGraphicData, + BinaryInputStream& rInStrm, + bool bWithGuid ); - /** Imports an OLE StdHlink from the current position of the passed binary stream. */ - static bool importStdHlink( StdHlinkInfo& orHlinkInfo, BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc, bool bWithGuid ); + /** Imports an OLE StdHlink from the current position of the passed binary + stream. + */ + static bool importStdHlink( + StdHlinkInfo& orHlinkInfo, + BinaryInputStream& rInStrm, + bool bWithGuid ); private: OleHelper(); // not implemented diff --git a/oox/inc/oox/ole/olestorage.hxx b/oox/inc/oox/ole/olestorage.hxx new file mode 100755 index 000000000000..a84fadfadc92 --- /dev/null +++ b/oox/inc/oox/ole/olestorage.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_OLESTORAGE_HXX +#define OOX_OLE_OLESTORAGE_HXX + +#include "oox/helper/storagebase.hxx" + +namespace com { namespace sun { namespace star { + namespace lang { class XMultiServiceFactory; } + namespace container { class XNameContainer; } +} } } + +namespace oox { +namespace ole { + +// ============================================================================ + +/** Implements stream access for binary OLE storages. */ +class OleStorage : public StorageBase +{ +public: + explicit OleStorage( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream, + bool bBaseStreamAccess ); + + explicit OleStorage( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream, + bool bBaseStreamAccess ); + + virtual ~OleStorage(); + +private: + explicit OleStorage( + const OleStorage& rParentStorage, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxStorage, + const ::rtl::OUString& rElementName, + bool bReadOnly ); + explicit OleStorage( + const OleStorage& rParentStorage, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream, + const ::rtl::OUString& rElementName ); + + /** Initializes the API storage object for input. */ + void initStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream ); + /** Initializes the API storage object for input/output. */ + void initStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ); + + /** Returns true, if the object represents a valid storage. */ + virtual bool implIsStorage() const; + + /** Returns the com.sun.star.embed.XStorage interface of the current storage. + + @attention + This function is not implemented for binary OLE storages. + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > + implGetXStorage() const; + + /** Returns the names of all elements of this storage. */ + virtual void implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const; + + /** Opens and returns the specified sub storage from the storage. */ + virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing ); + + /** Opens and returns the specified input stream from the storage. */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + implOpenInputStream( const ::rtl::OUString& rElementName ); + + /** Opens and returns the specified output stream from the storage. */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > + implOpenOutputStream( const ::rtl::OUString& rElementName ); + + /** Commits the current storage. */ + virtual void implCommit() const; + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + mxFactory; /// Factory for storage/stream creation. + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + mxStorage; /// Access to elements of this sub storage. + const OleStorage* mpParentStorage; /// Parent OLE storage that contains this storage. +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbacontrol.hxx b/oox/inc/oox/ole/vbacontrol.hxx new file mode 100755 index 000000000000..ec1c25be6952 --- /dev/null +++ b/oox/inc/oox/ole/vbacontrol.hxx @@ -0,0 +1,205 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBACONTROL_HXX +#define OOX_OLE_VBACONTROL_HXX + +#include "oox/ole/axcontrol.hxx" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } +} } } + +namespace oox { class StorageBase; } + +namespace oox { +namespace ole { + +class VbaFormControl; + +// ============================================================================ + +/** Common properties for all controls that are part of a VBA user form or of + another container control in a VBA user form. */ +class VbaSiteModel +{ +public: + explicit VbaSiteModel(); + virtual ~VbaSiteModel(); + + /** Allows to set single properties specified by XML token identifier. */ + void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue ); + /** Imports the site model data from the passed input stream. */ + bool importBinaryModel( BinaryInputStream& rInStrm ); + /** Moves the control relative to its current position by the passed distance. */ + void moveRelative( const AxPairData& rDistance ); + + /** Returns the programmatical name of the control. */ + inline const ::rtl::OUString& getName() const { return maName; } + /** Returns the position of the control in its parent. */ + inline const AxPairData& getPosition() const { return maPos; } + /** Returns true, if this control is a container control. */ + bool isContainer() const; + /** Returns the length of the stream data for stream based controls. */ + sal_uInt32 getStreamLength() const; + /** Returns the name of the substorage for the container control data. */ + ::rtl::OUString getSubStorageName() const; + /** Returns the tab index of the control. */ + inline sal_Int16 getTabIndex() const { return mnTabIndex; } + + /** Tries to create the control model according to the site model. */ + ControlModelRef createControlModel( const AxClassTable& rClassTable ) const; + /** Converts all form site properties. */ + void convertProperties( + PropertyMap& rPropMap, + const ControlConverter& rConv, + ApiControlType eCtrlType, + sal_Int32 nCtrlIndex ) const; + +protected: + ::rtl::OUString maName; /// Name of the control. + ::rtl::OUString maTag; /// User defined tag. + ::rtl::OUString maToolTip; /// Tool tip for the control. + ::rtl::OUString maLinkedCell; /// Linked cell for the control value in a spreadsheet. + ::rtl::OUString maSourceRange; /// Source data for the control in a spreadsheet. + AxPairData maPos; /// Position in parent container. + sal_Int32 mnId; /// Control identifier. + sal_Int32 mnHelpContextId; /// Help context identifier. + sal_uInt32 mnFlags; /// Various flags. + sal_uInt32 mnStreamLen; /// Size of control stream data. + sal_Int16 mnTabIndex; /// Tab order index. + sal_uInt16 mnClassIdOrCache; /// Class name identifier or GUID cache index. + sal_uInt16 mnGroupId; /// Group identifier for grouped controls. +}; + +typedef ::boost::shared_ptr< VbaSiteModel > VbaSiteModelRef; + +// ============================================================================ + +/** A control that is embedded in a VBA user form or in another container + control in a VBA user form. + + The control may be a 'simple' control with its data stored in the 'o' + stream, or it may be a container control with its data stored in an own + substorage. + */ +class VbaFormControl +{ +public: + explicit VbaFormControl(); + virtual ~VbaFormControl(); + + /** Imports the model from the passed stream or storage, depending on the + control's type. Imports all embedded controls, if this is a container. */ + void importModelOrStorage( + BinaryInputStream& rInStrm, + StorageBase& rStrg, + const AxClassTable& rClassTable ); + + /** Returns the programmatical name of the control. */ + ::rtl::OUString getControlName() const; + + /** Creates the UNO control model, inserts it into the passed container, + and converts all control properties. */ + void createAndConvert( + sal_Int32 nCtrlIndex, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxParentNC, + const ControlConverter& rConv ) const; + +protected: + /** Creates and imports the control model containing properties of the control. */ + void importControlModel( BinaryInputStream& rInStrm, const AxClassTable& rClassTable ); + /** Creates and imports the control model, and imports all embedded + controls from the passed substorage. */ + void importStorage( StorageBase& rStrg, const AxClassTable& rClassTable ); + + /** Converts all control properties, and inserts and converts embedded controls. */ + bool convertProperties( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, + const ControlConverter& rConv, + sal_Int32 nCtrlIndex ) const; + +private: + typedef RefVector< VbaFormControl > VbaFormControlVector; + typedef VbaFormControlVector::value_type VbaFormControlRef; + + /** Creates the control model according to the current site model. */ + void createControlModel( const AxClassTable& rClassTable ); + /** Imports the site model data containing common properties of the control. */ + bool importSiteModel( BinaryInputStream& rInStrm ); + + /** Imports the site models of all embedded controls from the 'f' stream. */ + bool importEmbeddedSiteModels( BinaryInputStream& rInStrm ); + /* Final processing of all embedded controls after import. */ + void finalizeEmbeddedControls(); + + /** Moves the control relative to its current position by the passed distance. */ + void moveRelative( const AxPairData& rDistance ); + /** Moves all embedded controls from their relative position in this + control to an absolute position in the parent of this control. */ + void moveEmbeddedToAbsoluteParent(); + + /** Functor for comparing controls by their tab index. */ + static bool compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight ); + +protected: + VbaSiteModelRef mxSiteModel; /// Common control properties. + ControlModelRef mxCtrlModel; /// Specific control properties. + +private: + VbaFormControlVector maControls; /// All embedded form controls. + AxClassTable maClassTable; /// Class identifiers for exotic embedded controls. +}; + +// ============================================================================ + +class VbaUserForm : public VbaFormControl, public ControlConverter +{ +public: + explicit VbaUserForm( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + + /** Imports the form and its embedded controls, and inserts the form with + all its controls into the passed dialog library. */ + void importForm( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxDialogLib, + StorageBase& rVbaFormStrg, + const ::rtl::OUString& rModuleName, + rtl_TextEncoding eTextEnc ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxGlobalFactory; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbahelper.hxx b/oox/inc/oox/ole/vbahelper.hxx new file mode 100755 index 000000000000..76dc1c736025 --- /dev/null +++ b/oox/inc/oox/ole/vbahelper.hxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBAHELPER_HXX +#define OOX_OLE_VBAHELPER_HXX + +#include "oox/helper/binarystreambase.hxx" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } + namespace document { class XEventsSupplier; } +} } } + +namespace oox { class BinaryInputStream; } + +namespace oox { +namespace ole { + +// Directory stream record identifiers ======================================== + +const sal_uInt16 VBA_ID_MODULECOOKIE = 0x002C; +const sal_uInt16 VBA_ID_MODULEDOCSTRING = 0x001C; +const sal_uInt16 VBA_ID_MODULEDOCSTRINGUNICODE = 0x0048; +const sal_uInt16 VBA_ID_MODULEEND = 0x002B; +const sal_uInt16 VBA_ID_MODULEHELPCONTEXT = 0x001E; +const sal_uInt16 VBA_ID_MODULENAME = 0x0019; +const sal_uInt16 VBA_ID_MODULENAMEUNICODE = 0x0047; +const sal_uInt16 VBA_ID_MODULEOFFSET = 0x0031; +const sal_uInt16 VBA_ID_MODULEPRIVATE = 0x0028; +const sal_uInt16 VBA_ID_MODULEREADONLY = 0x0025; +const sal_uInt16 VBA_ID_MODULESTREAMNAME = 0x001A; +const sal_uInt16 VBA_ID_MODULESTREAMNAMEUNICODE = 0x0032; +const sal_uInt16 VBA_ID_MODULETYPEDOCUMENT = 0x0022; +const sal_uInt16 VBA_ID_MODULETYPEPROCEDURAL = 0x0021; +const sal_uInt16 VBA_ID_PROJECTCODEPAGE = 0x0003; +const sal_uInt16 VBA_ID_PROJECTEND = 0x0010; +const sal_uInt16 VBA_ID_PROJECTMODULES = 0x000F; +const sal_uInt16 VBA_ID_PROJECTVERSION = 0x0009; + +// ============================================================================ + +/** Static helper functions for the VBA filters. */ +class VbaHelper +{ +public: + /** Returns the full Basic script URL from a VBA module and macro name. + The script is assumed to be in a document library. */ + static ::rtl::OUString getBasicScriptUrl( + const ::rtl::OUString& rLibraryName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Reads the next record from the VBA directory stream 'dir'. + + @param rnRecId (out parameter) The record identifier of the new record. + @param rRecData (out parameter) The contents of the new record. + @param rInStrm The 'dir' stream. + + @return True = next record successfully read. False on any error, or + if the stream is EOF. + */ + static bool readDirRecord( + sal_uInt16& rnRecId, + StreamDataSequence& rRecData, + BinaryInputStream& rInStrm ); + + /** Extracts a key/value pair from a string separated by an equality sign. + + @param rKey (out parameter) The key before the separator. + @param rValue (out parameter) The value following the separator. + @param rCodeLine The source key/value pair. + + @return True = Equality sign separator found, and the returned key and + value are not empty. False otherwise. + */ + static bool extractKeyValue( + ::rtl::OUString& rKey, + ::rtl::OUString& rValue, + const ::rtl::OUString& rKeyValue ); + + /** Removes whitespace characters from the beginning of the passed string. + + @param rCodeLine (in/out parameter) The string to be modified. + + @return True = at least one whitespace character found and removed + from rCodeLine. False = rCodeLine is empty or does not start with + a whitespace character. + */ + static bool eatWhitespace( ::rtl::OUString& rCodeLine ); + + /** Removes the passed keyword from the beginning of the passed string. + + @param rCodeLine (in/out parameter) The string to be modified. + + @param rKeyword The keyword to be removed from the beginning of the + rCodeLine string. + + @return True = rCodeLine starts with the passed keyword (case + insensitive), and is followed by whitespace characters, or it ends + right after the keyword. The keyword and the following whitespace + characters have been removed from rCodeLine. False = rCodeLine is + empty or does not start with the specified keyword, or the keyword + is not followed by whitespace characters. + */ + static bool eatKeyword( ::rtl::OUString& rCodeLine, const ::rtl::OUString& rKeyword ); + + /** Returns the VBA source code of the specified module, or an empty + string, if the module does not exist. + + @param rxBasicLib The container for all VBA code modules. + @param rModuleName The name of the VBA code module. + */ + static ::rtl::OUString getSourceCode( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::rtl::OUString& rModuleName ); + + /** Checks, if a macro with the specified name exists in the passed VBA + source code. + + @param rSourceCode The VBA source code. + @param rMacroName The name of the macro. + */ + static bool hasMacro( + const ::rtl::OUString& rSourceCode, + const ::rtl::OUString& rMacroName ); + + /** Checks, if a macro with the specified name exists in the specified + module. + + @param rxBasicLib The container for all VBA code modules. + @param rModuleName The name of the VBA module to check for the macro. + @param rMacroName The name of the macro. + */ + static bool hasMacro( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Tries to insert a VBA macro into the specified code module. + + @descr If the specified macro does not exist, it will be generated as + following, using the passed parameters. If the parameter rMacroType + is left empty, a sub procedure macro will be generated: + + Private Sub ( ) + + End Sub + + If the parameter rMacroType is not empty, a function macro + will be generated. Note that the parameter rMacroCode has to + provide the code that returns the function value. + + Private Function ( ) As + + End Function + + The source code in rMacroCode may contain a special placeholder + $MACRO that will be replaced by the macro name passed in rMacroName + before the macro will be inserted into the module. + + @param rModuleName The name of the VBA module to be used. + @param rMacroName The name of the VBA macro to be inserted. + @param rMacroArgs The argument list of the VBA macro. + @param rMacroType Macro return type (empty for sub procedure). + @param rMacroCode The VBA source code for the macro. + + @return True, if the specified VBA macro has been inserted. False, if + there already exists a macro with the specified name, or if any + error has occurred, for example, Office configuration forbids to + generate executable VBA code or the specified module does not + exist. + */ + static bool insertMacro( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rMacroArgs, + const ::rtl::OUString& rMacroType, + const ::rtl::OUString& rMacroCode ); + + /** Tries to attach a VBA macro to an event of the passed events supplier. + + @descr The function checks if the specified macro exists and attaches + it to the event of the passed events supplier. + + @param rxEventsSupp The events supplier for the event to be attached. + @param rEventName The event name used in the office API. + @param rLibraryName The name of the Basic library containing the macro. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + */ + static bool attachMacroToEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rLibraryName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + +private: + VbaHelper(); + ~VbaHelper(); +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbamodule.hxx b/oox/inc/oox/ole/vbamodule.hxx new file mode 100755 index 000000000000..3b529ceee129 --- /dev/null +++ b/oox/inc/oox/ole/vbamodule.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBAMODULE_HXX +#define OOX_OLE_VBAMODULE_HXX + +#include +#include + +namespace com { namespace sun { namespace star { + namespace container { class XNameAccess; } + namespace container { class XNameContainer; } + namespace frame { class XModel; } +} } } + +namespace oox { + class BinaryInputStream; + class StorageBase; +} + +namespace oox { +namespace ole { + +// ============================================================================ + +class VbaModule +{ +public: + explicit VbaModule( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, + const ::rtl::OUString& rName, + rtl_TextEncoding eTextEnc, + bool bExecutable ); + + /** Returns the module type (com.sun.star.script.ModuleType constant). */ + inline sal_Int32 getType() const { return mnType; } + /** Sets the passed module type. */ + inline void setType( sal_Int32 nType ) { mnType = nType; } + + /** Returns the name of the module. */ + inline const ::rtl::OUString& getName() const { return maName; } + /** Returns the stream name of the module. */ + inline const ::rtl::OUString& getStreamName() const { return maStreamName; } + + /** Imports all records for this module until the MODULEEND record. */ + void importDirRecords( BinaryInputStream& rDirStrm ); + /** Imports the Basic source code into the passed Basic library. */ + void importSourceCode( + StorageBase& rVbaStrg, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxDocObjectNA ) const; + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + mxDocModel; /// Document model used to import/export the VBA project. + ::rtl::OUString maName; + ::rtl::OUString maStreamName; + ::rtl::OUString maDocString; + rtl_TextEncoding meTextEnc; + sal_Int32 mnType; + sal_uInt32 mnOffset; + bool mbReadOnly; + bool mbPrivate; + bool mbExecutable; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ole/vbaproject.hxx b/oox/inc/oox/ole/vbaproject.hxx new file mode 100755 index 000000000000..0422ccbd0cf8 --- /dev/null +++ b/oox/inc/oox/ole/vbaproject.hxx @@ -0,0 +1,289 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_OLE_VBAPROJECT_HXX +#define OOX_OLE_VBAPROJECT_HXX + +#include "oox/helper/storagebase.hxx" +#include +#include "oox/dllapi.h" + +namespace com { namespace sun { namespace star { + namespace container { class XNameContainer; } + namespace document { class XEventsSupplier; } + namespace frame { class XModel; } + namespace script { class XLibraryContainer; } + namespace lang { class XMultiServiceFactory; } +} } } + +namespace oox { class GraphicHelper; } + +namespace oox { +namespace ole { + +// ============================================================================ + +class OOX_DLLPUBLIC VbaFilterConfig +{ +public: + explicit VbaFilterConfig( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::rtl::OUString& rConfigCompName ); + ~VbaFilterConfig(); + + /** Returns true, if the VBA source code and forms should be imported. */ + bool isImportVba() const; + /** Returns true, if the VBA source code should be imported executable. */ + bool isImportVbaExecutable() const; + /** Returns true, if the VBA source code and forms should be exported. */ + bool isExportVba() const; + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + mxConfigAccess; +}; + +// ============================================================================ + +class OOX_DLLPUBLIC VbaProject : public VbaFilterConfig +{ +public: + explicit VbaProject( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, + const ::rtl::OUString& rConfigCompName ); + virtual ~VbaProject(); + + /** Imports the entire VBA project from the passed storage. + + @param rVbaPrjStrg The root storage of the entire VBA project. + */ + void importVbaProject( + StorageBase& rVbaPrjStrg, + const GraphicHelper& rGraphicHelper, + bool bDefaultColorBgr = true ); + + /** Returns true, if the document contains at least one code module. */ + bool hasModules() const; + /** Returns true, if the document contains the specified code module. */ + bool hasModule( const ::rtl::OUString& rModuleName ) const; + + /** Returns true, if the document contains at least one dialog. */ + bool hasDialogs() const; + /** Returns true, if the document contains the specified dialog. */ + bool hasDialog( const ::rtl::OUString& rDialogName ) const; + + // Insert VBA code modules and VBA macros into modules -------------------- + + /** Tries to insert a VBA macro into the specified code module. + + @descr If the specified macro does not exist, it will be generated as + following, using the passed parameters. If the parameter rMacroType + is left empty, a sub procedure macro will be generated: + + Private Sub ( ) + + End Sub + + If the parameter rMacroType is not empty, a function macro + will be generated. Note that the parameter rMacroCode has to + provide the code that returns the function value. + + Private Function ( ) As + + End Function + + The source code in rMacroCode may contain a special placeholder + $MACRO that will be replaced by the macro name passed in rMacroName + before the macro will be inserted into the module. + + @param rModuleName The name of the VBA module to be used. + @param rMacroName The name of the VBA macro to be inserted. + @param rMacroArgs The argument list of the VBA macro. + @param rMacroType Macro return type (empty for sub procedure). + @param rMacroCode The VBA source code for the macro. + + @return True, if the specified VBA macro has been inserted. False, if + there already exists a macro with the specified name, or if any + error has occurred, for example, Office configuration forbids to + generate executable VBA code or the specified module does not + exist. + */ + bool insertMacro( + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rMacroArgs, + const ::rtl::OUString& rMacroType, + const ::rtl::OUString& rMacroCode ); + + // Attach VBA macros to generic or document events ------------------------ + + /** Tries to attach the specified VBA macro to an event directly. + + @descr The function checks if the specified macro exists and attaches + it to the event of the passed events supplier. + + @param rxEventsSupp The events supplier for the event to be attached. + @param rEventName The event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + + @return True, if the specified VBA macro exists and could be attached + to the specified event. + */ + bool attachMacroToEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Tries to attach the specified VBA macro to a document event directly. + + @descr The function checks if the specified macro exists and attaches + it to the document event. + + @param rEventName The document event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + + @return True, if the specified VBA macro exists and could be attached + to the specified document event. + */ + bool attachMacroToDocumentEvent( + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName ); + + /** Tries to attach the specified VBA macro to an event via a generated + proxy macro that implements necessary conversion between VBA and UNO. + + @descr The function checks if the specified VBA macro exists, then it + tries to generate a proxy macro using the parameters passed to this + function, appends it to the code module, and attaches it to the + event. + + The proxy macro will execute the code specified in the rProxyCode + parameter. This code may contain special placeholders that will be + replaced before the proxy macro will be inserted into the module: + - $MACRO will be replaced by the original VBA macro name passed + in the rMacroName parameter. + - $PROXY will be replaced by the name of the proxy macro + generated by this function. + + @param rxEventsSupp The events supplier for the event to be attached. + @param rEventName The event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + @param rProxyArgs The argument list of the generated proxy macro. + @param rProxyType Proxy macro return type (empty for procedure). + @param rProxyCode Proxy macro source code. + + @return True, if the specified VBA macro exists and could be attached + to the specified event. + */ + bool attachMacroToEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rProxyArgs, + const ::rtl::OUString& rProxyType, + const ::rtl::OUString& rProxyCode ); + + /** Tries to attach the specified VBA macro to a document event via a + proxy macro that implements necessary conversion between VBA and UNO. + + @descr The function checks if the specified VBA macro exists, then it + tries to generate a proxy macro using the parameters passed to this + function, appends it to the code module, and attaches it to the + document event. + + The proxy macro will execute the code specified in the rProxyCode + parameter. This code may contain special placeholders that will be + replaced before the proxy macro will be inserted into the module: + - $MACRO will be replaced by the original VBA macro name passed + in the rMacroName parameter. + - $PROXY will be replaced by the name of the proxy macro + generated by this function. + + @param rEventName The document event name used in the office API. + @param rModuleName The name of the VBA module containing the macro. + @param rMacroName The name of the VBA macro to attach to the event. + @param rProxyArgs The argument list of the generated proxy macro. + @param rProxyType Proxy macro return type (empty for procedure). + @param rProxyCode Proxy macro source code. + + @return True, if the specified VBA macro exists and could be attached + to the specified event. + */ + bool attachMacroToDocumentEvent( + const ::rtl::OUString& rEventName, + const ::rtl::OUString& rModuleName, + const ::rtl::OUString& rMacroName, + const ::rtl::OUString& rProxyArgs, + const ::rtl::OUString& rProxyType, + const ::rtl::OUString& rProxyCode ); + +private: + VbaProject( const VbaProject& ); + VbaProject& operator=( const VbaProject& ); + + /** Returns the Basic or dialog library container. */ + ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer > + getLibraryContainer( sal_Int32 nPropId ); + /** Opens a Basic or dialog library (creates missing if specified). */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + openLibrary( sal_Int32 nPropId, bool bCreateMissing ); + /** Creates and returns the Basic library of the document used for import. */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + createBasicLibrary(); + /** Creates and returns the dialog library of the document used for import. */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + createDialogLibrary(); + /** Imports the VBA code modules and forms. */ + void importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ); + /** Copies the entire VBA project storage to the passed document model. */ + void copyStorage( StorageBase& rVbaPrjStrg ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + mxGlobalFactory; /// Global service factory. + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + mxDocModel; /// Document model used to import/export the VBA project. + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + mxBasicLib; /// The Basic library of the document used for import. + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + mxDialogLib; /// The dialog library of the document used for import. + const ::rtl::OUString maLibName; /// Name for Basic and dialog library used for import. +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif diff --git a/oox/inc/oox/ppt/pptimport.hxx b/oox/inc/oox/ppt/pptimport.hxx index 7d04e1c492fa..c4ee29447c64 100644 --- a/oox/inc/oox/ppt/pptimport.hxx +++ b/oox/inc/oox/ppt/pptimport.hxx @@ -53,8 +53,6 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; - virtual const ::oox::drawingml::Theme* getCurrentTheme() const; virtual ::oox::vml::Drawing* getVmlDrawing(); virtual const oox::drawingml::table::TableStyleListPtr getTableStyles(); @@ -66,7 +64,10 @@ public: std::vector< SlidePersistPtr >& getMasterPages(){ return maMasterPages; }; std::vector< SlidePersistPtr >& getNotesPages(){ return maNotesPages; }; + sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + private: + virtual GraphicHelper* implCreateGraphicHelper() const; virtual ::rtl::OUString implGetImplementationName() const; private: diff --git a/oox/inc/oox/vml/vmldrawing.hxx b/oox/inc/oox/vml/vmldrawing.hxx index 1af14903793b..2312514d7117 100644 --- a/oox/inc/oox/vml/vmldrawing.hxx +++ b/oox/inc/oox/vml/vmldrawing.hxx @@ -39,7 +39,7 @@ namespace com { namespace sun { namespace star { } } } namespace oox { namespace core { class XmlFilterBase; } } -namespace oox { namespace ole { class AxControlHelper; } } +namespace oox { namespace ole { class EmbeddedForm; } } namespace oox { namespace vml { @@ -110,8 +110,8 @@ public: inline ShapeContainer& getShapes() { return *mxShapes; } /** Returns read access to the container of shapes and templates. */ inline const ShapeContainer& getShapes() const { return *mxShapes; } - /** Returns the helper object used to process ActiveX form controls. */ - ::oox::ole::AxControlHelper& getControlHelper() const; + /** Returns the form object used to process ActiveX form controls. */ + ::oox::ole::EmbeddedForm& getControlForm() const; /** Registers the passed embedded OLE object. The related shape will then load the OLE object data from the specified fragment. */ @@ -146,12 +146,8 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, const ShapeClientData& rClientData ) const; -protected: - /** Derived classes may create a specialized form control helper object. */ - virtual ::oox::ole::AxControlHelper* createControlHelper() const; - private: - typedef ::std::auto_ptr< ::oox::ole::AxControlHelper > AxControlHelperPtr; + typedef ::std::auto_ptr< ::oox::ole::EmbeddedForm > EmbeddedFormPtr; typedef ::std::auto_ptr< ShapeContainer > ShapeContainerPtr; typedef ::std::map< ::rtl::OUString, OleObjectInfo > OleObjectInfoMap; typedef ::std::map< ::rtl::OUString, ControlInfo > ControlInfoMap; @@ -159,7 +155,7 @@ private: ::oox::core::XmlFilterBase& mrFilter; /// Filter object that imports/exports the VML drawing. ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxDrawPage; /// UNO draw page used to insert the shapes. - mutable AxControlHelperPtr mxCtrlHelper;/// Form control helper. + mutable EmbeddedFormPtr mxCtrlForm; /// The control form used to process ActiveX controls. ShapeContainerPtr mxShapes; /// All shapes and shape templates. OleObjectInfoMap maOleObjects; /// Info about all embedded OLE objects, mapped by shape id. ControlInfoMap maControls; /// Info about all embedded form controls, mapped by control name. diff --git a/oox/inc/oox/vml/vmlformatting.hxx b/oox/inc/oox/vml/vmlformatting.hxx index b997c7451fe4..1a9c1811cf6b 100644 --- a/oox/inc/oox/vml/vmlformatting.hxx +++ b/oox/inc/oox/vml/vmlformatting.hxx @@ -30,8 +30,11 @@ #include "oox/helper/helper.hxx" -namespace oox { class PropertyMap; } -namespace oox { namespace core { class FilterBase; } } +namespace oox { + class GraphicHelper; + class ModelObjectHelper; + class PropertyMap; +} namespace oox { namespace vml { @@ -71,7 +74,7 @@ public: /** Converts the passed VML measure string to EMU (English Metric Units). - @param rFilter The core filter object needed to perform pixel + @param rGraphicHelper The graphic helper needed to perform pixel conversion according to the current output device. @param rValue The VML measure value. This is a floating-point value @@ -88,7 +91,7 @@ public: pixel. Set to false if omitted measure unit means EMU. */ static sal_Int32 decodeMeasureToEmu( - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, const ::rtl::OUString& rValue, sal_Int32 nRefValue, bool bPixelX, @@ -96,14 +99,14 @@ public: /** Converts the passed VML measure string to 1/100 mm. - @param rFilter See above. + @param rGraphicHelper See above. @param rValue See above. @param nRefValue See above. @param bPixelX See above. @param bDefaultAsPixel See above. */ static sal_Int32 decodeMeasureToHmm( - const ::oox::core::FilterBase& rFilter, + const GraphicHelper& rGraphicHelper, const ::rtl::OUString& rValue, sal_Int32 nRefValue, bool bPixelX, @@ -147,7 +150,8 @@ struct StrokeModel /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter ) const; + ModelObjectHelper& rModelObjectHelper, + const GraphicHelper& rGraphicHelper ) const; }; // ============================================================================ @@ -172,7 +176,8 @@ struct FillModel /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::FilterBase& rFilter ) const; + ModelObjectHelper& rModelObjectHelper, + const GraphicHelper& rGraphicHelper ) const; }; // ============================================================================ diff --git a/oox/inc/oox/xls/biffhelper.hxx b/oox/inc/oox/xls/biffhelper.hxx index f425b983ada2..b4f36c113c3d 100644 --- a/oox/inc/oox/xls/biffhelper.hxx +++ b/oox/inc/oox/xls/biffhelper.hxx @@ -493,6 +493,8 @@ const sal_uInt16 BIFF_ID_TOPMARGIN = 0x0028; const sal_uInt16 BIFF_ID_TXO = 0x01B6; const sal_uInt16 BIFF_ID_UNCALCED = 0x005E; const sal_uInt16 BIFF_ID_USESELFS = 0x0160; +const sal_uInt16 BIFF_ID_VBAPROJECT = 0x00D3; +const sal_uInt16 BIFF_ID_VBAPROJECTEMPTY = 0x01BD; const sal_uInt16 BIFF_ID_VCENTER = 0x0084; const sal_uInt16 BIFF_ID_VERPAGEBREAKS = 0x001A; const sal_uInt16 BIFF_ID_WINDOW1 = 0x003D; diff --git a/oox/inc/oox/xls/excelfilter.hxx b/oox/inc/oox/xls/excelfilter.hxx index 5da8b50d7f92..b5d7a97f33b5 100644 --- a/oox/inc/oox/xls/excelfilter.hxx +++ b/oox/inc/oox/xls/excelfilter.hxx @@ -34,22 +34,23 @@ namespace oox { namespace xls { -// ============================================================================ +class WorkbookData; -class WorkbookHelper; +// ============================================================================ class ExcelFilterBase { +public: + void registerWorkbookData( WorkbookData& rData ); + WorkbookData& getWorkbookData() const; + void unregisterWorkbookData(); + protected: explicit ExcelFilterBase(); virtual ~ExcelFilterBase(); - void setWorkbookHelper( WorkbookHelper& rHelper ); - WorkbookHelper& getWorkbookHelper() const; - void clearWorkbookHelper(); - private: - WorkbookHelper* mpHelper; /// Nonowning pointer to helper base. + WorkbookData* mpData; }; // ============================================================================ @@ -64,15 +65,13 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; - virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; - virtual const ::oox::drawingml::Theme* getCurrentTheme() const; virtual ::oox::vml::Drawing* getVmlDrawing(); virtual const ::oox::drawingml::table::TableStyleListPtr getTableStyles(); virtual ::oox::drawingml::chart::ChartConverter& getChartConverter(); private: + virtual GraphicHelper* implCreateGraphicHelper() const; virtual ::rtl::OUString implGetImplementationName() const; }; @@ -88,9 +87,8 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; - private: + virtual GraphicHelper* implCreateGraphicHelper() const; virtual ::rtl::OUString implGetImplementationName() const; }; diff --git a/oox/inc/oox/xls/excelvbaproject.hxx b/oox/inc/oox/xls/excelvbaproject.hxx new file mode 100755 index 000000000000..6a517d13cd88 --- /dev/null +++ b/oox/inc/oox/xls/excelvbaproject.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_XLS_EXCELVBAPROJECT_HXX +#define OOX_XLS_EXCELVBAPROJECT_HXX + +#include "oox/ole/vbaproject.hxx" +#include "oox/dllapi.h" + +namespace com { namespace sun { namespace star { + namespace sheet { class XSpreadsheetDocument; } +} } } + +namespace oox { +namespace xls { + +// ============================================================================ + +/** Special implementation of the VBA project for the Excel filters. */ +class OOX_DLLPUBLIC VbaProject : public ::oox::ole::VbaProject +{ +public: + explicit VbaProject( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& rxDocument ); + + /** Attaches all document and sheet events to existing VBA macros. */ + void attachToEvents(); + +private: + /** Attaches VBA macros to all supported document events. */ + void attachToDocumentEvents( const ::rtl::OUString& rCodeName ); + + /** Attaches VBA macros to all supported sheet events. */ + void attachToSheetEvents( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, + const ::rtl::OUString& rCodeName ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > + mxDocument; +}; + +// ============================================================================ + +} // namespace xls +} // namespace oox + +#endif diff --git a/oox/inc/oox/xls/stylesbuffer.hxx b/oox/inc/oox/xls/stylesbuffer.hxx index 8af5127143de..0cef90019809 100644 --- a/oox/inc/oox/xls/stylesbuffer.hxx +++ b/oox/inc/oox/xls/stylesbuffer.hxx @@ -35,6 +35,7 @@ #include #include #include "oox/helper/containerhelper.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/drawingml/color.hxx" #include "oox/xls/numberformatsbuffer.hxx" @@ -78,6 +79,22 @@ const sal_Int8 API_ESCAPEHEIGHT_DEFAULT = 58; /// Relative character h // ============================================================================ +/** Special implementation of the GraphicHelper for Excel palette and scheme + colors. + */ +class ExcelGraphicHelper : public GraphicHelper, public WorkbookHelper +{ +public: + explicit ExcelGraphicHelper( const WorkbookHelper& rHelper ); + + /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */ + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + /** Derived classes may implement to resolve a palette index to an RGB color. */ + virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; +}; + +// ============================================================================ + class Color : public ::oox::drawingml::Color { public: @@ -205,7 +222,7 @@ struct ApiScriptFontName { ::rtl::OUString maName; /// Font name. sal_Int16 mnFamily; /// Font family. - sal_Int16 mnCharSet; /// Font character set. + sal_Int16 mnTextEnc; /// Font text encoding. explicit ApiScriptFontName(); }; diff --git a/oox/inc/oox/xls/workbookfragment.hxx b/oox/inc/oox/xls/workbookfragment.hxx index f9f0bb25c78f..0a4853748bf5 100644 --- a/oox/inc/oox/xls/workbookfragment.hxx +++ b/oox/inc/oox/xls/workbookfragment.hxx @@ -92,6 +92,9 @@ private: bool importSheetFragment( ISegmentProgressBar& rProgressBar, BiffFragmentType eFragment, sal_Int16 nCalcSheet ); + +private: + bool mbImportVbaProject; /// True = import VBA project at end of filter. }; // ============================================================================ diff --git a/oox/inc/oox/xls/workbookhelper.hxx b/oox/inc/oox/xls/workbookhelper.hxx index 90c0f33c3c50..8a6f436bbaaf 100644 --- a/oox/inc/oox/xls/workbookhelper.hxx +++ b/oox/inc/oox/xls/workbookhelper.hxx @@ -29,9 +29,8 @@ #define OOX_XLS_WORKBOOKHELPER_HXX #include -#include #include -#include +//#include "oox/helper/storagebase.hxx" #include "oox/xls/biffhelper.hxx" namespace com { namespace sun { namespace star { @@ -72,87 +71,8 @@ namespace oox { namespace drawingml { namespace oox { namespace xls { -// DEBUG ====================================================================== - -// Set this define to 1 to show the load/save time of a document in an assertion (nonpro only). -#define OOX_SHOW_LOADSAVE_TIME 0 - -// ---------------------------------------------------------------------------- - -#define OOX_LOADSAVE_TIMER( eTimerType ) (void)0 - -#if OSL_DEBUG_LEVEL > 0 -namespace dbg { - -// ---------------------------------------------------------------------------- - -#if OOX_SHOW_LOADSAVE_TIME > 0 - -enum TimerType -{ - TIMER_IMPORTFORMULA, - TIMER_IMPORTSHEETFRAGMENT, - TIMER_ONCREATESHEETCONTEXT, - TIMER_IMPORTROW, - TIMER_CONVERTROWFORMAT, - TIMER_CONVERTCOLUMNFORMAT, - TIMER_IMPORTCELL, - TIMER_ONENDSHEETELEMENT, - TIMER_SETCELL, - TIMER_SETCELLFORMAT, - TIMER_MERGECELLFORMAT, - TIMER_WRITECELLPROPERTIES, - TIMER_FINALIZESHEETDATA, - TIMER_FINALIZEDRAWING, - TIMER_FINALIZEBOOKDATA, - - // TIMER_TOTAL must be the last entry! - TIMER_TOTAL -}; - -// ---------------------------------------------------------------------------- - -struct TimeCount; - -class Timer -{ -public: - explicit Timer( TimeCount& rTimeCount ); - ~Timer(); -private: - TimeCount& mrTimeCount; - TimeValue maStartTime; -}; - -// ---------------------------------------------------------------------------- - -#undef OOX_LOADSAVE_TIMER -#define OOX_LOADSAVE_TIMER( TimerType ) ::oox::xls::dbg::Timer aDbgTimer##TimerType( getTimeCount( ::oox::xls::dbg::TIMER_##TimerType ) ) - -#endif - -// ---------------------------------------------------------------------------- - -struct WorkbookData; - -class WorkbookHelper -{ -protected: - explicit WorkbookHelper( WorkbookData& rBookData ); - explicit WorkbookHelper( const WorkbookHelper& rCopy ); - virtual ~WorkbookHelper(); -#if OOX_SHOW_LOADSAVE_TIME > 0 -public: - TimeCount& getTimeCount( TimerType eType ) const; -#endif -private: - WorkbookData& mrDbgBookData; -}; - -// ---------------------------------------------------------------------------- - -} // namespace dbg -#endif +class ExcelFilter; +class ExcelBiffFilter; // ============================================================================ @@ -193,6 +113,7 @@ class UnitConverter; class AddressConverter; class ExcelChartConverter; class PageSettingsConverter; +class VbaProject; class BiffCodecHelper; /** Helper class to provice access to global workbook data. @@ -201,14 +122,15 @@ class BiffCodecHelper; object of type WorkbookData containing global workbook settings, buffers, converters, etc. Nearly all classes in this filter implementation are derived directly or indirectly from this class. + + This class contains just a simple reference to the WorkbookData object to + prevent circular references, as the WorkbookData object contains a lot of + objects derived from this class. */ class WorkbookHelper -#if OSL_DEBUG_LEVEL > 0 - : public dbg::WorkbookHelper -#endif { public: - /*implicit*/ WorkbookHelper( WorkbookData& rBookData ); + inline /*implicit*/ WorkbookHelper( WorkbookData& rBookData ) : mrBookData( rBookData ) {} virtual ~WorkbookHelper(); // filter ----------------------------------------------------------------- @@ -333,8 +255,10 @@ public: ExcelChartConverter& getChartConverter() const; /** Returns the page and print settings converter. */ PageSettingsConverter& getPageSettingsConverter() const; + /** Returns the VBA project used to import/export VBA and attach events. */ + VbaProject& getVbaProject() const; - // OOX specific ----------------------------------------------------------- + // OOX specific (MUST NOT be called in BIFF filter) ----------------------- /** Returns the base OOX filter object. Must not be called, if current filter is not the OOX filter. */ @@ -344,7 +268,7 @@ public: the full path to the fragment stream. */ bool importOoxFragment( const ::rtl::Reference< ::oox::core::FragmentHandler >& rxHandler ); - // BIFF specific ---------------------------------------------------------- + // BIFF specific (MUST NOT be called in OOX filter) ----------------------- /** Returns the base BIFF filter object. */ ::oox::core::BinaryFilterBase& getBiffFilter() const; @@ -392,8 +316,8 @@ struct WorkbookDataOwner class WorkbookHelperRoot : private prv::WorkbookDataOwner, public WorkbookHelper { public: - explicit WorkbookHelperRoot( ::oox::core::XmlFilterBase& rFilter ); - explicit WorkbookHelperRoot( ::oox::core::BinaryFilterBase& rFilter, BiffType eBiff ); + explicit WorkbookHelperRoot( ExcelFilter& rFilter ); + explicit WorkbookHelperRoot( ExcelBiffFilter& rFilter, BiffType eBiff ); /** Returns true, if this helper refers to a valid document. */ bool isValid() const; @@ -409,4 +333,3 @@ private: } // namespace oox #endif - diff --git a/oox/inc/oox/xls/worksheetsettings.hxx b/oox/inc/oox/xls/worksheetsettings.hxx index c96f12605911..17e22dc5342c 100644 --- a/oox/inc/oox/xls/worksheetsettings.hxx +++ b/oox/inc/oox/xls/worksheetsettings.hxx @@ -120,6 +120,8 @@ public: void importPassword( BiffInputStream& rStrm ); /** Imports protection settings from the SHEETPROTECTION record. */ void importSheetProtection( BiffInputStream& rStrm ); + /** Imports the VBA code module name from the CODENAME record. */ + void importCodeName( BiffInputStream& rStrm ); /** Imports phonetic settings from the PHONETICPR record. */ void importPhoneticPr( BiffInputStream& rStrm ); diff --git a/oox/prj/build.lst b/oox/prj/build.lst index a1dfa584543c..345c72e00558 100644 --- a/oox/prj/build.lst +++ b/oox/prj/build.lst @@ -1,4 +1,4 @@ -oox oox : vos cppu cppuhelper comphelper sal offapi sax basegfx tools vcl BOOST:boost OPENSSL:openssl NULL +oox oox : vos cppu cppuhelper comphelper sal offapi sax basegfx xmlscript tools vcl BOOST:boost OPENSSL:openssl NULL oox oox usr1 - all oox_mkout NULL oox oox\prj get - all oox_prj NULL oox oox\source\token nmake - all oox_token NULL diff --git a/oox/prj/d.lst b/oox/prj/d.lst index 2c9d8d5bae74..482a270926a3 100644 --- a/oox/prj/d.lst +++ b/oox/prj/d.lst @@ -4,7 +4,9 @@ mkdir: %_DEST%\inc%_EXT%\oox\core mkdir: %_DEST%\inc%_EXT%\oox\drawingml mkdir: %_DEST%\inc%_EXT%\oox\drawingml\chart mkdir: %_DEST%\inc%_EXT%\oox\drawingml\table +mkdir: %_DEST%\inc%_EXT%\oox\ole mkdir: %_DEST%\inc%_EXT%\oox\vml +mkdir: %_DEST%\inc%_EXT%\oox\xls ..\%__SRC%\misc\*.map %_DEST%\bin%_EXT%\*.map ..\%__SRC%\lib\ixo.lib %_DEST%\lib%_EXT%\ixo.lib @@ -22,6 +24,7 @@ mkdir: %_DEST%\inc%_EXT%\oox\vml ..\inc\oox\dllapi.h %_DEST%\inc%_EXT%\oox\dllapi.h ..\inc\oox\helper\binarystreambase.hxx %_DEST%\inc%_EXT%\oox\helper\binarystreambase.hxx ..\inc\oox\helper\helper.hxx %_DEST%\inc%_EXT%\oox\helper\helper.hxx +..\inc\oox\helper\containerhelper.hxx %_DEST%\inc%_EXT%\oox\helper\containerhelper.hxx ..\inc\oox\helper\storagebase.hxx %_DEST%\inc%_EXT%\oox\helper\storagebase.hxx ..\inc\oox\helper\zipstorage.hxx %_DEST%\inc%_EXT%\oox\helper\zipstorage.hxx ..\inc\oox\core\filterbase.hxx %_DEST%\inc%_EXT%\oox\core\filterbase.hxx @@ -30,8 +33,10 @@ mkdir: %_DEST%\inc%_EXT%\oox\vml ..\inc\oox\core\xmlfilterbase.hxx %_DEST%\inc%_EXT%\oox\core\xmlfilterbase.hxx ..\inc\oox\drawingml\chart\chartconverter.hxx %_DEST%\inc%_EXT%\oox\drawingml\chart\chartconverter.hxx ..\inc\oox\drawingml\table\tablestylelist.hxx %_DEST%\inc%_EXT%\oox\drawingml\table\tablestylelist.hxx +..\inc\oox\ole\vbaproject.hxx %_DEST%\inc%_EXT%\oox\ole\vbaproject.hxx ..\inc\oox\vml\vmldrawing.hxx %_DEST%\inc%_EXT%\oox\vml\vmldrawing.hxx ..\inc\oox\vml\vmlshape.hxx %_DEST%\inc%_EXT%\oox\vml\vmlshape.hxx +..\inc\oox\xls\excelvbaproject.hxx %_DEST%\inc%_EXT%\oox\xls\excelvbaproject.hxx dos: sh -c "if test %OS% = MACOSX; then create-bundle %_DEST%\lib%_EXT%\*.dylib; fi" diff --git a/oox/source/core/binaryfilterbase.cxx b/oox/source/core/binaryfilterbase.cxx index 1dd2e0e9086c..f308f02ac9dc 100644 --- a/oox/source/core/binaryfilterbase.cxx +++ b/oox/source/core/binaryfilterbase.cxx @@ -26,7 +26,7 @@ ************************************************************************/ #include "oox/core/binaryfilterbase.hxx" -#include "oox/helper/olestorage.hxx" +#include "oox/ole/olestorage.hxx" using ::rtl::OUString; using ::com::sun::star::uno::Reference; @@ -52,12 +52,12 @@ BinaryFilterBase::~BinaryFilterBase() StorageRef BinaryFilterBase::implCreateStorage( const Reference< XInputStream >& rxInStream ) const { - return StorageRef( new OleStorage( getGlobalFactory(), rxInStream, true ) ); + return StorageRef( new ::oox::ole::OleStorage( getGlobalFactory(), rxInStream, true ) ); } StorageRef BinaryFilterBase::implCreateStorage( const Reference< XStream >& rxOutStream ) const { - return StorageRef( new OleStorage( getGlobalFactory(), rxOutStream, true ) ); + return StorageRef( new ::oox::ole::OleStorage( getGlobalFactory(), rxOutStream, true ) ); } // ============================================================================ diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index 07c31736e9e7..27a1b26fbcfd 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -27,8 +27,6 @@ #include "oox/core/filterbase.hxx" #include -#include -#include #include #include #include @@ -57,10 +55,6 @@ using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::lang::XComponent; using ::com::sun::star::beans::PropertyValue; -using ::com::sun::star::awt::DeviceInfo; -using ::com::sun::star::awt::XDevice; -using ::com::sun::star::frame::XFrame; -using ::com::sun::star::frame::XFramesSupplier; using ::com::sun::star::frame::XModel; using ::com::sun::star::io::XInputStream; using ::com::sun::star::io::XOutputStream; @@ -139,12 +133,10 @@ struct FilterBaseImpl typedef ::boost::shared_ptr< ModelObjectHelper > ModelObjHelperRef; typedef ::boost::shared_ptr< OleObjectHelper > OleObjHelperRef; typedef ::std::map< OUString, Reference< XGraphic > > EmbeddedGraphicMap; - typedef ::std::map< sal_Int32, sal_Int32 > SystemPalette; FilterDirection meDirection; SequenceAsHashMap maArguments; MediaDescriptor maMediaDesc; - DeviceInfo maDeviceInfo; OUString maFileUrl; StorageRef mxStorage; @@ -152,7 +144,6 @@ struct FilterBaseImpl ModelObjHelperRef mxModelObjHelper; /// Tables to create new named drawing objects. OleObjHelperRef mxOleObjHelper; /// OLE object handling. EmbeddedGraphicMap maEmbeddedGraphics; /// Maps all imported embedded graphics by their path. - SystemPalette maSystemPalette; /// Maps system colors (XML tokens) to RGB color values. Reference< XMultiServiceFactory > mxGlobalFactory; Reference< XModel > mxModel; @@ -178,53 +169,6 @@ FilterBaseImpl::FilterBaseImpl( const Reference< XMultiServiceFactory >& rxGloba mxGlobalFactory( rxGlobalFactory ) { OSL_ENSURE( mxGlobalFactory.is(), "FilterBaseImpl::FilterBaseImpl - missing service factory" ); - if( mxGlobalFactory.is() ) - { - // get the metric of the output device - try - { - Reference< XFramesSupplier > xFramesSupp( mxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY_THROW ); - Reference< XFrame > xFrame( xFramesSupp->getActiveFrame(), UNO_SET_THROW ); - Reference< XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW ); - maDeviceInfo = xDevice->getInfo(); - } - catch( Exception& ) - { - OSL_ENSURE( false, "FilterBaseImpl::FilterBaseImpl - cannot get output device info" ); - } - } - - //! TODO: get colors from system - maSystemPalette[ XML_3dDkShadow ] = 0x716F64; - maSystemPalette[ XML_3dLight ] = 0xF1EFE2; - maSystemPalette[ XML_activeBorder ] = 0xD4D0C8; - maSystemPalette[ XML_activeCaption ] = 0x0054E3; - maSystemPalette[ XML_appWorkspace ] = 0x808080; - maSystemPalette[ XML_background ] = 0x004E98; - maSystemPalette[ XML_btnFace ] = 0xECE9D8; - maSystemPalette[ XML_btnHighlight ] = 0xFFFFFF; - maSystemPalette[ XML_btnShadow ] = 0xACA899; - maSystemPalette[ XML_btnText ] = 0x000000; - maSystemPalette[ XML_captionText ] = 0xFFFFFF; - maSystemPalette[ XML_gradientActiveCaption ] = 0x3D95FF; - maSystemPalette[ XML_gradientInactiveCaption ] = 0xD8E4F8; - maSystemPalette[ XML_grayText ] = 0xACA899; - maSystemPalette[ XML_highlight ] = 0x316AC5; - maSystemPalette[ XML_highlightText ] = 0xFFFFFF; - maSystemPalette[ XML_hotLight ] = 0x000080; - maSystemPalette[ XML_inactiveBorder ] = 0xD4D0C8; - maSystemPalette[ XML_inactiveCaption ] = 0x7A96DF; - maSystemPalette[ XML_inactiveCaptionText ] = 0xD8E4F8; - maSystemPalette[ XML_infoBk ] = 0xFFFFE1; - maSystemPalette[ XML_infoText ] = 0x000000; - maSystemPalette[ XML_menu ] = 0xFFFFFF; - maSystemPalette[ XML_menuBar ] = 0xECE9D8; - maSystemPalette[ XML_menuHighlight ] = 0x316AC5; - maSystemPalette[ XML_menuText ] = 0x000000; - maSystemPalette[ XML_scrollBar ] = 0xD4D0C8; - maSystemPalette[ XML_window ] = 0xFFFFFF; - maSystemPalette[ XML_windowFrame ] = 0x000000; - maSystemPalette[ XML_windowText ] = 0x000000; } void FilterBaseImpl::setDocumentModel( const Reference< XComponent >& rxComponent ) @@ -404,9 +348,9 @@ StorageRef FilterBase::getStorage() const return mxImpl->mxStorage; } -StorageRef FilterBase::openSubStorage( const OUString& rStorageName, bool bCreate ) const +StorageRef FilterBase::openSubStorage( const OUString& rStorageName, bool bCreateMissing ) const { - return mxImpl->mxStorage->openSubStorage( rStorageName, bCreate ); + return mxImpl->mxStorage->openSubStorage( rStorageName, bCreateMissing ); } Reference< XInputStream > FilterBase::openInputStream( const OUString& rStreamName ) const @@ -429,7 +373,7 @@ void FilterBase::commitStorage() const GraphicHelper& FilterBase::getGraphicHelper() const { if( !mxImpl->mxGraphicHelper ) - mxImpl->mxGraphicHelper.reset( new GraphicHelper( mxImpl->mxGlobalFactory ) ); + mxImpl->mxGraphicHelper.reset( implCreateGraphicHelper() ); return *mxImpl->mxGraphicHelper; } @@ -447,42 +391,6 @@ OleObjectHelper& FilterBase::getOleObjectHelper() const return *mxImpl->mxOleObjHelper; } -const DeviceInfo& FilterBase::getDeviceInfo() const -{ - return mxImpl->maDeviceInfo; -} - -sal_Int32 FilterBase::convertScreenPixelX( double fPixelX ) const -{ - return (mxImpl->maDeviceInfo.PixelPerMeterX > 0) ? - static_cast< sal_Int32 >( (fPixelX * 100000.0) / mxImpl->maDeviceInfo.PixelPerMeterX ) : 0; -} - -sal_Int32 FilterBase::convertScreenPixelY( double fPixelY ) const -{ - return (mxImpl->maDeviceInfo.PixelPerMeterY > 0) ? - static_cast< sal_Int32 >( (fPixelY * 100000.0) / mxImpl->maDeviceInfo.PixelPerMeterY ) : 0; -} - -sal_Int32 FilterBase::getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ) const -{ - FilterBaseImpl::SystemPalette::const_iterator aIt = mxImpl->maSystemPalette.find( nToken ); - OSL_ENSURE( aIt != mxImpl->maSystemPalette.end(), "FilterBase::getSystemColor - invalid token identifier" ); - return (aIt == mxImpl->maSystemPalette.end()) ? nDefaultRgb : aIt->second; -} - -sal_Int32 FilterBase::getSchemeColor( sal_Int32 /*nToken*/ ) const -{ - OSL_ENSURE( false, "FilterBase::getSchemeColor - scheme colors not implemented" ); - return API_RGB_TRANSPARENT; -} - -sal_Int32 FilterBase::getPaletteColor( sal_Int32 /*nPaletteIdx*/ ) const -{ - OSL_ENSURE( false, "FilterBase::getPaletteColor - palette colors not implemented" ); - return API_RGB_TRANSPARENT; -} - OUString FilterBase::requestPassword( ::comphelper::IDocPasswordVerifier& rVerifier ) const { ::std::vector< OUString > aDefaultPasswords; @@ -504,7 +412,7 @@ bool FilterBase::importBinaryData( StreamDataSequence& orDataSeq, const OUString // copy the entire stream to the passed sequence SequenceOutputStream aOutStrm( orDataSeq ); - aOutStrm.copyStream( aInStrm ); + aInStrm.copyToStream( aOutStrm ); return true; } @@ -668,6 +576,11 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc mxImpl->mxInteractionHandler = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() ); } +GraphicHelper* FilterBase::implCreateGraphicHelper() const +{ + // default: return base implementation without any special behaviour + return new GraphicHelper( mxImpl->mxGlobalFactory ); +} // ============================================================================ diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index 3997d0b9af6d..12cafc48305a 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -35,10 +35,10 @@ #include "oox/helper/attributelist.hxx" #include "oox/helper/binaryinputstream.hxx" #include "oox/helper/binaryoutputstream.hxx" -#include "oox/helper/olestorage.hxx" #include "oox/helper/zipstorage.hxx" #include "oox/core/fasttokenhandler.hxx" #include "oox/core/namespaces.hxx" +#include "oox/ole/olestorage.hxx" using ::rtl::OUString; using ::com::sun::star::uno::Exception; @@ -485,7 +485,7 @@ Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescript } // try to decrypt an encrypted OLE package - OleStorage aOleStorage( mxFactory, xInStrm, false ); + ::oox::ole::OleStorage aOleStorage( mxFactory, xInStrm, false ); if( aOleStorage.isStorage() ) try { // open the required input streams in the encrypted package diff --git a/oox/source/core/recordparser.cxx b/oox/source/core/recordparser.cxx index b1749ae7be07..8f0de9c2894a 100644 --- a/oox/source/core/recordparser.cxx +++ b/oox/source/core/recordparser.cxx @@ -277,7 +277,6 @@ void RecordParser::parseStream( const RecordInputSource& rInputSource ) throw( S // try to leave a context, there may be other incomplete contexts on the stack if( const RecordInfo* pEndRecInfo = getEndRecordInfo( nRecId ) ) { - (void)pEndRecInfo; // shut warning up in non-debug // finalize contexts without record identifier for context end while( !mxStack->empty() && !mxStack->hasCurrentEndRecId() ) mxStack->popContext(); @@ -288,7 +287,7 @@ void RecordParser::parseStream( const RecordInputSource& rInputSource ) throw( S if( xCurrContext.is() ) { // context end record may contain some data, handle it as simple record - aRecStrm.seek( 0 ); + aRecStrm.seekToStart(); xCurrContext->startRecord( nRecId, aRecStrm ); xCurrContext->endRecord( nRecId ); } @@ -303,7 +302,7 @@ void RecordParser::parseStream( const RecordInputSource& rInputSource ) throw( S ContextHandlerRef xCurrContext = mxStack->getCurrentContext(); if( xCurrContext.is() ) { - aRecStrm.seek( 0 ); + aRecStrm.seekToStart(); xCurrContext = xCurrContext->createRecordContext( nRecId, aRecStrm ); } // track all context identifiers on the stack (do not push simple records) @@ -314,7 +313,7 @@ void RecordParser::parseStream( const RecordInputSource& rInputSource ) throw( S if( xCurrContext.is() ) { // import the record - aRecStrm.seek( 0 ); + aRecStrm.seekToStart(); xCurrContext->startRecord( nRecId, aRecStrm ); // end simple records (context records are finished in ContextStack::popContext) if( !pStartRecInfo ) diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx index da7daa9a058e..97453d5bddb0 100644 --- a/oox/source/docprop/docprophandler.cxx +++ b/oox/source/docprop/docprophandler.cxx @@ -179,7 +179,7 @@ uno::Sequence< ::rtl::OUString > OOXMLDocPropHandler::GetKeywordsSet( const ::rt case (sal_Unicode)',': case (sal_Unicode)';': case (sal_Unicode)':': - case (sal_Unicode)' ': + case (sal_Unicode)'\t': // this is a delimiter // unfortunately I did not find any specification for the possible delimiters if ( aResult[nCounter].getLength() ) diff --git a/oox/source/drawingml/chart/chartdrawingfragment.cxx b/oox/source/drawingml/chart/chartdrawingfragment.cxx index 9df064125457..fcc350b583c3 100644 --- a/oox/source/drawingml/chart/chartdrawingfragment.cxx +++ b/oox/source/drawingml/chart/chartdrawingfragment.cxx @@ -2,14 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: chartdrawingfragment.cxx,v $ - * - * $Revision: 1.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index 08ca5f44bec3..5b898d4da6ed 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -847,7 +847,7 @@ sal_Int32 DetailFormatterBase::getPhColor( sal_Int32 nSeriesIdx ) const Color aColor; aColor.setSrgbClr( nPhClr ); aColor.addChartTintTransformation( fShadeTint ); - nPhClr = aColor.getColor( mrData.mrFilter ); + nPhClr = aColor.getColor( mrData.mrFilter.getGraphicHelper() ); } return nPhClr; @@ -859,7 +859,7 @@ sal_Int32 DetailFormatterBase::getSchemeColor( sal_Int32 nColorToken, sal_Int32 aColor.setSchemeClr( nColorToken ); if( nModToken != XML_TOKEN_INVALID ) aColor.addTransformation( nModToken, nModValue ); - return aColor.getColor( mrData.mrFilter ); + return aColor.getColor( mrData.mrFilter.getGraphicHelper() ); } // ============================================================================ @@ -888,7 +888,7 @@ void LineFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Sh aLineProps.assignUsed( *mxAutoLine ); if( rxShapeProp.is() ) aLineProps.assignUsed( rxShapeProp->getLineProperties() ); - aLineProps.pushToPropSet( rPropSet, mrData.mrFilter, mrData.maModelObjHelper, mrLinePropIds, getPhColor( nSeriesIdx ) ); + aLineProps.pushToPropSet( rPropSet, mrData.maModelObjHelper, mrData.mrFilter.getGraphicHelper(), mrLinePropIds, getPhColor( nSeriesIdx ) ); } // ============================================================================ @@ -916,7 +916,7 @@ void FillFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Sh aFillProps.assignUsed( rxShapeProp->getFillProperties() ); if( pPicOptions ) lclConvertPictureOptions( aFillProps, *pPicOptions ); - aFillProps.pushToPropSet( rPropSet, mrData.mrFilter, mrData.maModelObjHelper, mrFillPropIds, 0, getPhColor( nSeriesIdx ) ); + aFillProps.pushToPropSet( rPropSet, mrData.maModelObjHelper, mrData.mrFilter.getGraphicHelper(), mrFillPropIds, 0, getPhColor( nSeriesIdx ) ); } // ============================================================================ diff --git a/oox/source/drawingml/clrschemecontext.cxx b/oox/source/drawingml/clrschemecontext.cxx index d91f15c56e18..996ddef2ab0f 100644 --- a/oox/source/drawingml/clrschemecontext.cxx +++ b/oox/source/drawingml/clrschemecontext.cxx @@ -73,7 +73,7 @@ clrSchemeColorContext::clrSchemeColorContext( ContextHandler& rParent, ClrScheme clrSchemeColorContext::~clrSchemeColorContext() { - mrClrScheme.setColor( mnColorToken, getColor( getFilter() ) ); + mrClrScheme.setColor( mnColorToken, getColor( getFilter().getGraphicHelper() ) ); } clrSchemeContext::clrSchemeContext( ContextHandler& rParent, ClrScheme& rClrScheme ) : diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index ebf62f17a01e..8653d787517d 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -30,8 +30,8 @@ #include #include "tokens.hxx" #include "oox/helper/containerhelper.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/core/namespaces.hxx" -#include "oox/core/filterbase.hxx" #include "oox/drawingml/drawingmltypes.hxx" using ::rtl::OUString; @@ -350,7 +350,7 @@ void Color::clearTransparence() mnAlpha = MAX_PERCENT; } -sal_Int32 Color::getColor( const ::oox::core::FilterBase& rFilter, sal_Int32 nPhClr ) const +sal_Int32 Color::getColor( const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const { /* Special handling for theme style list placeholder colors (state COLOR_PH), Color::getColor() may be called with different placeholder @@ -368,10 +368,10 @@ sal_Int32 Color::getColor( const ::oox::core::FilterBase& rFilter, sal_Int32 nPh case COLOR_CRGB: break; // nothing to do case COLOR_HSL: break; // nothing to do - case COLOR_SCHEME: setResolvedRgb( rFilter.getSchemeColor( mnC1 ) ); break; - case COLOR_PALETTE: setResolvedRgb( rFilter.getPaletteColor( mnC1 ) ); break; - case COLOR_SYSTEM: setResolvedRgb( rFilter.getSystemColor( mnC1, mnC2 ) ); break; - case COLOR_PH: setResolvedRgb( nPhClr ); bIsPh = true; break; + case COLOR_SCHEME: setResolvedRgb( rGraphicHelper.getSchemeColor( mnC1 ) ); break; + case COLOR_PALETTE: setResolvedRgb( rGraphicHelper.getPaletteColor( mnC1 ) ); break; + case COLOR_SYSTEM: setResolvedRgb( rGraphicHelper.getSystemColor( mnC1, mnC2 ) ); break; + case COLOR_PH: setResolvedRgb( nPhClr ); bIsPh = true; break; case COLOR_FINAL: return mnC1; } diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx index 28e84e72e2cc..4459c5936cfa 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -39,7 +39,6 @@ #include using rtl::OUString; -using namespace ::oox::core; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -60,8 +59,8 @@ void CustomShapeProperties::apply( const CustomShapePropertiesPtr& /* rSourceCus // not sure if this needs to be implemented } -void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFilterBase */, - const Reference < XPropertySet >& xPropSet, const Reference < XShape > & xShape ) const +void CustomShapeProperties::pushToPropSet( + const Reference < XPropertySet >& xPropSet, const Reference < XShape > & xShape ) const { if ( maShapePresetType.getLength() ) { diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 0e4d56a6634b..168055935104 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -41,7 +41,6 @@ #include "oox/helper/modelobjecthelper.hxx" #include "oox/helper/propertymap.hxx" #include "oox/helper/propertyset.hxx" -#include "oox/core/filterbase.hxx" #include "oox/drawingml/drawingmltypes.hxx" using namespace ::com::sun::star; @@ -54,7 +53,6 @@ using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::geometry::IntegerRectangle2D; -using ::oox::core::FilterBase; namespace oox { namespace drawingml { @@ -105,30 +103,26 @@ RectanglePoint lclGetRectanglePoint( sal_Int32 nToken ) return RectanglePoint_LEFT_TOP; } -const awt::Size lclGetOriginalSize( const FilterBase& rFilter, const Reference< XGraphic >& rxGraphic ) +const awt::Size lclGetOriginalSize( const GraphicHelper& rGraphicHelper, const Reference< XGraphic >& rxGraphic ) { - awt::Size aSize100thMM( 0, 0 ); + awt::Size aSizeHmm( 0, 0 ); try { Reference< beans::XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW ); - if( xGraphicPropertySet->getPropertyValue( CREATE_OUSTRING( "Size100thMM" ) ) >>= aSize100thMM ) + if( xGraphicPropertySet->getPropertyValue( CREATE_OUSTRING( "Size100thMM" ) ) >>= aSizeHmm ) { - if( !aSize100thMM.Width && !aSize100thMM.Height ) + if( !aSizeHmm.Width && !aSizeHmm.Height ) { // MAPMODE_PIXEL USED :-( awt::Size aSourceSizePixel( 0, 0 ); if( xGraphicPropertySet->getPropertyValue( CREATE_OUSTRING( "SizePixel" ) ) >>= aSourceSizePixel ) - { - aSize100thMM = awt::Size( - rFilter.convertScreenPixelX( aSourceSizePixel.Width ), - rFilter.convertScreenPixelY( aSourceSizePixel.Height ) ); - } + aSizeHmm = rGraphicHelper.convertScreenPixelToHmm( aSourceSizePixel ); } } } catch( Exception& ) { } - return aSize100thMM; + return aSizeHmm; } } // namespace @@ -221,8 +215,8 @@ Color FillProperties::getBestSolidColor() const return aSolidColor; } -void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter, - ModelObjectHelper& rModelObjHelper, const FillPropertyIds& rPropIds, +void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds, sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const { if( moFillType.has() ) @@ -237,7 +231,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi case XML_solidFill: if( maFillColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ FillColorId ], maFillColor.getColor( rFilter, nPhClr ) ); + rPropMap.setProperty( rPropIds[ FillColorId ], maFillColor.getColor( rGraphicHelper, nPhClr ) ); if( maFillColor.hasTransparence() ) rPropMap.setProperty( rPropIds[ FillTransparenceId ], maFillColor.getTransparence() ); eFillStyle = FillStyle_SOLID; @@ -256,8 +250,8 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi size_t nColorCount = maGradientProps.maGradientStops.size(); if( nColorCount > 1 ) { - aGradient.StartColor = maGradientProps.maGradientStops.begin()->second.getColor( rFilter, nPhClr ); - aGradient.EndColor = maGradientProps.maGradientStops.rbegin()->second.getColor( rFilter, nPhClr ); + aGradient.StartColor = maGradientProps.maGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr ); + aGradient.EndColor = maGradientProps.maGradientStops.rbegin()->second.getColor( rGraphicHelper, nPhClr ); } // "rotate with shape" not set, or set to false -> do not rotate @@ -288,7 +282,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi { GradientFillProperties::GradientStopMap::const_iterator aIt = maGradientProps.maGradientStops.begin(); // API StartColor is inner color in axial gradient - aGradient.StartColor = (++aIt)->second.getColor( rFilter, nPhClr ); + aGradient.StartColor = (++aIt)->second.getColor( rGraphicHelper, nPhClr ); } nDmlAngle = maGradientProps.moShadeAngle.get( 0 ) - nShapeRotation; } @@ -319,7 +313,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi { // TODO: "rotate with shape" is not possible with our current core - OUString aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject( maBlipProps.mxGraphic ); + OUString aGraphicUrl = rGraphicHelper.createGraphicObject( maBlipProps.mxGraphic ); if( aGraphicUrl.getLength() > 0 ) { // push bitmap or named bitmap to property map @@ -353,7 +347,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) ); rPropMap.setProperty( rPropIds[ FillBitmapRectanglePointId ], eRectPoint ); - awt::Size aOriginalSize = lclGetOriginalSize( rFilter, maBlipProps.mxGraphic ); + awt::Size aOriginalSize = lclGetOriginalSize( rGraphicHelper, maBlipProps.mxGraphic ); if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) ) { // size of one bitmap tile (given as 1/1000 percent of bitmap size), convert to 1/100 mm @@ -381,7 +375,7 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi Color aColor = getBestSolidColor(); if( aColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ FillColorId ], aColor.getColor( rFilter, nPhClr ) ); + rPropMap.setProperty( rPropIds[ FillColorId ], aColor.getColor( rGraphicHelper, nPhClr ) ); if( aColor.hasTransparence() ) rPropMap.setProperty( rPropIds[ FillTransparenceId ], aColor.getTransparence() ); eFillStyle = FillStyle_SOLID; @@ -400,12 +394,12 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi } } -void FillProperties::pushToPropSet( PropertySet& rPropSet, const FilterBase& rFilter, - ModelObjectHelper& rModelObjHelper, const FillPropertyIds& rPropIds, +void FillProperties::pushToPropSet( PropertySet& rPropSet, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds, sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const { PropertyMap aPropMap; - pushToPropMap( aPropMap, rFilter, rModelObjHelper, rPropIds, nShapeRotation, nPhClr ); + pushToPropMap( aPropMap, rModelObjHelper, rGraphicHelper, rPropIds, nShapeRotation, nPhClr ); rPropSet.setProperties( aPropMap ); } @@ -416,7 +410,7 @@ void GraphicProperties::assignUsed( const GraphicProperties& rSourceProps ) maBlipProps.assignUsed( rSourceProps.maBlipProps ); } -void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter, sal_Int32 nPhClr ) const +void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const { if( maBlipProps.mxGraphic.is() ) { @@ -424,8 +418,8 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& Reference< XGraphic > xGraphic = maBlipProps.mxGraphic; if( maBlipProps.maColorChangeFrom.isUsed() && maBlipProps.maColorChangeTo.isUsed() ) { - sal_Int32 nFromColor = maBlipProps.maColorChangeFrom.getColor( rFilter, nPhClr ); - sal_Int32 nToColor = maBlipProps.maColorChangeTo.getColor( rFilter, nPhClr ); + sal_Int32 nFromColor = maBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr ); + sal_Int32 nToColor = maBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr ); if ( (nFromColor != nToColor) || maBlipProps.maColorChangeTo.hasTransparence() ) try { sal_Int16 nToTransparence = maBlipProps.maColorChangeTo.getTransparence(); @@ -438,7 +432,7 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& } } - OUString aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject( xGraphic ); + OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic ); if( aGraphicUrl.getLength() > 0 ) rPropMap[ PROP_GraphicURL ] <<= aGraphicUrl; } @@ -461,10 +455,10 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rPropMap[ PROP_AdjustContrast ] <<= nContrast; } -void GraphicProperties::pushToPropSet( PropertySet& rPropSet, const FilterBase& rFilter, sal_Int32 nPhClr ) const +void GraphicProperties::pushToPropSet( PropertySet& rPropSet, const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const { PropertyMap aPropMap; - pushToPropMap( aPropMap, rFilter, nPhClr ); + pushToPropMap( aPropMap, rGraphicHelper, nPhClr ); rPropSet.setProperties( aPropMap ); } diff --git a/oox/source/drawingml/fillpropertiesgroupcontext.cxx b/oox/source/drawingml/fillpropertiesgroupcontext.cxx index 454222bc52e6..8adffb265240 100644 --- a/oox/source/drawingml/fillpropertiesgroupcontext.cxx +++ b/oox/source/drawingml/fillpropertiesgroupcontext.cxx @@ -270,12 +270,12 @@ Reference< XFastContextHandler > FillPropertiesContext::createFastChildContext( { switch( nElement ) { - case A_TOKEN( noFill ): { rFillProps.moFillType = getToken( nElement ); return 0; }; - case A_TOKEN( solidFill ): { rFillProps.moFillType = getToken( nElement ); return new SolidFillContext( rParent, rxAttribs, rFillProps ); }; - case A_TOKEN( gradFill ): { rFillProps.moFillType = getToken( nElement ); return new GradientFillContext( rParent, rxAttribs, rFillProps.maGradientProps ); }; - case A_TOKEN( pattFill ): { rFillProps.moFillType = getToken( nElement ); return new PatternFillContext( rParent, rxAttribs, rFillProps.maPatternProps ); }; - case A_TOKEN( blipFill ): { rFillProps.moFillType = getToken( nElement ); return new BlipFillContext( rParent, rxAttribs, rFillProps.maBlipProps ); }; - case A_TOKEN( grpFill ): { rFillProps.moFillType = getToken( nElement ); return 0; }; // TODO + case A_TOKEN( noFill ): { rFillProps.moFillType = getToken( nElement ); return 0; }; + case A_TOKEN( solidFill ): { rFillProps.moFillType = getToken( nElement ); return new SolidFillContext( rParent, rxAttribs, rFillProps ); }; + case A_TOKEN( gradFill ): { rFillProps.moFillType = getToken( nElement ); return new GradientFillContext( rParent, rxAttribs, rFillProps.maGradientProps ); }; + case A_TOKEN( pattFill ): { rFillProps.moFillType = getToken( nElement ); return new PatternFillContext( rParent, rxAttribs, rFillProps.maPatternProps ); }; + case A_TOKEN( blipFill ): { rFillProps.moFillType = getToken( nElement ); return new BlipFillContext( rParent, rxAttribs, rFillProps.maBlipProps ); }; + case A_TOKEN( grpFill ): { rFillProps.moFillType = getToken( nElement ); return 0; }; // TODO } return 0; } diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index 4a9a0d04e1e5..9f23cf466d30 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -37,10 +37,10 @@ #include #include "properties.hxx" #include "tokens.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/helper/modelobjecthelper.hxx" #include "oox/helper/propertymap.hxx" #include "oox/helper/propertyset.hxx" -#include "oox/core/filterbase.hxx" #include "oox/core/namespaces.hxx" #include "oox/drawingml/drawingmltypes.hxx" @@ -52,7 +52,6 @@ using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::awt::Point; using ::com::sun::star::container::XNameContainer; -using ::oox::core::FilterBase; namespace oox { namespace drawingml { @@ -395,8 +394,8 @@ void LineProperties::assignUsed( const LineProperties& rSourceProps ) moLineJoint.assignIfUsed( rSourceProps.moLineJoint ); } -void LineProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter, - ModelObjectHelper& rModelObjHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const +void LineProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const { // line fill type must exist, otherwise ignore other properties if( maLineFill.moFillType.has() ) @@ -453,7 +452,7 @@ void LineProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi Color aLineColor = maLineFill.getBestSolidColor(); if( aLineColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ LineColorId ], aLineColor.getColor( rFilter, nPhClr ) ); + rPropMap.setProperty( rPropIds[ LineColorId ], aLineColor.getColor( rGraphicHelper, nPhClr ) ); if( aLineColor.hasTransparence() ) rPropMap.setProperty( rPropIds[ LineTransparenceId ], aLineColor.getTransparence() ); } @@ -464,11 +463,11 @@ void LineProperties::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFi } } -void LineProperties::pushToPropSet( PropertySet& rPropSet, const FilterBase& rFilter, - ModelObjectHelper& rModelObjHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const +void LineProperties::pushToPropSet( PropertySet& rPropSet, ModelObjectHelper& rModelObjHelper, + const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const { PropertyMap aPropMap; - pushToPropMap( aPropMap, rFilter, rModelObjHelper, rPropIds, nPhClr ); + pushToPropMap( aPropMap, rModelObjHelper, rGraphicHelper, rPropIds, nPhClr ); rPropSet.setProperties( aPropMap ); } diff --git a/oox/source/drawingml/linepropertiescontext.cxx b/oox/source/drawingml/linepropertiescontext.cxx index 200af2eb6fb5..a2cf4111a524 100644 --- a/oox/source/drawingml/linepropertiescontext.cxx +++ b/oox/source/drawingml/linepropertiescontext.cxx @@ -93,7 +93,7 @@ Reference< XFastContextHandler > LinePropertiesContext::createFastChildContext( case A_TOKEN( headEnd ): // CT_LineEndProperties case A_TOKEN( tailEnd ): // CT_LineEndProperties - { // ST_LineEndType + { // ST_LineEndType bool bTailEnd = nElement == A_TOKEN( tailEnd ); LineArrowProperties& rArrowProps = bTailEnd ? mrLineProperties.maEndArrow : mrLineProperties.maStartArrow; rArrowProps.moArrowType = aAttribs.getToken( XML_type ); diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index cab64f11c166..e017ce0188f9 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -376,6 +376,9 @@ Reference< XShape > Shape::createAndInsert( } } + ModelObjectHelper& rModelObjectHelper = rFilterBase.getModelObjectHelper(); + const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper(); + LineProperties aLineProperties; aLineProperties.maLineFill.moFillType = XML_noFill; sal_Int32 nLinePhClr = -1; @@ -389,19 +392,19 @@ Reference< XShape > Shape::createAndInsert( { if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) ) aLineProperties.assignUsed( *pLineProps ); - nLinePhClr = pLineRef->maPhClr.getColor( rFilterBase ); + nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper ); } if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) ) { if( const FillProperties* pFillProps = pTheme->getFillStyle( pFillRef->mnThemedIdx ) ) aFillProperties.assignUsed( *pFillProps ); - nFillPhClr = pFillRef->maPhClr.getColor( rFilterBase ); + nFillPhClr = pFillRef->maPhClr.getColor( rGraphicHelper ); } // if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_fillRef ) ) // { // if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) ) // aEffectProperties.assignUsed( *pEffectProps ); -// nEffectPhClr = pEffectRef->maPhClr.getColor( rFilterBase ); +// nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper ); // } } @@ -420,11 +423,11 @@ Reference< XShape > Shape::createAndInsert( // applying properties PropertySet aPropSet( xSet ); if ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.GraphicObjectShape" ) ) - mpGraphicPropertiesPtr->pushToPropSet( aPropSet, rFilterBase ); + mpGraphicPropertiesPtr->pushToPropSet( aPropSet, rGraphicHelper ); if ( mpTablePropertiesPtr.get() && ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.TableShape" ) ) ) mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle ); - aFillProperties.pushToPropSet( aPropSet, rFilterBase, rFilterBase.getModelObjectHelper(), FillProperties::DEFAULT_IDS, mnRotation, nFillPhClr ); - aLineProperties.pushToPropSet( aPropSet, rFilterBase, rFilterBase.getModelObjectHelper(), LineProperties::DEFAULT_IDS, nLinePhClr ); + aFillProperties.pushToPropSet( aPropSet, rModelObjectHelper, rGraphicHelper, FillProperties::DEFAULT_IDS, mnRotation, nFillPhClr ); + aLineProperties.pushToPropSet( aPropSet, rModelObjectHelper, rGraphicHelper, LineProperties::DEFAULT_IDS, nLinePhClr ); // applying autogrowheight property before setting shape size, because // the shape size might be changed if currently autogrowheight is true @@ -440,7 +443,7 @@ Reference< XShape > Shape::createAndInsert( aPropSet.setProperties( aShapeProperties ); if( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.CustomShape" ) ) - mpCustomShapePropertiesPtr->pushToPropSet( rFilterBase, xSet, mxShape ); + mpCustomShapePropertiesPtr->pushToPropSet( xSet, mxShape ); // in some cases, we don't have any text body. if( getTextBody() ) diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index 1684414eea2b..ee3ac495f4d6 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -80,7 +80,7 @@ void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase, if( rLineProperties.maLineFill.moFillType.differsFrom( XML_noFill ) ) { Color aColor = rLineProperties.maLineFill.getBestSolidColor(); - aBorderLine.Color = aColor.getColor( rFilterBase ); + aBorderLine.Color = aColor.getColor( rFilterBase.getGraphicHelper() ); aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 4 ); aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.get( 0 ) ) / 4 ); aBorderLine.LineDistance = 0; @@ -360,7 +360,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo aFillProperties.assignUsed( maFillProperties ); PropertySet aPropSet( xPropSet ); // TODO: phClr? - aFillProperties.pushToPropSet( aPropSet, rFilterBase, rFilterBase.getModelObjectHelper() ); + aFillProperties.pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), rFilterBase.getGraphicHelper() ); } } } } diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx index aa08218053ac..4dbd632b2191 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -98,7 +98,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil // symbol font not supported if( maCharColor.isUsed() ) - rPropMap[ PROP_CharColor ] <<= maCharColor.getColor( rFilter ); + rPropMap[ PROP_CharColor ] <<= maCharColor.getColor( rFilter.getGraphicHelper() ); if( moLang.has() && (moLang.get().getLength() > 0) ) { @@ -144,7 +144,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil if( moUnderline.has() && maUnderlineColor.isUsed() && !bUnderlineFillFollowText ) { rPropMap[ PROP_CharUnderlineHasColor ] <<= true; - rPropMap[ PROP_CharUnderlineColor ] <<= maUnderlineColor.getColor( rFilter ); + rPropMap[ PROP_CharUnderlineColor ] <<= maUnderlineColor.getColor( rFilter.getGraphicHelper() ); } } diff --git a/oox/source/drawingml/textfont.cxx b/oox/source/drawingml/textfont.cxx index f20c9b53511b..8d58787e544a 100644 --- a/oox/source/drawingml/textfont.cxx +++ b/oox/source/drawingml/textfont.cxx @@ -63,7 +63,7 @@ sal_Int16 lclGetFontFamily( sal_Int32 nOoxValue ) TextFont::TextFont() : mnPitch( 0 ), - mnCharset( 0 ) + mnCharset( WINDOWS_CHARSET_ANSI ) { } @@ -72,7 +72,7 @@ void TextFont::setAttributes( const AttributeList& rAttribs ) maTypeface = rAttribs.getString( XML_typeface, OUString() ); maPanose = rAttribs.getString( XML_panose, OUString() ); mnPitch = rAttribs.getInteger( XML_pitchFamily, 0 ); - mnCharset = rAttribs.getInteger( XML_charset, 1 ); + mnCharset = rAttribs.getInteger( XML_charset, WINDOWS_CHARSET_DEFAULT ); } void TextFont::assignIfUsed( const TextFont& rTextFont ) diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx index 3416d4918e7b..2f5954168d37 100644 --- a/oox/source/drawingml/textparagraphproperties.cxx +++ b/oox/source/drawingml/textparagraphproperties.cxx @@ -322,7 +322,7 @@ void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase& rFilterBase, P if ( maStyleName.hasValue() ) rPropMap[ PROP_CharStyleName ] <<= maStyleName; if ( maBulletColorPtr->isUsed() ) - rPropMap[ PROP_BulletColor ] <<= maBulletColorPtr->getColor( rFilterBase ); + rPropMap[ PROP_BulletColor ] <<= maBulletColorPtr->getColor( rFilterBase.getGraphicHelper() ); } TextParagraphProperties::TextParagraphProperties() diff --git a/oox/source/dump/biffdumper.cxx b/oox/source/dump/biffdumper.cxx index 21aa341107fa..ea1944d935a4 100644 --- a/oox/source/dump/biffdumper.cxx +++ b/oox/source/dump/biffdumper.cxx @@ -30,8 +30,8 @@ #include #include #include "oox/dump/oledumper.hxx" -#include "oox/helper/olestorage.hxx" #include "oox/core/filterbase.hxx" +#include "oox/ole/olestorage.hxx" #include "oox/xls/biffdetector.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/formulabase.hxx" @@ -100,30 +100,30 @@ const sal_uInt16 BIFF_PT_NOSTRING = 0xFFFF; namespace { -void lclDumpDffClientPos( Output& rOut, BinaryInputStream& rStrm, const String& rName, sal_uInt16 nSubScale ) +void lclDumpDffClientPos( const OutputRef& rxOut, const BinaryInputStreamRef& rxStrm, const String& rName, sal_uInt16 nSubScale ) { - MultiItemsGuard aMultiGuard( rOut ); - TableGuard aTabGuard( rOut, 17 ); + MultiItemsGuard aMultiGuard( rxOut ); + TableGuard aTabGuard( rxOut, 17 ); { - sal_uInt16 nPos = rStrm.readuInt16(); - ItemGuard aItem( rOut, rName ); - rOut.writeDec( nPos ); + sal_uInt16 nPos = rxStrm->readuInt16(); + ItemGuard aItem( rxOut, rName ); + rxOut->writeDec( nPos ); } { - sal_uInt16 nSubUnits = rStrm.readuInt16(); - ItemGuard aItem( rOut, "sub-units" ); - rOut.writeDec( nSubUnits ); - rOut.writeChar( '/' ); - rOut.writeDec( nSubScale ); + sal_uInt16 nSubUnits = rxStrm->readuInt16(); + ItemGuard aItem( rxOut, "sub-units" ); + rxOut->writeDec( nSubUnits ); + rxOut->writeChar( '/' ); + rxOut->writeDec( nSubScale ); } } -void lclDumpDffClientRect( Output& rOut, BinaryInputStream& rStrm ) +void lclDumpDffClientRect( const OutputRef& rxOut, const BinaryInputStreamRef& rxStrm ) { - lclDumpDffClientPos( rOut, rStrm, "start-col", 1024 ); - lclDumpDffClientPos( rOut, rStrm, "start-row", 256 ); - lclDumpDffClientPos( rOut, rStrm, "end-col", 1024 ); - lclDumpDffClientPos( rOut, rStrm, "end-row", 256 ); + lclDumpDffClientPos( rxOut, rxStrm, "start-col", 1024 ); + lclDumpDffClientPos( rxOut, rxStrm, "start-row", 256 ); + lclDumpDffClientPos( rxOut, rxStrm, "end-col", 1024 ); + lclDumpDffClientPos( rxOut, rxStrm, "end-row", 256 ); } } // namespace @@ -138,7 +138,7 @@ BiffDffStreamObject::BiffDffStreamObject( const OutputObjectBase& rParent, const void BiffDffStreamObject::implDumpClientAnchor() { dumpHex< sal_uInt16 >( "flags", "DFF-CLIENTANCHOR-FLAGS" ); - lclDumpDffClientRect( out(), in() ); + lclDumpDffClientRect( mxOut, mxStrm ); } // ============================================================================ @@ -161,15 +161,16 @@ void BiffCtlsStreamObject::implDump() { if( mnLength > 0 ) { - out().emptyLine(); + mxOut->emptyLine(); writeEmptyItem( "CTLS-START" ); { - IndentGuard aIndGuard( out() ); - in().seek( mnStartPos ); - OcxGuidControlObject( *this, mnLength ).dump(); + IndentGuard aIndGuard( mxOut ); + mxStrm->seek( mnStartPos ); + RelativeInputStreamRef xRelStrm( new RelativeInputStream( *mxStrm, mnLength ) ); + FormControlStreamObject( *this, xRelStrm ).dump(); } writeEmptyItem( "CTLS-END" ); - out().emptyLine(); + mxOut->emptyLine(); } } @@ -315,7 +316,7 @@ bool BiffObjectBase::implStartRecord( BinaryInputStream&, sal_Int64& ornRecPos, switch( mnLastRecId ) { case BIFF_ID_CHBEGIN: - out().incIndent(); + mxOut->incIndent(); break; } @@ -351,7 +352,7 @@ bool BiffObjectBase::implStartRecord( BinaryInputStream&, sal_Int64& ornRecPos, mxBiffStrm->enableDecoder( false ); break; case BIFF_ID_CHEND: - out().decIndent(); + mxOut->decIndent(); break; } @@ -416,10 +417,10 @@ void BiffObjectBase::writeFontPortions( const FontPortionModelList& rPortions ) if( !rPortions.empty() ) { writeDecItem( "font-count", static_cast< sal_uInt32 >( rPortions.size() ) ); - TableGuard aTabGuard( out(), 14 ); + TableGuard aTabGuard( mxOut, 14 ); for( FontPortionModelList::const_iterator aIt = rPortions.begin(), aEnd = rPortions.end(); aIt != aEnd; ++aIt ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeDecItem( "char-pos", aIt->mnPos ); writeDecItem( "font-idx", aIt->mnFontId, "FONTNAMES" ); } @@ -497,7 +498,7 @@ OUString BiffObjectBase::dumpUniString( const String& rName, BiffStringFlags nFl // #122185# bRich flag may be set, but format runs may be missing if( nFontCount > 0 ) { - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); FontPortionModelList aPortions; aPortions.importPortions( *mxBiffStrm, nFontCount, BIFF_FONTPORTION_16BIT ); writeFontPortions( aPortions ); @@ -508,7 +509,7 @@ OUString BiffObjectBase::dumpUniString( const String& rName, BiffStringFlags nFl if( nPhoneticSize > 0 ) { sal_Int64 nStrmPos = mxBiffStrm->tell(); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); writeEmptyItem( "phonetic-data" ); dumpUnused( 2 ); dumpDec< sal_uInt16 >( "size" ); @@ -520,7 +521,7 @@ OUString BiffObjectBase::dumpUniString( const String& rName, BiffStringFlags nFl if( nLen == 0 ) dumpUnused( 2 ); for( sal_uInt16 nPortion = 0; !mxBiffStrm->isEof() && (nPortion < nCount); ++nPortion ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); dumpDec< sal_uInt16 >( "first-portion-char" ); dumpDec< sal_uInt16 >( "first-main-char" ); dumpDec< sal_uInt16 >( "main-char-count" ); @@ -560,7 +561,7 @@ rtl_TextEncoding BiffObjectBase::dumpCodePage( const String& rName ) void BiffObjectBase::dumpFormulaResult( const String& rName ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); sal_uInt8 pnResult[ 8 ]; mxBiffStrm->readMemory( pnResult, 8 ); writeArrayItem( rName( "result" ), pnResult, 8 ); @@ -638,8 +639,7 @@ void BiffObjectBase::dumpRangeList( const String& rName, bool bCol16Bit, bool bR void BiffObjectBase::dumpConstArrayHeader( sal_uInt32& rnCols, sal_uInt32& rnRows ) { - Output& rOut = out(); - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); rnCols = dumpDec< sal_uInt8 >( "width" ); rnRows = dumpDec< sal_uInt16 >( "height" ); switch( getBiff() ) @@ -651,18 +651,17 @@ void BiffObjectBase::dumpConstArrayHeader( sal_uInt32& rnCols, sal_uInt32& rnRow case BIFF8: ++rnCols; ++rnRows; break; case BIFF_UNKNOWN: break; } - ItemGuard aItem( rOut, "size" ); - rOut.writeDec( rnCols ); - rOut.writeChar( 'x' ); - rOut.writeDec( rnRows ); + ItemGuard aItem( mxOut, "size" ); + mxOut->writeDec( rnCols ); + mxOut->writeChar( 'x' ); + mxOut->writeDec( rnRows ); aItem.cont(); - rOut.writeDec( rnCols * rnRows ); + mxOut->writeDec( rnCols * rnRows ); } OUString BiffObjectBase::dumpConstValue( sal_Unicode cStrQuote ) { - Output& rOut = out(); - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); OUStringBuffer aValue; switch( dumpDec< sal_uInt8 >( "type", mxConstType ) ) { @@ -672,7 +671,7 @@ OUString BiffObjectBase::dumpConstValue( sal_Unicode cStrQuote ) break; case BIFF_DATATYPE_DOUBLE: dumpDec< double >( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); break; case BIFF_DATATYPE_STRING: aValue.append( dumpString( "value", BIFF_STR_8BITLENGTH ) ); @@ -680,12 +679,12 @@ OUString BiffObjectBase::dumpConstValue( sal_Unicode cStrQuote ) break; case BIFF_DATATYPE_BOOL: dumpBoolean( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); dumpUnused( 7 ); break; case BIFF_DATATYPE_ERROR: dumpErrorCode( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); dumpUnused( 7 ); break; } @@ -712,22 +711,22 @@ void BiffObjectBase::dumpFrHeader( bool bWithFlags, bool bWithRange ) void BiffObjectBase::dumpDffClientRect() { - lclDumpDffClientRect( out(), in() ); + lclDumpDffClientRect( mxOut, mxStrm ); } void BiffObjectBase::dumpEmbeddedDff() { - out().decIndent(); + mxOut->decIndent(); writeEmptyItem( "EMBEDDED-DFF-START" ); - out().incIndent(); + mxOut->incIndent(); mxDffObj->dump(); - out().emptyLine(); - out().decIndent(); + mxOut->emptyLine(); + mxOut->decIndent(); writeEmptyItem( "EMBEDDED-DFF-END" ); - out().incIndent(); + mxOut->incIndent(); } -void BiffObjectBase::dumpOcxControl() +void BiffObjectBase::dumpControl() { sal_uInt32 nStartPos = dumpHex< sal_uInt32 >( "ctls-stream-pos", "CONV-DEC" ); sal_uInt32 nLength = dumpHex< sal_uInt32 >( "ctls-stream-length", "CONV-DEC" ); @@ -784,26 +783,25 @@ void FormulaObject::dumpNameFormula( const String& rName ) void FormulaObject::implDump() { { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( maName ); writeDecItem( "formula-size", mnSize ); } if( mnSize == 0 ) return; - BinaryInputStream& rStrm = in(); - sal_Int64 nStartPos = rStrm.tell(); - sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, rStrm.getLength() ); + sal_Int64 nStartPos = mxStrm->tell(); + sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, mxStrm->getLength() ); bool bValid = mxTokens.get(); mxStack.reset( new FormulaStack ); maAddData.clear(); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); { - TableGuard aTabGuard( out(), 8, 18 ); - while( bValid && !rStrm.isEof() && (rStrm.tell() < nEndPos) ) + TableGuard aTabGuard( mxOut, 8, 18 ); + while( bValid && !mxStrm->isEof() && (mxStrm->tell() < nEndPos) ) { - MultiItemsGuard aMultiGuard( out() ); - writeHexItem( EMPTY_STRING, static_cast< sal_uInt16 >( rStrm.tell() - nStartPos ) ); + MultiItemsGuard aMultiGuard( mxOut ); + writeHexItem( EMPTY_STRING, static_cast< sal_uInt16 >( mxStrm->tell() - nStartPos ) ); sal_uInt8 nTokenId = dumpHex< sal_uInt8 >( EMPTY_STRING, mxTokens ); bValid = mxTokens->hasName( nTokenId ); if( bValid ) @@ -881,7 +879,7 @@ void FormulaObject::implDump() } } } - bValid = nEndPos == rStrm.tell(); + bValid = nEndPos == mxStrm->tell(); if( bValid ) { dumpAddTokenData(); @@ -889,7 +887,7 @@ void FormulaObject::implDump() writeInfoItem( "classes", mxStack->getClassesString() ); } else - dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), nEndPos - rStrm.tell(), false ); + dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), nEndPos - mxStrm->tell(), false ); mnSize = 0; } @@ -1006,12 +1004,12 @@ OUString FormulaObject::createPlaceHolder() const sal_uInt16 FormulaObject::readFuncId() { - return (getBiff() >= BIFF4) ? in().readuInt16() : in().readuInt8(); + return (getBiff() >= BIFF4) ? mxStrm->readuInt16() : mxStrm->readuInt8(); } OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo** oppFuncInfo ) { - ItemGuard aItemGuard( out(), "func-id" ); + ItemGuard aItemGuard( mxOut, "func-id" ); writeHexItem( EMPTY_STRING, nFuncId, "FUNCID" ); OUStringBuffer aBuffer; const FunctionInfo* pFuncInfo = mxFuncProv->getFuncInfoFromBiffFuncId( nFuncId ); @@ -1025,9 +1023,9 @@ OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo* } OUString aFuncName = aBuffer.makeStringAndClear(); aItemGuard.cont(); - out().writeChar( OOX_DUMP_STRQUOTE ); - out().writeString( aFuncName ); - out().writeChar( OOX_DUMP_STRQUOTE ); + mxOut->writeChar( OOX_DUMP_STRQUOTE ); + mxOut->writeString( aFuncName ); + mxOut->writeChar( OOX_DUMP_STRQUOTE ); if( oppFuncInfo ) *oppFuncInfo = pFuncInfo; return aFuncName; } @@ -1133,13 +1131,13 @@ OUString FormulaObject::dumpTokenRefTabIdxs() void FormulaObject::dumpIntToken() { dumpDec< sal_uInt16 >( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpDoubleToken() { dumpDec< double >( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpStringToken() @@ -1153,13 +1151,13 @@ void FormulaObject::dumpStringToken() void FormulaObject::dumpBoolToken() { dumpBoolean( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpErrorToken() { dumpErrorCode( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpMissArgToken() @@ -1201,14 +1199,14 @@ void FormulaObject::dumpRefToken( const OUString& rTokClass, bool bNameMode ) { TokenAddress aPos = dumpTokenAddress( bNameMode ); writeTokenAddressItem( "addr", aPos, bNameMode ); - mxStack->pushOperand( createRef( out().getLastItemValue() ), rTokClass ); + mxStack->pushOperand( createRef( mxOut->getLastItemValue() ), rTokClass ); } void FormulaObject::dumpAreaToken( const OUString& rTokClass, bool bNameMode ) { TokenRange aRange = dumpTokenRange( bNameMode ); writeTokenRangeItem( "range", aRange, bNameMode ); - mxStack->pushOperand( createRef( out().getLastItemValue() ), rTokClass ); + mxStack->pushOperand( createRef( mxOut->getLastItemValue() ), rTokClass ); } void FormulaObject::dumpRefErrToken( const OUString& rTokClass, bool bArea ) @@ -1222,7 +1220,7 @@ void FormulaObject::dumpRef3dToken( const OUString& rTokClass, bool bNameMode ) OUString aRef = dumpTokenRefTabIdxs(); TokenAddress aPos = dumpTokenAddress( bNameMode ); writeTokenAddress3dItem( "addr", aRef, aPos, bNameMode ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } void FormulaObject::dumpArea3dToken( const OUString& rTokClass, bool bNameMode ) @@ -1230,7 +1228,7 @@ void FormulaObject::dumpArea3dToken( const OUString& rTokClass, bool bNameMode ) OUString aRef = dumpTokenRefTabIdxs(); TokenRange aRange = dumpTokenRange( bNameMode ); writeTokenRange3dItem( "range", aRef, aRange, bNameMode ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } void FormulaObject::dumpRefErr3dToken( const OUString& rTokClass, bool bArea ) @@ -1260,7 +1258,7 @@ void FormulaObject::dumpExpToken( const String& rName ) aPos.mnCol = dumpDec< sal_uInt16, sal_uInt8 >( getBiff() != BIFF2, "col" ); writeAddressItem( "base-addr", aPos ); OUStringBuffer aOp( rName ); - StringHelper::appendIndex( aOp, out().getLastItemValue() ); + StringHelper::appendIndex( aOp, mxOut->getLastItemValue() ); mxStack->pushOperand( aOp.makeStringAndClear() ); } @@ -1288,7 +1286,7 @@ void FormulaObject::dumpFuncToken( const OUString& rTokClass ) void FormulaObject::dumpFuncVarToken( const OUString& rTokClass ) { sal_uInt8 nParamCount; - in() >> nParamCount; + *mxStrm >> nParamCount; sal_uInt16 nFuncId = readFuncId(); bool bCmd = getFlag( nFuncId, BIFF_TOK_FUNCVAR_CMD ); if( bCmd ) @@ -1345,7 +1343,7 @@ bool FormulaObject::dumpAttrToken() case BIFF_TOK_ATTR_CHOOSE: { sal_uInt16 nCount = dumpDec< sal_uInt16, sal_uInt8 >( !bBiff2, "choices" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nIdx = 0; nIdx < nCount; ++nIdx ) dumpDec< sal_uInt16, sal_uInt8 >( !bBiff2, "#skip" ); dumpDec< sal_uInt16, sal_uInt8 >( !bBiff2, "skip-err" ); @@ -1431,7 +1429,7 @@ void FormulaObject::dumpNlrColRowToken( const OUString& rTokClass, bool bAddData { TokenAddress aPos = dumpTokenAddress( false ); writeInfoItem( "addr", lclCreateNlr( aPos ) ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } } @@ -1447,7 +1445,7 @@ void FormulaObject::dumpNlrRangeToken( const OUString& rTokClass, bool bAddData { TokenAddress aPos = dumpTokenAddress( false ); writeInfoItem( "addr", lclCreateNlr( aPos ) ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } dumpUnknown( 1 ); dumpRange( "target-range" ); @@ -1462,24 +1460,23 @@ void FormulaObject::dumpNlrRangeErrToken() void FormulaObject::dumpAddTokenData() { - Output& rOut = out(); - rOut.resetItemIndex(); + mxOut->resetItemIndex(); for( AddDataTypeVec::const_iterator aIt = maAddData.begin(), aEnd = maAddData.end(); aIt != aEnd; ++aIt ) { AddDataType eType = *aIt; { - ItemGuard aItem( rOut, "#add-data" ); + ItemGuard aItem( mxOut, "#add-data" ); switch( eType ) { - case ADDDATA_NLR: rOut.writeAscii( "tNlr" ); break; - case ADDDATA_ARRAY: rOut.writeAscii( "tArray" ); break; - case ADDDATA_MEMAREA: rOut.writeAscii( "tMemArea" ); break; + case ADDDATA_NLR: mxOut->writeAscii( "tNlr" ); break; + case ADDDATA_ARRAY: mxOut->writeAscii( "tArray" ); break; + case ADDDATA_MEMAREA: mxOut->writeAscii( "tMemArea" ); break; } } size_t nIdx = aIt - maAddData.begin(); - IndentGuard aIndGuard( rOut ); + IndentGuard aIndGuard( mxOut ); switch( eType ) { case ADDDATA_NLR: dumpAddDataNlr( nIdx ); break; @@ -1513,7 +1510,7 @@ void FormulaObject::dumpAddDataArray( size_t nIdx ) dumpConstArrayHeader( nCols, nRows ); OUStringBuffer aOp; - TableGuard aTabGuard( out(), 17 ); + TableGuard aTabGuard( mxOut, 17 ); for( sal_uInt32 nRow = 0; nRow < nRows; ++nRow ) { OUStringBuffer aArrayLine; @@ -1779,7 +1776,7 @@ void WorkbookStreamObject::implDumpRecordBody() dumpDec< sal_uInt8 >( "creator", "CHFRINFO-APPVERSION" ); dumpDec< sal_uInt8 >( "writer", "CHFRINFO-APPVERSION" ); sal_uInt16 nCount = dumpDec< sal_uInt16 >( "rec-range-count" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex ) dumpHexPair< sal_uInt16 >( "#rec-range", '-' ); } @@ -1995,7 +1992,7 @@ void WorkbookStreamObject::implDumpRecordBody() break; case BIFF_ID_COLUMNDEFAULT: - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_Int32 nCol = 0, nCount = dumpColRange(); nCol < nCount; ++nCol ) dumpXfIdx( "#xf-idx", true ); dumpUnused( 2 ); @@ -2018,11 +2015,11 @@ void WorkbookStreamObject::implDumpRecordBody() case BIFF_ID_COORDLIST: { - out().resetItemIndex(); - TableGuard aTabGuard( out(), 12, 10 ); + mxOut->resetItemIndex(); + TableGuard aTabGuard( mxOut, 12, 10 ); while( rStrm.getRemaining() >= 4 ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#point" ); dumpDec< sal_uInt16 >( "x" ); dumpDec< sal_uInt16 >( "y" ); @@ -2040,10 +2037,10 @@ void WorkbookStreamObject::implDumpRecordBody() sal_Int32 nCol2 = dumpColIndex( "last-col-idx", false ); sal_Int32 nCol1 = dumpColIndex( "first-col-idx", false ); sal_Int32 nRow = dumpRowIndex( "row-idx" ); - TableGuard aTabGuard( out(), 14, 17 ); + TableGuard aTabGuard( mxOut, 14, 17 ); for( Address aPos( nCol1, nRow ); !rStrm.isEof() && (aPos.mnCol <= nCol2); ++aPos.mnCol ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeAddressItem( "pos", aPos ); dumpConstValue(); } @@ -2117,7 +2114,7 @@ void WorkbookStreamObject::implDumpRecordBody() case BIFF_ID_DBCELL: dumpDec< sal_uInt32 >( "reverse-offset-to-row" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); while( rStrm.getRemaining() >= 2 ) dumpDec< sal_uInt16 >( "#cell-offset" ); break; @@ -2181,7 +2178,7 @@ void WorkbookStreamObject::implDumpRecordBody() else { dumpString( "workbook-url" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nSheet = 0; !rStrm.isEof() && (nSheet < nCount); ++nSheet ) dumpString( "#sheet-name" ); } @@ -2214,11 +2211,11 @@ void WorkbookStreamObject::implDumpRecordBody() if( eBiff == BIFF8 ) { sal_uInt16 nCount = dumpDec< sal_uInt16 >( "ref-count" ); - TableGuard aTabGuard( out(), 10, 17, 24 ); - out().resetItemIndex(); + TableGuard aTabGuard( mxOut, 10, 17, 24 ); + mxOut->resetItemIndex(); for( sal_uInt16 nRefId = 0; !rStrm.isEof() && (nRefId < nCount); ++nRefId ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#ref" ); dumpDec< sal_uInt16 >( "extbook-idx" ); dumpDec< sal_Int16 >( "first-sheet", "EXTERNSHEET-IDX" ); @@ -2353,7 +2350,7 @@ void WorkbookStreamObject::implDumpRecordBody() if( nFormat == 9 ) { writeEmptyItem( "bitmap-header" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( dumpDec< sal_uInt32 >( "header-size" ) == 12 ) { dumpDec< sal_Int16 >( "width" ); @@ -2374,7 +2371,7 @@ void WorkbookStreamObject::implDumpRecordBody() dumpRowIndex( "first-row-with-cell", eBiff == BIFF8 ); dumpRowIndex( "first-free-row", eBiff == BIFF8 ); if( nRecId == BIFF3_ID_INDEX ) dumpHex< sal_uInt32 >( (eBiff <= BIFF4) ? "first-xf-pos" : "defcolwidth-pos", "CONV-DEC" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); while( rStrm.getRemaining() >= 4 ) dumpHex< sal_uInt32 >( "#first-row-pos-of-block", "CONV-DEC" ); break; @@ -2424,10 +2421,10 @@ void WorkbookStreamObject::implDumpRecordBody() { Address aPos = dumpAddress(); { - TableGuard aTabGuard( out(), 12 ); + TableGuard aTabGuard( mxOut, 12 ); for( ; rStrm.getRemaining() >= 4; ++aPos.mnCol ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeAddressItem( "pos", aPos ); dumpXfIdx(); } @@ -2440,10 +2437,10 @@ void WorkbookStreamObject::implDumpRecordBody() { Address aPos = dumpAddress(); { - TableGuard aTabGuard( out(), 12, 12 ); + TableGuard aTabGuard( mxOut, 12, 12 ); for( ; rStrm.getRemaining() >= 8; ++aPos.mnCol ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeAddressItem( "pos", aPos ); dumpXfIdx(); dumpRk( "value" ); @@ -2611,13 +2608,13 @@ void WorkbookStreamObject::implDumpRecordBody() case BIFF_ID_PTPAGEFIELDS: { - out().resetItemIndex(); - TableGuard aTabGuard( out(), 17, 17, 17 ); + mxOut->resetItemIndex(); + TableGuard aTabGuard( mxOut, 17, 17, 17 ); while( rStrm.getRemaining() >= 6 ) { writeEmptyItem( "#page-field" ); - MultiItemsGuard aMultiGuard( out() ); - IndentGuard aIndGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); + IndentGuard aIndGuard( mxOut ); dumpDec< sal_Int16 >( "base-field" ); dumpDec< sal_Int16 >( "item", "PTPAGEFIELDS-ITEM" ); dumpDec< sal_uInt16 >( "dropdown-obj-id" ); @@ -2626,7 +2623,7 @@ void WorkbookStreamObject::implDumpRecordBody() break; case BIFF_ID_PTROWCOLFIELDS: - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_Int64 nIdx = 0, nCount = rStrm.getRemaining() / 2; nIdx < nCount; ++nIdx ) dumpDec< sal_Int16 >( "#field-idx" ); break; @@ -2636,19 +2633,19 @@ void WorkbookStreamObject::implDumpRecordBody() { sal_uInt16 nCount = (mnPTRowColItemsIdx == 0) ? mnPTRowFields : mnPTColFields; sal_Int64 nLineSize = 8 + 2 * nCount; - out().resetItemIndex(); + mxOut->resetItemIndex(); while( rStrm.getRemaining() >= nLineSize ) { writeEmptyItem( "#line-data" ); - IndentGuard aIndGuard( out() ); - MultiItemsGuard aMultiGuard( out() ); + IndentGuard aIndGuard( mxOut ); + MultiItemsGuard aMultiGuard( mxOut ); dumpDec< sal_uInt16 >( "ident-count" ); dumpDec< sal_uInt16 >( "item-type", "PTROWCOLITEMS-ITEMTYPE" ); dumpDec< sal_uInt16 >( "used-count" ); dumpHex< sal_uInt16 >( "flags", "PTROWCOLITEMS-FLAGS" ); OUStringBuffer aItemList; for( sal_uInt16 nIdx = 0; nIdx < nCount; ++nIdx ) - StringHelper::appendToken( aItemList, in().readInt16() ); + StringHelper::appendToken( aItemList, mxStrm->readInt16() ); writeInfoItem( "item-idxs", aItemList.makeStringAndClear() ); } ++mnPTRowColItemsIdx; @@ -2714,10 +2711,10 @@ void WorkbookStreamObject::implDumpRecordBody() writeStringItem( "name", rStrm.readUniStringBody( nNameLen, true ) ); if( nUserLen > 0 ) dumpUniString( "user" ); // repeated string length if( nCommentLen > 0 ) dumpUniString( "comment" ); // repeated string length - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nCell = 0; !rStrm.isEof() && (nCell < nCellCount); ++nCell ) dumpAddress( "#pos" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nCell = 0; !rStrm.isEof() && (nCell < nCellCount); ++nCell ) dumpString( "#value" ); dumpUnused( 2 * nCellCount ); @@ -2803,7 +2800,7 @@ void WorkbookStreamObject::implDumpRecordBody() case BIFF_ID_SST: dumpDec< sal_uInt32 >( "string-cell-count" ); dumpDec< sal_uInt32 >( "sst-size" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); while( !rStrm.isEof() && (rStrm.getRemaining() >= 3) ) dumpUniString( "#entry" ); break; @@ -3029,7 +3026,7 @@ void WorkbookStreamObject::dumpExtColorValue( sal_uInt32 nColorType ) void WorkbookStreamObject::dumpExtColor( const String& rName ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName( "color" ) ); switch( extractValue< sal_uInt8 >( dumpDec< sal_uInt8 >( "flags", "EXTCOLOR-FLAGS" ), 1, 7 ) ) { @@ -3046,7 +3043,7 @@ void WorkbookStreamObject::dumpExtColor( const String& rName ) void WorkbookStreamObject::dumpExtCfColor( const String& rName ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName( "color" ) ); dumpExtColorValue( dumpExtColorType< sal_uInt32 >() ); dumpDec< double >( "tint", "CONV-FLOAT-TO-PERC" ); @@ -3089,7 +3086,7 @@ sal_uInt16 WorkbookStreamObject::dumpCellHeader( bool bBiff2Style ) void WorkbookStreamObject::dumpBoolErr() { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); sal_uInt8 nValue = dumpHex< sal_uInt8 >( "value" ); bool bErrCode = dumpBool< sal_uInt8 >( "is-errorcode" ); if( bErrCode ) @@ -3106,7 +3103,7 @@ void WorkbookStreamObject::dumpCfRuleProp() if( getFlag< sal_uInt32 >( nFlags1, 0x02000000 ) ) { writeEmptyItem( "numfmt-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( getFlag< sal_uInt16 >( nFlags2, 0x0001 ) ) { dumpDec< sal_uInt16 >( "size" ); @@ -3121,7 +3118,7 @@ void WorkbookStreamObject::dumpCfRuleProp() if( getFlag< sal_uInt32 >( nFlags1, 0x04000000 ) ) { writeEmptyItem( "font-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); sal_Int64 nRecPos = rStrm.tell(); dumpUniString( "name", BIFF_STR_8BITLENGTH ); dumpUnused( static_cast< sal_Int32 >( nRecPos + 64 - rStrm.tell() ) ); @@ -3147,7 +3144,7 @@ void WorkbookStreamObject::dumpCfRuleProp() if( getFlag< sal_uInt32 >( nFlags1, 0x08000000 ) ) { writeEmptyItem( "alignment-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt8 >( "alignent", "CFRULE-ALIGNMENT" ); dumpHex< sal_uInt8 >( "rotation", "TEXTROTATION" ); dumpHex< sal_uInt16 >( "indent", "CFRULE-INDENT" ); @@ -3156,7 +3153,7 @@ void WorkbookStreamObject::dumpCfRuleProp() if( getFlag< sal_uInt32 >( nFlags1, 0x10000000 ) ) { writeEmptyItem( "border-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt16 >( "border-style", "XF-BORDERSTYLE" ); dumpHex< sal_uInt16 >( "border-color1", "XF-BORDERCOLOR1" ); dumpHex< sal_uInt32 >( "border-color2", "CFRULE-BORDERCOLOR2" ); @@ -3164,13 +3161,13 @@ void WorkbookStreamObject::dumpCfRuleProp() if( getFlag< sal_uInt32 >( nFlags1, 0x20000000 ) ) { writeEmptyItem( "pattern-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt32 >( "pattern", "CFRULE-FILLBLOCK" ); } if( getFlag< sal_uInt32 >( nFlags1, 0x40000000 ) ) { writeEmptyItem( "protection-block" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt16 >( "flags", "CFRULE-PROTECTION-FLAGS" ); } } @@ -3180,14 +3177,14 @@ void WorkbookStreamObject::dumpXfExtProp() BiffInputStream& rStrm = getBiffStream(); for( sal_uInt16 nIndex = 0, nCount = dumpDec< sal_uInt16 >( "subrec-count" ); !rStrm.isEof() && (nIndex < nCount); ++nIndex ) { - out().startMultiItems(); + mxOut->startMultiItems(); sal_Int64 nStartPos = rStrm.tell(); writeEmptyItem( "SUBREC" ); sal_uInt16 nSubRecId = dumpDec< sal_uInt16 >( "id", "XFEXT-SUBREC" ); sal_uInt16 nSubRecSize = dumpDec< sal_uInt16 >( "size" ); sal_Int64 nEndPos = nStartPos + nSubRecSize; - out().endMultiItems(); - IndentGuard aIndGuard( out() ); + mxOut->endMultiItems(); + IndentGuard aIndGuard( mxOut ); switch( nSubRecId ) { case 4: case 5: case 7: case 8: case 9: case 10: case 11: case 13: @@ -3200,11 +3197,11 @@ void WorkbookStreamObject::dumpXfExtProp() break; case 6: dumpExtGradientHead(); - out().resetItemIndex(); - for( sal_Int32 nStop = 0, nStopCount = dumpDec< sal_Int32 >( "stop-count" ); (nStop < nStopCount) && !in().isEof(); ++nStop ) + mxOut->resetItemIndex(); + for( sal_Int32 nStop = 0, nStopCount = dumpDec< sal_Int32 >( "stop-count" ); (nStop < nStopCount) && !mxStrm->isEof(); ++nStop ) { writeEmptyItem( "#stop" ); - IndentGuard aIndGuard2( out() ); + IndentGuard aIndGuard2( mxOut ); sal_uInt16 nColorType = dumpExtColorType< sal_uInt16 >(); dumpExtColorValue( nColorType ); dumpDec< double >( "stop-pos" ); @@ -3228,14 +3225,14 @@ void WorkbookStreamObject::dumpDxfProp() dumpUnused( 2 ); for( sal_uInt16 nIndex = 0, nCount = dumpDec< sal_uInt16 >( "subrec-count" ); !rStrm.isEof() && (nIndex < nCount); ++nIndex ) { - out().startMultiItems(); + mxOut->startMultiItems(); sal_Int64 nStartPos = rStrm.tell(); writeEmptyItem( "SUBREC" ); sal_uInt16 nSubRecId = dumpDec< sal_uInt16 >( "id", "DXF-SUBREC" ); sal_uInt16 nSubRecSize = dumpDec< sal_uInt16 >( "size" ); sal_Int64 nEndPos = nStartPos + nSubRecSize; - out().endMultiItems(); - IndentGuard aIndGuard( out() ); + mxOut->endMultiItems(); + IndentGuard aIndGuard( mxOut ); switch( nSubRecId ) { case 0: @@ -3325,7 +3322,7 @@ void WorkbookStreamObject::dumpDxf12Prop() { BiffInputStream& rStrm = getBiffStream(); writeEmptyItem( "dxf-data" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); sal_uInt32 nSize = dumpDec< sal_uInt32 >( "dxf-size" ); if( nSize == 0 ) { @@ -3350,7 +3347,7 @@ void WorkbookStreamObject::dumpCfRule12Param( sal_uInt16 nSubType ) sal_Int64 nEndPos = getBiffStream().tell() + nSize; { writeEmptyItem( "params" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); switch( nSubType ) { case 5: @@ -3380,7 +3377,7 @@ void WorkbookStreamObject::dumpCfRule12Param( sal_uInt16 nSubType ) void WorkbookStreamObject::dumpFontRec() { sal_uInt16 nFontId = getBiffData().getFontCount(); - out().resetItemIndex( nFontId ); + mxOut->resetItemIndex( nFontId ); writeEmptyItem( "#font" ); sal_uInt16 nHeight = dumpDec< sal_uInt16 >( "height", "CONV-TWIP-TO-PT" ); sal_uInt16 nFlags = dumpHex< sal_uInt16 >( "flags", "FONT-FLAGS" ); @@ -3420,19 +3417,19 @@ void WorkbookStreamObject::dumpFormatRec() case BIFF2: case BIFF3: nFormatIdx = mnFormatIdx++; - out().resetItemIndex( nFormatIdx ); + mxOut->resetItemIndex( nFormatIdx ); writeEmptyItem( "#fmt" ); break; case BIFF4: nFormatIdx = mnFormatIdx++; - out().resetItemIndex( nFormatIdx ); + mxOut->resetItemIndex( nFormatIdx ); writeEmptyItem( "#fmt" ); dumpUnused( 2 ); break; case BIFF5: case BIFF8: getBiffStream() >> nFormatIdx; - out().resetItemIndex( nFormatIdx ); + mxOut->resetItemIndex( nFormatIdx ); writeEmptyItem( "#fmt" ); writeDecItem( "fmt-idx", nFormatIdx ); break; @@ -3445,7 +3442,7 @@ void WorkbookStreamObject::dumpFormatRec() void WorkbookStreamObject::dumpXfRec() { sal_uInt16 nXfId = getBiffData().getXfCount(); - out().resetItemIndex( nXfId ); + mxOut->resetItemIndex( nXfId ); writeEmptyItem( "#xf" ); sal_uInt16 nFontId = dumpFontIdx( EMPTY_STRING, getBiff() >= BIFF5 ); switch( getBiff() ) @@ -3824,7 +3821,6 @@ void WorkbookStreamObject::dumpObjRecBiff5() void WorkbookStreamObject::dumpObjRecBiff8() { - Output& rOut = out(); BiffInputStream& rStrm = getBiffStream(); NameListRef xRecNames = cfg().getNameList( "OBJ-RECNAMES" ); sal_uInt16 nObjType = 0xFFFF; @@ -3833,10 +3829,10 @@ void WorkbookStreamObject::dumpObjRecBiff8() bool bLoop = true; while( bLoop && (rStrm.getRemaining() >= 4) ) { - rOut.emptyLine(); + mxOut->emptyLine(); sal_uInt16 nSubRecId, nSubRecSize; { - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "OBJREC" ); writeHexItem( "pos", static_cast< sal_uInt32 >( rStrm.tell() ) ); rStrm >> nSubRecId >> nSubRecSize; @@ -3849,7 +3845,7 @@ void WorkbookStreamObject::dumpObjRecBiff8() sal_Int64 nRealRecSize = ::std::min< sal_Int64 >( nSubRecSize, rStrm.getRemaining() ); sal_Int64 nSubRecEnd = nSubRecStart + nRealRecSize; - IndentGuard aIndGuard( rOut ); + IndentGuard aIndGuard( mxOut ); switch( nSubRecId ) { case BIFF_ID_OBJMACRO: @@ -3871,7 +3867,7 @@ void WorkbookStreamObject::dumpObjRecBiff8() if( rStrm.tell() + 4 <= nSubRecEnd ) { if( bControl && bCtlsStrm ) - dumpOcxControl(); + dumpControl(); else dumpHex< sal_uInt32 >( "ole-storage-id" ); } @@ -3880,7 +3876,7 @@ void WorkbookStreamObject::dumpObjRecBiff8() sal_uInt32 nKeySize = dumpDec< sal_uInt32 >( "licence-key-size" ); if( nKeySize > 0 ) { - IndentGuard aIndGuard2( rOut ); + IndentGuard aIndGuard2( mxOut ); sal_Int64 nKeyEnd = rStrm.tell() + nKeySize; dumpArray( "licence-key", static_cast< sal_Int32 >( nKeySize ) ); rStrm.seek( nKeyEnd ); @@ -4052,7 +4048,7 @@ void WorkbookStreamObject::dumpObjRecPadding() { if( getBiffStream().tell() & 1 ) { - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt8 >( "padding" ); } } @@ -4090,7 +4086,7 @@ void WorkbookStreamObject::dumpObjRecFmla( const String& rName, sal_uInt16 nFmla if( nFmlaSize > 0 ) { writeEmptyItem( rName ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); sal_Int64 nStrmEnd = rStrm.tell() + nFmlaSize; dumpObjRecFmlaRaw(); if( rStrm.isEof() || (rStrm.tell() != nStrmEnd) ) @@ -4105,7 +4101,7 @@ void WorkbookStreamObject::dumpObjRecPictFmla( sal_uInt16 nFmlaSize ) if( nFmlaSize > 0 ) { writeEmptyItem( "pic-link" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); sal_Int64 nStrmEnd = rStrm.tell() + nFmlaSize; if( (getBiff() == BIFF3) && (nStrmEnd & 1) ) ++nStrmEnd; // BIFF3 size without padding dumpObjRecFmlaRaw(); @@ -4152,7 +4148,7 @@ void PivotCacheStreamObject::implDumpRecordBody() break; case BIFF_ID_PCDFDISCRETEPR: - out().resetItemIndex(); + mxOut->resetItemIndex(); while( !rStrm.isEof() && (rStrm.getRemaining() >= 2) ) dumpDec< sal_uInt16 >( "#item-index" ); break; @@ -4172,12 +4168,12 @@ void PivotCacheStreamObject::implDumpRecordBody() case BIFF_ID_PCITEM_DATE: { DateTime aDateTime; - aDateTime.Year = in().readuInt16(); - aDateTime.Month = in().readuInt16(); - aDateTime.Day = in().readuInt8(); - aDateTime.Hours = in().readuInt8(); - aDateTime.Minutes = in().readuInt8(); - aDateTime.Seconds = in().readuInt8(); + aDateTime.Year = mxStrm->readuInt16(); + aDateTime.Month = mxStrm->readuInt16(); + aDateTime.Day = mxStrm->readuInt8(); + aDateTime.Hours = mxStrm->readuInt8(); + aDateTime.Minutes = mxStrm->readuInt8(); + aDateTime.Seconds = mxStrm->readuInt8(); writeDateTimeItem( "value", aDateTime ); } break; @@ -4214,10 +4210,17 @@ void RootStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUStrin { if( rStrgPath.equalsAscii( "_VBA_PROJECT_CUR" ) ) VbaProjectStorageObject( *this, rxStrg, rSysPath ).dump(); + else if( rStrgPath.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "MBD" ) ) ) + VbaContainerStorageObject( *this, rxStrg, rSysPath ).dump(); else OleStorageObject::implDumpStorage( rxStrg, rStrgPath, rSysPath ); } +void RootStorageObject::implDumpBaseStream( const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) +{ + WorkbookStreamObject( *this, rxStrm, rSysFileName ).dump(); +} + // ============================================================================ // ============================================================================ @@ -4233,7 +4236,7 @@ Dumper::Dumper( const Reference< XMultiServiceFactory >& rxFactory, const Refere { if( rxFactory.is() && rxInStrm.is() ) { - StorageRef xStrg( new OleStorage( rxFactory, rxInStrm, true ) ); + StorageRef xStrg( new ::oox::ole::OleStorage( rxFactory, rxInStrm, true ) ); MediaDescriptor aMediaDesc; ConfigRef xCfg( new Config( DUMP_BIFF_CONFIG_ENVVAR, rxFactory, xStrg, rSysFileName, aMediaDesc ) ); DumperBase::construct( xCfg ); @@ -4242,17 +4245,7 @@ Dumper::Dumper( const Reference< XMultiServiceFactory >& rxFactory, const Refere void Dumper::implDump() { - RootStorageObject aRootStrg( *this ); - if( aRootStrg.isValid() ) - { - aRootStrg.dump(); - } - else if( StorageBase* pRootStrg = cfg().getRootStorage().get() ) - { - // try to dump plain BIFF stream - BinaryInputStreamRef xStrm( new BinaryXInputStream( pRootStrg->openInputStream( OUString() ), false ) ); - WorkbookStreamObject( *this, xStrm, cfg().getSysFileName() ).dump(); - } + RootStorageObject( *this ).dump(); } // ============================================================================ diff --git a/oox/source/dump/biffdumper.ini b/oox/source/dump/biffdumper.ini index 618e89c996e0..16c3fb883149 100644 --- a/oox/source/dump/biffdumper.ini +++ b/oox/source/dump/biffdumper.ini @@ -350,7 +350,7 @@ multilist=RECORD-NAMES-BIFF5 0x00B8=DOCROUTE,RECIPNAME,,,,MULTRK,MULTBLANK,TOOLBARHDR 0x00C0=TOOLBAREND,MMS,ADDMENU,DELMENU,,PTDATAFIELD,PCDEFINITION,PCDFIELD 0x00C8=PCITEM_INDEXLIST,PCITEM_DOUBLE,PCITEM_BOOL,PCITEM_ERROR,PCITEM_INTEGER,PCITEM_STRING,PCITEM_DATE,PCITEM_MISSING - 0x00D0=SXTBL,SXTBRGITEM,SXTBPG,OBPROJ,,PIVOTCACHE,RSTRING,DBCELL + 0x00D0=SXTBL,SXTBRGITEM,SXTBPG,VBAPROJECT,,PIVOTCACHE,RSTRING,DBCELL 0x00D8=PCDFRANGEPR,PCDFDISCRETEPR,BOOKBOOL,REVERT,SXEXT|PARAMQRY,SCENPROTECT,OLESIZE,UDDESC 0x00E0=XF,INTERFACEHDR,INTERFACEEND,PCDSOURCE,,,, 0x0206=FORMULA @@ -381,7 +381,7 @@ multilist=RECORD-NAMES-BIFF8 0x0190=,,,,,,CHTRHEADER, 0x01A8=,USERBVIEW,USERSVIEWBEGIN,USERSVIEWEND,,QSI,EXTERNALBOOK,PROT4REV 0x01B0=CFHEADER,CFRULE,DATAVALIDATIONS,,,DCONBINAME,TXO,REFRESHALL - 0x01B8=HYPERLINK,NLRDELNAME,CODENAME,PCDFSQLTYPE,PROT4REVPASS,,DATAVALIDATION, + 0x01B8=HYPERLINK,NLRDELNAME,CODENAME,PCDFSQLTYPE,PROT4REVPASS,VBAPROJECTEMPTY,DATAVALIDATION, 0x01C0=XL9FILE,RECALCID,INTCACHEDDATA,,,,, 0x0800=SCREENTIP,,,WEBQRYSETTINGS,WEBQRYTABLES,,, 0x0850=CHFRINFO,CHFRWRAPPER,CHFRBLOCKBEGIN,CHFRBLOCKEND,,,,CHFRUNITPROPS diff --git a/oox/source/dump/dffdumper.cxx b/oox/source/dump/dffdumper.cxx index 599687f5bd50..1b93d9b213c4 100644 --- a/oox/source/dump/dffdumper.cxx +++ b/oox/source/dump/dffdumper.cxx @@ -93,7 +93,7 @@ void DffStreamObject::implWriteExtHeader() case DFF_ID_SP: pcListName = "DFFSP-RECORD-INST"; break; // shape type case DFF_ID_SPLITMENUCOLORS: pcListName = "DFFSPLITMENUC-RECORD-INST"; break; // number of colors } - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeHexItem( "instance", mnInstVer, pcListName ); if( isContainer() ) writeDecItem( "container-size", mnRealSize ); } @@ -137,11 +137,11 @@ void DffStreamObject::implDumpRecordBody() sal_uInt32 nClusters = dumpDec< sal_uInt32 >( "id-cluster-count" ); dumpDec< sal_uInt32 >( "shape-count" ); dumpDec< sal_uInt32 >( "drawing-count" ); - out().resetItemIndex( 1 ); - TableGuard aTabGuard( out(), 15, 16 ); - for( sal_uInt32 nCluster = 1; !in().isEof() && (nCluster < nClusters); ++nCluster ) + mxOut->resetItemIndex( 1 ); + TableGuard aTabGuard( *mxOut, 15, 16 ); + for( sal_uInt32 nCluster = 1; !mxStrm->isEof() && (nCluster < nClusters); ++nCluster ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( *mxOut ); writeEmptyItem( "#cluster" ); dumpDec< sal_uInt32 >( "drawing-id" ); dumpHex< sal_uInt32 >( "next-free-id", "CONV-DEC" ); @@ -223,14 +223,14 @@ void DffStreamObject::dumpDffOpt() { sal_uInt16 nPropCount = getInst(); PropInfoVector aPropInfos; - out().resetItemIndex(); - for( sal_uInt16 nPropIdx = 0; !in().isEof() && (nPropIdx < nPropCount); ++nPropIdx ) + mxOut->resetItemIndex(); + for( sal_uInt16 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx ) { sal_uInt16 nPropId = dumpDffOptPropHeader(); sal_uInt16 nBaseId = nPropId & DFF_OPT_IDMASK; - sal_uInt32 nValue = in().readuInt32(); + sal_uInt32 nValue = mxStrm->readuInt32(); - IndentGuard aIndent( out() ); + IndentGuard aIndent( mxOut ); if( getFlag( nPropId, DFF_OPT_COMPLEX ) ) { writeHexItem( "complex-size", nValue, "CONV-DEC" ); @@ -280,14 +280,14 @@ void DffStreamObject::dumpDffOpt() } } - out().resetItemIndex(); - for( PropInfoVector::iterator aIt = aPropInfos.begin(), aEnd = aPropInfos.end(); !in().isEof() && (aIt != aEnd); ++aIt ) + mxOut->resetItemIndex(); + for( PropInfoVector::iterator aIt = aPropInfos.begin(), aEnd = aPropInfos.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt ) { - out().startMultiItems(); + mxOut->startMultiItems(); writeEmptyItem( "#complex-data" ); writeHexItem( "id", aIt->mnId, "DFFOPT-PROPERTY-NAMES" ); - out().endMultiItems(); - IndentGuard aIndent( out() ); + mxOut->endMultiItems(); + IndentGuard aIndent( *mxOut ); switch( aIt->meType ) { case PROPTYPE_BINARY: @@ -308,8 +308,8 @@ void DffStreamObject::dumpDffOpt() sal_uInt16 DffStreamObject::dumpDffOptPropHeader() { - MultiItemsGuard aMultiGuard( out() ); - TableGuard aTabGuard( out(), 11 ); + MultiItemsGuard aMultiGuard( mxOut ); + TableGuard aTabGuard( mxOut, 11 ); writeEmptyItem( "#prop" ); return dumpHex< sal_uInt16 >( "id", "DFFOPT-PROPERTY-ID" ); } diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx index 8e0e9a4e1225..807a5ec74715 100644 --- a/oox/source/dump/dumperbase.cxx +++ b/oox/source/dump/dumperbase.cxx @@ -38,6 +38,7 @@ #include #include #include "oox/helper/binaryoutputstream.hxx" +#include "oox/helper/textinputstream.hxx" #include "oox/core/filterbase.hxx" #include "oox/xls/biffhelper.hxx" @@ -1042,31 +1043,31 @@ ConfigItemBase::~ConfigItemBase() { } -void ConfigItemBase::readConfigBlock( const ConfigInputStreamRef& rxStrm ) +void ConfigItemBase::readConfigBlock( TextInputStream& rStrm ) { - readConfigBlockContents( rxStrm ); + readConfigBlockContents( rStrm ); } void ConfigItemBase::implProcessConfigItemStr( - const ConfigInputStreamRef& /*rxStrm*/, const OUString& /*rKey*/, const OUString& /*rData*/ ) + TextInputStream& /*rStrm*/, const OUString& /*rKey*/, const OUString& /*rData*/ ) { } void ConfigItemBase::implProcessConfigItemInt( - const ConfigInputStreamRef& /*rxStrm*/, sal_Int64 /*nKey*/, const OUString& /*rData*/ ) + TextInputStream& /*rStrm*/, sal_Int64 /*nKey*/, const OUString& /*rData*/ ) { } -void ConfigItemBase::readConfigBlockContents( const ConfigInputStreamRef& rxStrm ) +void ConfigItemBase::readConfigBlockContents( TextInputStream& rStrm ) { bool bLoop = true; - while( bLoop && !rxStrm->isEOF() ) + while( bLoop && !rStrm.isEof() ) { OUString aKey, aData; - switch( readConfigLine( rxStrm, aKey, aData ) ) + switch( readConfigLine( rStrm, aKey, aData ) ) { case LINETYPE_DATA: - processConfigItem( rxStrm, aKey, aData ); + processConfigItem( rStrm, aKey, aData ); break; case LINETYPE_END: bLoop = false; @@ -1076,12 +1077,12 @@ void ConfigItemBase::readConfigBlockContents( const ConfigInputStreamRef& rxStrm } ConfigItemBase::LineType ConfigItemBase::readConfigLine( - const ConfigInputStreamRef& rxStrm, OUString& orKey, OUString& orData ) const + TextInputStream& rStrm, OUString& orKey, OUString& orData ) const { OUString aLine; - while( !rxStrm->isEOF() && (aLine.getLength() == 0) ) + while( !rStrm.isEof() && (aLine.getLength() == 0) ) { - try { aLine = rxStrm->readLine(); } catch( Exception& ) { aLine = OUString(); } + aLine = rStrm.readLine(); if( (aLine.getLength() > 0) && (aLine[ 0 ] == OOX_DUMP_BOM) ) aLine = aLine.copy( 1 ); aLine = StringHelper::trimSpaces( aLine ); @@ -1101,20 +1102,20 @@ ConfigItemBase::LineType ConfigItemBase::readConfigLine( LINETYPE_DATA : LINETYPE_END; } -ConfigItemBase::LineType ConfigItemBase::readConfigLine( const ConfigInputStreamRef& rxStrm ) const +ConfigItemBase::LineType ConfigItemBase::readConfigLine( TextInputStream& rStrm ) const { OUString aKey, aData; - return readConfigLine( rxStrm, aKey, aData ); + return readConfigLine( rStrm, aKey, aData ); } void ConfigItemBase::processConfigItem( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { sal_Int64 nKey; if( StringHelper::convertStringToInt( nKey, rKey ) ) - implProcessConfigItemInt( rxStrm, nKey, rData ); + implProcessConfigItemInt( rStrm, nKey, rData ); else - implProcessConfigItemStr( rxStrm, rKey, rData ); + implProcessConfigItemStr( rStrm, rKey, rData ); } // ============================================================================ @@ -1144,18 +1145,18 @@ bool NameListBase::implIsValid() const } void NameListBase::implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { if( rKey.equalsAscii( "include" ) ) include( rData ); else if( rKey.equalsAscii( "exclude" ) ) exclude( rData ); else - ConfigItemBase::implProcessConfigItemStr( rxStrm, rKey, rData ); + ConfigItemBase::implProcessConfigItemStr( rStrm, rKey, rData ); } void NameListBase::implProcessConfigItemInt( - const ConfigInputStreamRef& /*rxStrm*/, sal_Int64 nKey, const OUString& rData ) + TextInputStream& /*rStrm*/, sal_Int64 nKey, const OUString& rData ) { implSetName( nKey, rData ); } @@ -1206,14 +1207,14 @@ ConstList::ConstList( const SharedConfigData& rCfgData ) : } void ConstList::implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { if( rKey.equalsAscii( "default" ) ) setDefaultName( rData ); else if( rKey.equalsAscii( "quote-names" ) ) setQuoteNames( StringHelper::convertStringToBool( rData ) ); else - NameListBase::implProcessConfigItemStr( rxStrm, rKey, rData ); + NameListBase::implProcessConfigItemStr( rStrm, rKey, rData ); } void ConstList::implSetName( sal_Int64 nKey, const OUString& rName ) @@ -1265,12 +1266,12 @@ void MultiList::setNamesFromVec( sal_Int64 nStartKey, const OUStringVector& rNam } void MultiList::implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { if( rKey.equalsAscii( "ignore-empty" ) ) mbIgnoreEmpty = StringHelper::convertStringToBool( rData ); else - ConstList::implProcessConfigItemStr( rxStrm, rKey, rData ); + ConstList::implProcessConfigItemStr( rStrm, rKey, rData ); } void MultiList::implSetName( sal_Int64 nKey, const OUString& rName ) @@ -1289,7 +1290,7 @@ FlagsList::FlagsList( const SharedConfigData& rCfgData ) : } void FlagsList::implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { if( rKey.equalsAscii( "ignore" ) ) { @@ -1299,7 +1300,7 @@ void FlagsList::implProcessConfigItemStr( } else { - NameListBase::implProcessConfigItemStr( rxStrm, rKey, rData ); + NameListBase::implProcessConfigItemStr( rStrm, rKey, rData ); } } @@ -1600,18 +1601,18 @@ bool SharedConfigData::implIsValid() const } void SharedConfigData::implProcessConfigItemStr( - const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData ) + TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { if( rKey.equalsAscii( "include-config-file" ) ) readConfigFile( maConfigPath + rData ); else if( rKey.equalsAscii( "constlist" ) ) - readNameList< ConstList >( rxStrm, rData ); + readNameList< ConstList >( rStrm, rData ); else if( rKey.equalsAscii( "multilist" ) ) - readNameList< MultiList >( rxStrm, rData ); + readNameList< MultiList >( rStrm, rData ); else if( rKey.equalsAscii( "flagslist" ) ) - readNameList< FlagsList >( rxStrm, rData ); + readNameList< FlagsList >( rStrm, rData ); else if( rKey.equalsAscii( "combilist" ) ) - readNameList< CombiList >( rxStrm, rData ); + readNameList< CombiList >( rStrm, rData ); else if( rKey.equalsAscii( "shortlist" ) ) createShortList( rData ); else if( rKey.equalsAscii( "unitconverter" ) ) @@ -1625,12 +1626,13 @@ bool SharedConfigData::readConfigFile( const OUString& rFileUrl ) bool bLoaded = maConfigFiles.count( rFileUrl ) > 0; if( !bLoaded ) { - Reference< XTextInputStream > xTextInStrm = - InputOutputHelper::openTextInputStream( mxFactory, rFileUrl, CREATE_OUSTRING( "UTF-8" ) ); - if( xTextInStrm.is() ) + Reference< XInputStream > xInStrm = InputOutputHelper::openInputStream( mxFactory, rFileUrl ); + BinaryXInputStream aInStrm( xInStrm, true ); + TextInputStream aTxtStrm( aInStrm, RTL_TEXTENCODING_UTF8 ); + if( !aTxtStrm.isEof() ) { maConfigFiles.insert( rFileUrl ); - readConfigBlockContents( xTextInStrm ); + readConfigBlockContents( aTxtStrm ); bLoaded = true; } } @@ -2220,20 +2222,38 @@ void StorageObjectBase::construct( const ObjectBase& rParent ) bool StorageObjectBase::implIsValid() const { - return mxStrg.get() && mxStrg->isStorage() && (maSysPath.getLength() > 0) && ObjectBase::implIsValid(); + return mxStrg.get() && (maSysPath.getLength() > 0) && ObjectBase::implIsValid(); } void StorageObjectBase::implDump() { - try + bool bIsStrg = mxStrg->isStorage(); + bool bIsRoot = mxStrg->isRootStorage(); + Reference< XInputStream > xBaseStrm; + if( !bIsStrg ) + xBaseStrm = mxStrg->openInputStream( OUString() ); + + OUString aSysOutPath = maSysPath; + if( bIsRoot ) try { + aSysOutPath += OOX_DUMP_DUMPEXT; Reference< XSimpleFileAccess > xFileAccess( getFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW ); - xFileAccess->kill( maSysPath + OOX_DUMP_DUMPEXT ); + xFileAccess->kill( aSysOutPath ); } catch( Exception& ) { } - extractStorage( mxStrg, OUString(), maSysPath ); + + if( bIsStrg ) + { + extractStorage( mxStrg, OUString(), aSysOutPath ); + } + else if( xBaseStrm.is() ) + { + BinaryInputStreamRef xInStrm( new BinaryXInputStream( xBaseStrm, false ) ); + xInStrm->seekToStart(); + implDumpBaseStream( xInStrm, aSysOutPath ); + } } void StorageObjectBase::implDumpStream( const BinaryInputStreamRef&, const OUString&, const OUString&, const OUString& ) @@ -2245,6 +2265,10 @@ void StorageObjectBase::implDumpStorage( const StorageRef& rxStrg, const OUStrin extractStorage( rxStrg, rStrgPath, rSysPath ); } +void StorageObjectBase::implDumpBaseStream( const BinaryInputStreamRef&, const OUString& ) +{ +} + void StorageObjectBase::addPreferredStream( const String& rStrmName ) { if( rStrmName.has() ) @@ -2280,7 +2304,7 @@ void StorageObjectBase::extractStream( StorageBase& rStrg, const OUString& rStrg { BinaryXOutputStream aOutStrm( InputOutputHelper::openOutputStream( getFactory(), rSysFileName ), true ); if( !aOutStrm.isEof() ) - aOutStrm.copyStream( aInStrm ); + aInStrm.copyToStream( aOutStrm ); } BinaryXInputStreamRef xDumpStrm( new BinaryXInputStream( InputOutputHelper::openInputStream( getFactory(), rSysFileName ), true ) ); if( !xDumpStrm->isEof() ) @@ -2289,17 +2313,15 @@ void StorageObjectBase::extractStream( StorageBase& rStrg, const OUString& rStrg void StorageObjectBase::extractStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) { - OUString aSysOutPath = rSysPath + OOX_DUMP_DUMPEXT; - // create directory in file system - ::osl::FileBase::RC eRes = ::osl::Directory::create( aSysOutPath ); + ::osl::FileBase::RC eRes = ::osl::Directory::create( rSysPath ); if( (eRes != ::osl::FileBase::E_None) && (eRes != ::osl::FileBase::E_EXIST) ) return; // process preferred storages and streams in root storage first if( rStrgPath.getLength() == 0 ) for( PreferredItemVector::iterator aIt = maPreferred.begin(), aEnd = maPreferred.end(); aIt != aEnd; ++aIt ) - extractItem( rxStrg, rStrgPath, aIt->maName, aSysOutPath, aIt->mbStorage, !aIt->mbStorage ); + extractItem( rxStrg, rStrgPath, aIt->maName, rSysPath, aIt->mbStorage, !aIt->mbStorage ); // process children of the storage for( StorageIterator aIt( rxStrg ); aIt.isValid(); ++aIt ) @@ -2311,13 +2333,13 @@ void StorageObjectBase::extractStorage( const StorageRef& rxStrg, const OUString for( PreferredItemVector::iterator aIIt = maPreferred.begin(), aIEnd = maPreferred.end(); !bFound && (aIIt != aIEnd); ++aIIt ) bFound = aIIt->maName == aItemName; if( !bFound ) - extractItem( rxStrg, rStrgPath, aItemName, aSysOutPath, aIt.isStorage(), aIt.isStream() ); + extractItem( rxStrg, rStrgPath, aItemName, rSysPath, aIt.isStorage(), aIt.isStream() ); } } -void StorageObjectBase::extractItem( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rItemName, const OUString& rSysOutPath, bool bIsStrg, bool bIsStrm ) +void StorageObjectBase::extractItem( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rItemName, const OUString& rSysPath, bool bIsStrg, bool bIsStrm ) { - OUString aSysFileName = getSysFileName( rItemName, rSysOutPath ); + OUString aSysFileName = getSysFileName( rItemName, rSysPath ); if( bIsStrg ) { OUStringBuffer aStrgPath( rStrgPath ); @@ -2362,18 +2384,18 @@ bool OutputObjectBase::implIsValid() const void OutputObjectBase::writeEmptyItem( const String& rName ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); } void OutputObjectBase::writeInfoItem( const String& rName, const String& rData ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeString( rData ); } void OutputObjectBase::writeCharItem( const String& rName, sal_Unicode cData ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeChar( OOX_DUMP_STRQUOTE ); mxOut->writeChar( cData ); mxOut->writeChar( OOX_DUMP_STRQUOTE ); @@ -2381,7 +2403,7 @@ void OutputObjectBase::writeCharItem( const String& rName, sal_Unicode cData ) void OutputObjectBase::writeStringItem( const String& rName, const OUString& rData ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeAscii( "(len=" ); mxOut->writeDec( rData.getLength() ); mxOut->writeAscii( ")," ); @@ -2394,19 +2416,19 @@ void OutputObjectBase::writeStringItem( const String& rName, const OUString& rDa void OutputObjectBase::writeArrayItem( const String& rName, const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeArray( pnData, nSize, cSep ); } void OutputObjectBase::writeBoolItem( const String& rName, bool bData ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeBool( bData ); } double OutputObjectBase::writeRkItem( const String& rName, sal_Int32 nRk ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeHexItem( rName, static_cast< sal_uInt32 >( nRk ), "RK-FLAGS" ); double fValue = ::oox::xls::BiffHelper::calcDoubleFromRk( nRk ); writeDecItem( "decoded", fValue ); @@ -2415,20 +2437,20 @@ double OutputObjectBase::writeRkItem( const String& rName, sal_Int32 nRk ) void OutputObjectBase::writeColorABGRItem( const String& rName, sal_Int32 nColor ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); writeHexItem( rName, nColor ); mxOut->writeColorABGR( nColor ); } void OutputObjectBase::writeDateTimeItem( const String& rName, const DateTime& rDateTime ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeDateTime( rDateTime ); } void OutputObjectBase::writeGuidItem( const String& rName, const OUString& rGuid ) { - ItemGuard aItem( *mxOut, rName ); + ItemGuard aItem( mxOut, rName ); mxOut->writeString( rGuid ); aItem.cont(); mxOut->writeString( cfg().getStringOption( rGuid, OUString() ) ); @@ -2436,85 +2458,81 @@ void OutputObjectBase::writeGuidItem( const String& rName, const OUString& rGuid void OutputObjectBase::writeColIndexItem( const String& rName, sal_Int32 nCol ) { - Output& rOut = out(); - ItemGuard aItem( rOut, rName ); - rOut.writeDec( nCol ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeDec( nCol ); aItem.cont(); - rOut.writeColIndex( nCol ); + mxOut->writeColIndex( nCol ); } void OutputObjectBase::writeRowIndexItem( const String& rName, sal_Int32 nRow ) { - Output& rOut = out(); - ItemGuard aItem( rOut, rName ); - rOut.writeDec( nRow ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeDec( nRow ); aItem.cont(); - rOut.writeRowIndex( nRow ); + mxOut->writeRowIndex( nRow ); } void OutputObjectBase::writeColRangeItem( const String& rName, sal_Int32 nCol1, sal_Int32 nCol2 ) { - Output& rOut = out(); - ItemGuard aItem( rOut, rName ); - rOut.writeColRowRange( nCol1, nCol2 ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeColRowRange( nCol1, nCol2 ); aItem.cont(); - rOut.writeColRange( nCol1, nCol2 ); + mxOut->writeColRange( nCol1, nCol2 ); } void OutputObjectBase::writeRowRangeItem( const String& rName, sal_Int32 nRow1, sal_Int32 nRow2 ) { - Output& rOut = out(); - ItemGuard aItem( rOut, rName ); - rOut.writeColRowRange( nRow1, nRow2 ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeColRowRange( nRow1, nRow2 ); aItem.cont(); - rOut.writeRowRange( nRow1, nRow2 ); + mxOut->writeRowRange( nRow1, nRow2 ); } void OutputObjectBase::writeAddressItem( const String& rName, const Address& rPos ) { - ItemGuard aItem( out(), rName ); - StringHelper::appendAddress( out().getLine(), rPos ); + ItemGuard aItem( mxOut, rName ); + StringHelper::appendAddress( mxOut->getLine(), rPos ); } void OutputObjectBase::writeRangeItem( const String& rName, const Range& rRange ) { - ItemGuard aItem( out(), rName ); - StringHelper::appendRange( out().getLine(), rRange ); + ItemGuard aItem( mxOut, rName ); + StringHelper::appendRange( mxOut->getLine(), rRange ); } void OutputObjectBase::writeRangeListItem( const String& rName, const RangeList& rRanges ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName ); writeDecItem( "count", static_cast< sal_uInt16 >( rRanges.size() ) ); - ItemGuard aItem( out(), "ranges" ); - StringHelper::appendRangeList( out().getLine(), rRanges ); + ItemGuard aItem( mxOut, "ranges" ); + StringHelper::appendRangeList( mxOut->getLine(), rRanges ); } void OutputObjectBase::writeTokenAddressItem( const String& rName, const TokenAddress& rPos, bool bNameMode ) { - ItemGuard aItem( out(), rName ); - StringHelper::appendAddress( out().getLine(), rPos, bNameMode ); + ItemGuard aItem( mxOut, rName ); + StringHelper::appendAddress( mxOut->getLine(), rPos, bNameMode ); } void OutputObjectBase::writeTokenAddress3dItem( const String& rName, const OUString& rRef, const TokenAddress& rPos, bool bNameMode ) { - ItemGuard aItem( out(), rName ); - out().writeString( rRef ); - StringHelper::appendAddress( out().getLine(), rPos, bNameMode ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeString( rRef ); + StringHelper::appendAddress( mxOut->getLine(), rPos, bNameMode ); } void OutputObjectBase::writeTokenRangeItem( const String& rName, const TokenRange& rRange, bool bNameMode ) { - ItemGuard aItem( out(), rName ); - StringHelper::appendRange( out().getLine(), rRange, bNameMode ); + ItemGuard aItem( mxOut, rName ); + StringHelper::appendRange( mxOut->getLine(), rRange, bNameMode ); } void OutputObjectBase::writeTokenRange3dItem( const String& rName, const OUString& rRef, const TokenRange& rRange, bool bNameMode ) { - ItemGuard aItem( out(), rName ); - out().writeString( rRef ); - StringHelper::appendRange( out().getLine(), rRange, bNameMode ); + ItemGuard aItem( mxOut, rName ); + mxOut->writeString( rRef ); + StringHelper::appendRange( mxOut->getLine(), rRange, bNameMode ); } // ============================================================================ @@ -2565,8 +2583,7 @@ void InputObjectBase::skipBlock( sal_Int64 nBytes, bool bShowSize ) void InputObjectBase::dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bStream ) { - Output& rOut = out(); - TableGuard aTabGuard( rOut, + TableGuard aTabGuard( mxOut, bShowOffset ? 12 : 0, 3 * OOX_DUMP_BYTESPERLINE / 2 + 1, 3 * OOX_DUMP_BYTESPERLINE / 2 + 1, @@ -2583,8 +2600,8 @@ void InputObjectBase::dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bS while( bLoop && (nPos < nDumpEnd) ) { - rOut.writeHex( static_cast< sal_uInt32 >( nPos ) ); - rOut.tab(); + mxOut->writeHex( static_cast< sal_uInt32 >( nPos ) ); + mxOut->tab(); sal_uInt8 pnLineData[ OOX_DUMP_BYTESPERLINE ]; sal_Int32 nLineSize = bSeekable ? ::std::min( static_cast< sal_Int32 >( nDumpEnd - mxStrm->tell() ), OOX_DUMP_BYTESPERLINE ) : OOX_DUMP_BYTESPERLINE; @@ -2598,18 +2615,18 @@ void InputObjectBase::dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bS const sal_uInt8* pnEnd = 0; for( pnByte = pnLineData, pnEnd = pnLineData + nReadSize; pnByte != pnEnd; ++pnByte ) { - if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) rOut.tab(); - rOut.writeHex( *pnByte, false ); - rOut.writeChar( ' ' ); + if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) mxOut->tab(); + mxOut->writeHex( *pnByte, false ); + mxOut->writeChar( ' ' ); } aTabGuard.tab( 3 ); for( pnByte = pnLineData, pnEnd = pnLineData + nReadSize; pnByte != pnEnd; ++pnByte ) { - if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) rOut.tab(); - rOut.writeChar( static_cast< sal_Unicode >( (*pnByte < 0x20) ? '.' : *pnByte ) ); + if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) mxOut->tab(); + mxOut->writeChar( static_cast< sal_Unicode >( (*pnByte < 0x20) ? '.' : *pnByte ) ); } - rOut.newLine(); + mxOut->newLine(); } } @@ -2621,11 +2638,11 @@ void InputObjectBase::dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bS void InputObjectBase::dumpBinary( const String& rName, sal_Int64 nBytes, bool bShowOffset ) { { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName ); writeDecItem( "size", nBytes ); } - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpRawBinary( nBytes, bShowOffset ); } @@ -2642,7 +2659,7 @@ void InputObjectBase::dumpRemaining( sal_Int64 nBytes ) void InputObjectBase::dumpRemainingTo( sal_Int64 nPos ) { - if( mxStrm->isEof() ) + if( mxStrm->isEof() || (mxStrm->tell() > nPos) ) writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); else dumpRemaining( nPos - mxStrm->tell() ); @@ -2760,7 +2777,7 @@ DateTime InputObjectBase::dumpFileTime( const String& rName ) { DateTime aDateTime; - ItemGuard aItem( out(), rName( "file-time" ) ); + ItemGuard aItem( mxOut, rName( "file-time" ) ); sal_Int64 nFileTime = dumpDec< sal_Int64 >( EMPTY_STRING ); // file time is in 10^-7 seconds (100 nanoseconds), convert to 1/100 seconds nFileTime /= 100000; @@ -2871,9 +2888,9 @@ BinaryStreamObject::BinaryStreamObject( const OutputObjectBase& rParent, const B void BinaryStreamObject::dumpBinaryStream( bool bShowOffset ) { - in().seek( 0 ); - dumpRawBinary( in().getLength(), bShowOffset, true ); - out().emptyLine(); + mxStrm->seekToStart(); + dumpRawBinary( mxStrm->getLength(), bShowOffset, true ); + mxOut->emptyLine(); } void BinaryStreamObject::implDump() @@ -2883,110 +2900,47 @@ void BinaryStreamObject::implDump() // ============================================================================ -namespace { - -bool lclIsEof( BinaryInputStream& rStrm ) -{ - return rStrm.isEof() || (rStrm.isSeekable() && (rStrm.tell() >= rStrm.getLength())); -} - -template< typename BufferType, typename CharType > -CharType lclAppendChar( BufferType& orBuffer, CharType cChar ) -{ - if( (cChar == 0x0A) || (cChar == 0x0D) ) - return cChar; - orBuffer.append( cChar ); - return 0; -} - -template< typename BufferType, typename CharType, typename StreamDataType > -bool lclReadLine( BufferType& orBuffer, sal_Unicode& orcNextLineChar, BinaryInputStream& rStrm ) -{ - CharType cLineEndChar = (orcNextLineChar == 0) ? 0 : lclAppendChar( orBuffer, static_cast< CharType >( orcNextLineChar ) ); - orcNextLineChar = 0; - - // read chars until EOF or line end character (LF or CR) - bool bIsEof = lclIsEof( rStrm ); - while( !bIsEof && (cLineEndChar == 0) ) - { - CharType cChar = static_cast< CharType >( rStrm.readValue< StreamDataType >() ); - bIsEof = rStrm.isEof(); - cLineEndChar = bIsEof ? 0 : lclAppendChar( orBuffer, cChar ); - } - - // try to skip LF following CR, or CR following LF - if( !lclIsEof( rStrm ) && (cLineEndChar != 0) ) - { - CharType cChar = static_cast< CharType >( rStrm.readValue< StreamDataType >() ); - bool bLineEnd = ((cChar == 0x0A) || (cChar == 0x0D)) && (cChar != cLineEndChar); - if( !rStrm.isEof() && !bLineEnd ) - orcNextLineChar = static_cast< sal_Unicode >( cChar ); - } - - return (cLineEndChar != 0) || (orBuffer.getLength() > 0); -} - -} // namespace - -// ---------------------------------------------------------------------------- - TextStreamObject::TextStreamObject( const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc, const OUString& rSysFileName ) : - meTextEnc( eTextEnc ) + const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc, const OUString& rSysFileName ) { InputObjectBase::construct( rParent, rxStrm, rSysFileName ); + if( rxStrm.get() ) + mxTextStrm.reset( new TextInputStream( *rxStrm, eTextEnc ) ); } TextStreamObject::TextStreamObject( const OutputObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc ) : - meTextEnc( eTextEnc ) + const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc ) { InputObjectBase::construct( rParent, rxStrm ); + if( rxStrm.get() ) + mxTextStrm.reset( new TextInputStream( *rxStrm, eTextEnc ) ); +} + +bool TextStreamObject::implIsValid() const +{ + return InputObjectBase::implIsValid() && mxTextStrm.get(); } void TextStreamObject::implDump() { OUString aLine; - sal_Unicode cNextLineChar = 0; sal_uInt32 nLine = 0; - while( readLine( aLine, cNextLineChar ) ) - implDumpLine( aLine, ++nLine ); - out().emptyLine(); + while( !mxTextStrm->isEof() ) + { + aLine = mxTextStrm->readLine(); + if( !mxTextStrm->isEof() ) + implDumpLine( aLine, ++nLine ); + } + mxOut->emptyLine(); } void TextStreamObject::implDumpLine( const OUString& rLine, sal_uInt32 nLine ) { - Output& rOut = out(); - TableGuard aTabGuard( rOut, 8 ); - rOut.writeDec( nLine, 6 ); - rOut.tab(); - rOut.writeString( rLine ); - rOut.newLine(); -} - -bool TextStreamObject::readCharLine( OUString& orLine, sal_Unicode& orcNextLineChar ) -{ - OStringBuffer aBuffer; - bool bHasData = lclReadLine< OStringBuffer, sal_Char, sal_uInt8 >( aBuffer, orcNextLineChar, in() ); - if( bHasData ) - orLine = OStringToOUString( aBuffer.makeStringAndClear(), meTextEnc ); - return bHasData; -} - -bool TextStreamObject::readUcs2Line( OUString& orLine, sal_Unicode& orcNextLineChar ) -{ - OUStringBuffer aBuffer; - bool bHasData = lclReadLine< OUStringBuffer, sal_Unicode, sal_uInt16 >( aBuffer, orcNextLineChar, in() ); - if( bHasData ) - orLine = aBuffer.makeStringAndClear(); - return bHasData; -} - -bool TextStreamObject::readLine( OUString& orLine, sal_Unicode& orcNextLineChar ) -{ - return (meTextEnc == RTL_TEXTENCODING_UCS2) ? - readUcs2Line( orLine, orcNextLineChar ) : - readCharLine( orLine, orcNextLineChar ); + TableGuard aTabGuard( mxOut, 8 ); + mxOut->writeDec( nLine, 6 ); + mxOut->tab(); + mxOut->writeString( rLine ); + mxOut->newLine(); } // ============================================================================ @@ -3002,9 +2956,9 @@ void XmlStreamObject::implDump() TextStreamObject::implDump(); if( maIncompleteLine.getLength() > 0 ) { - out().resetIndent(); - out().writeString( maIncompleteLine ); - out().emptyLine(); + mxOut->resetIndent(); + mxOut->writeString( maIncompleteLine ); + mxOut->emptyLine(); writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); } } @@ -3018,10 +2972,9 @@ void XmlStreamObject::implDumpLine( const OUString& rLine, sal_uInt32 ) aLine.append( rLine ); maIncompleteLine = OUString(); - Output& rOut = out(); if( aLine.getLength() == 0 ) { - rOut.newLine(); + mxOut->newLine(); return; } @@ -3092,10 +3045,10 @@ void XmlStreamObject::implDumpLine( const OUString& rLine, sal_uInt32 ) // flush output line if( maIncompleteLine.getLength() == 0 ) { - if( !bIsStartElement && bIsEndElement ) rOut.decIndent(); - rOut.writeString( aOutLine.makeStringAndClear() ); - rOut.newLine(); - if( bIsStartElement && !bIsEndElement ) rOut.incIndent(); + if( !bIsStartElement && bIsEndElement ) mxOut->decIndent(); + mxOut->writeString( aOutLine.makeStringAndClear() ); + mxOut->newLine(); + if( bIsStartElement && !bIsEndElement ) mxOut->incIndent(); } } } @@ -3131,11 +3084,11 @@ void RecordObjectBase::implDump() while( implStartRecord( *mxBaseStrm, mnRecPos, mnRecId, mnRecSize ) ) { // record header - out().emptyLine(); + mxOut->emptyLine(); writeHeader(); implWriteExtHeader(); - IndentGuard aIndGuard( out() ); - sal_Int64 nRecPos = in().tell(); + IndentGuard aIndGuard( mxOut ); + sal_Int64 nRecPos = mxStrm->tell(); // record body if( !mbBinaryOnly && cfg().hasName( xRecNames, mnRecId ) ) @@ -3148,7 +3101,7 @@ void RecordObjectBase::implDump() } // remaining undumped data - if( !in().isEof() && (in().tell() == nRecPos) ) + if( !mxStrm->isEof() && (mxStrm->tell() == nRecPos) ) dumpRawBinary( mnRecSize, false ); else dumpRemainingTo( nRecPos + mnRecSize ); @@ -3176,13 +3129,13 @@ void RecordObjectBase::constructRecObjBase( const BinaryInputStreamRef& rxBaseSt void RecordObjectBase::writeHeader() { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "REC" ); if( mbShowRecPos && mxBaseStrm->isSeekable() ) writeShortHexItem( "pos", mnRecPos, "CONV-DEC" ); writeShortHexItem( "size", mnRecSize, "CONV-DEC" ); - ItemGuard aItem( out(), "id" ); - out().writeShortHex( mnRecId ); + ItemGuard aItem( mxOut, "id" ); + mxOut->writeShortHex( mnRecId ); addNameToItem( mnRecId, "CONV-DEC" ); addNameToItem( mnRecId, maRecNames ); } @@ -3224,7 +3177,7 @@ bool SequenceRecordObjectBase::implStartRecord( BinaryInputStream& rBaseStrm, sa sal_Int32 nRecSize = static_cast< sal_Int32 >( ornRecSize ); mxRecData->realloc( nRecSize ); bValid = (nRecSize == 0) || (rBaseStrm.readData( *mxRecData, nRecSize ) == nRecSize); - in().seekToStart(); + mxStrm->seekToStart(); } return bValid; } diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx index b7750d4113b8..9c3e00fdcf30 100644 --- a/oox/source/dump/oledumper.cxx +++ b/oox/source/dump/oledumper.cxx @@ -33,8 +33,8 @@ #include #include "oox/helper/binaryoutputstream.hxx" #include "oox/core/filterbase.hxx" +#include "oox/ole/olestorage.hxx" #include "oox/ole/vbainputstream.hxx" -#include "oox/xls/biffhelper.hxx" #if OOX_INCLUDE_DUMPER @@ -52,9 +52,52 @@ namespace dump { // ============================================================================ // ============================================================================ -StdFontObject::StdFontObject( const InputObjectBase& rParent ) : - InputObjectBase( rParent ) +OUString OleInputObjectBase::dumpAnsiString32( const String& rName ) { + return dumpCharArray( rName, mxStrm->readInt32(), RTL_TEXTENCODING_MS_1252 ); +} + +OUString OleInputObjectBase::dumpUniString32( const String& rName ) +{ + return dumpUnicodeArray( rName, mxStrm->readInt32() ); +} + +sal_Int32 OleInputObjectBase::dumpStdClipboardFormat( const String& rName ) +{ + return dumpDec< sal_Int32 >( rName( "clipboard-format" ), "OLE-STD-CLIPBOARD-FORMAT" ); +} + +OUString OleInputObjectBase::dumpAnsiString32OrStdClip( const String& rName ) +{ + sal_Int32 nLen = mxStrm->readInt32(); + return (nLen < 0) ? OUString::valueOf( dumpStdClipboardFormat( rName ) ) : dumpCharArray( rName, nLen, RTL_TEXTENCODING_MS_1252 ); +} + +OUString OleInputObjectBase::dumpUniString32OrStdClip( const String& rName ) +{ + sal_Int32 nLen = mxStrm->readInt32(); + return (nLen < 0) ? OUString::valueOf( dumpStdClipboardFormat( rName ) ) : dumpUnicodeArray( rName, nLen ); +} + +void OleInputObjectBase::writeOleColorItem( const String& rName, sal_uInt32 nColor ) +{ + MultiItemsGuard aMultiGuard( mxOut ); + writeHexItem( rName, nColor, "OLE-COLOR" ); +} + +sal_uInt32 OleInputObjectBase::dumpOleColor( const String& rName ) +{ + sal_uInt32 nOleColor = mxStrm->readuInt32(); + writeOleColorItem( rName, nOleColor ); + return nOleColor; +} + +// ============================================================================ +// ============================================================================ + +StdFontObject::StdFontObject( const InputObjectBase& rParent ) +{ + construct( rParent ); } void StdFontObject::implDump() @@ -64,19 +107,19 @@ void StdFontObject::implDump() dumpHex< sal_uInt8 >( "flags", "STDFONT-FLAGS" ); dumpDec< sal_uInt16 >( "weight", "FONT-WEIGHT" ); dumpDec< sal_uInt32 >( "height", "STDFONT-HEIGHT" ); - dumpCharArray( "name", in().readuInt8(), RTL_TEXTENCODING_ASCII_US ); + dumpCharArray( "name", mxStrm->readuInt8(), RTL_TEXTENCODING_ASCII_US ); } // ============================================================================ -StdPicObject::StdPicObject( const InputObjectBase& rParent ) : - InputObjectBase( rParent ) +StdPicObject::StdPicObject( const InputObjectBase& rParent ) { + construct( rParent ); } void StdPicObject::implDump() { - dumpHex< sal_uInt32 >( "identifier" ); + dumpHex< sal_uInt32 >( "identifier", "STDPIC-ID" ); sal_uInt32 nSize = dumpHex< sal_uInt32 >( "image-size", "CONV-DEC" ); dumpBinary( "image-data", nSize ); } @@ -96,9 +139,9 @@ const sal_uInt32 STDHLINK_ASSTRING = 0x00000100; /// Hyperlink as sim } // namespace -StdHlinkObject::StdHlinkObject( const InputObjectBase& rParent ) : - InputObjectBase( rParent ) +StdHlinkObject::StdHlinkObject( const InputObjectBase& rParent ) { + construct( rParent ); } void StdHlinkObject::implDump() @@ -126,15 +169,14 @@ void StdHlinkObject::implDump() OUString StdHlinkObject::dumpHyperlinkString( const String& rName, bool bUnicode ) { - sal_Int32 nLen = in().readInt32(); - return bUnicode ? dumpUnicodeArray( rName, nLen ) : dumpCharArray( rName, nLen, osl_getThreadTextEncoding() ); + return bUnicode ? dumpUniString32( rName ) : dumpAnsiString32( rName ); } bool StdHlinkObject::dumpGuidAndMoniker() { bool bValidMoniker = true; OUString aGuid = cfg().getStringOption( dumpGuid( "moniker" ), OUString() ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( aGuid.equalsAscii( "URLMoniker" ) ) dumpUrlMoniker(); else if( aGuid.equalsAscii( "FileMoniker" ) ) @@ -153,9 +195,9 @@ bool StdHlinkObject::dumpGuidAndMoniker() void StdHlinkObject::dumpUrlMoniker() { sal_Int32 nBytes = dumpDec< sal_Int32 >( "url-bytes" ); - sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + sal_Int64 nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 ); dumpNullUnicodeArray( "url" ); - if( in().tell() + 24 == nEndPos ) + if( mxStrm->tell() + 24 == nEndPos ) { dumpGuid( "implementation-id" ); dumpDec< sal_uInt32 >( "version" ); @@ -172,7 +214,7 @@ void StdHlinkObject::dumpFileMoniker() dumpHex< sal_uInt16 >( "version" ); dumpUnused( 20 ); sal_Int32 nBytes = dumpDec< sal_Int32 >( "total-bytes" ); - sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + sal_Int64 nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 ); if( nBytes > 0 ) { sal_Int32 nFileBytes = dumpDec< sal_Int32 >( "uni-filename-bytes" ); @@ -185,18 +227,18 @@ void StdHlinkObject::dumpFileMoniker() void StdHlinkObject::dumpItemMoniker() { sal_Int32 nBytes = dumpDec< sal_Int32 >( "delimiter-bytes" ); - sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); - dumpNullCharArray( "ansi-delimiter", osl_getThreadTextEncoding() ); - if( in().tell() < nEndPos ) - dumpUnicodeArray( "unicode-delimiter", (nEndPos - in().tell()) / 2 ); - in().seek( nEndPos ); + sal_Int64 nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + dumpNullCharArray( "ansi-delimiter", RTL_TEXTENCODING_MS_1252 ); + if( mxStrm->tell() < nEndPos ) + dumpUnicodeArray( "unicode-delimiter", (nEndPos - mxStrm->tell()) / 2 ); + mxStrm->seek( nEndPos ); nBytes = dumpDec< sal_Int32 >( "item-bytes" ); - nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); - dumpNullCharArray( "ansi-item", osl_getThreadTextEncoding() ); - if( in().tell() < nEndPos ) - dumpUnicodeArray( "unicode-item", (nEndPos - in().tell()) / 2 ); - in().seek( nEndPos ); + nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + dumpNullCharArray( "ansi-item", RTL_TEXTENCODING_MS_1252 ); + if( mxStrm->tell() < nEndPos ) + dumpUnicodeArray( "unicode-item", (nEndPos - mxStrm->tell()) / 2 ); + mxStrm->seek( nEndPos ); } void StdHlinkObject::dumpAntiMoniker() @@ -207,13 +249,54 @@ void StdHlinkObject::dumpAntiMoniker() void StdHlinkObject::dumpCompositeMoniker() { sal_Int32 nCount = dumpDec< sal_Int32 >( "moniker-count" ); - for( sal_Int32 nIndex = 0; !in().isEof() && (nIndex < nCount); ++nIndex ) + for( sal_Int32 nIndex = 0; !mxStrm->isEof() && (nIndex < nCount); ++nIndex ) dumpGuidAndMoniker(); } // ============================================================================ // ============================================================================ +OleStreamObject::OleStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) +{ + construct( rParent, rxStrm, rSysFileName ); +} + +// ============================================================================ + +OleCompObjObject::OleCompObjObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) : + OleStreamObject( rParent, rxStrm, rSysFileName ) +{ +} + +void OleCompObjObject::implDump() +{ + dumpUnused( 4 ); + dumpDec< sal_uInt32 >( "version" ); + dumpUnused( 20 ); + dumpAnsiString32( "ansi-display-name" ); + dumpAnsiString32OrStdClip( "ansi-clipboard-format" ); + if( mxStrm->getRemaining() >= 4 ) + { + sal_Int32 nLen = mxStrm->readInt32(); + if( (0 <= nLen) && (nLen <= 40) ) + { + dumpCharArray( "ansi-unused", nLen, RTL_TEXTENCODING_MS_1252 ); + if( (mxStrm->getRemaining() >= 4) && (dumpHex< sal_Int32 >( "unicode-marker" ) == 0x71B239F4) ) + { + dumpUniString32( "unicode-display-name" ); + dumpUniString32OrStdClip( "unicode-clipboard-format" ); + dumpUniString32( "unicode-unused" ); + } + } + else + writeDecItem( "length", nLen ); + } + dumpRemainingStream(); +} + +// ============================================================================ +// ============================================================================ + namespace { const sal_Int32 OLEPROP_ID_DICTIONARY = 0; @@ -244,29 +327,26 @@ const sal_Int32 OLEPROP_TYPE_CLIPFMT = 71; const sal_uInt16 CODEPAGE_UNICODE = 1200; -const sal_uInt32 OCX_STRING_COMPRESSED = 0x80000000; +const sal_uInt32 AX_STRING_COMPRESSED = 0x80000000; } // namespace // ============================================================================ -OlePropertyStreamObject::OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) : - BinaryStreamObject( rParent, rxStrm, rSysFileName ) +OlePropertyStreamObject::OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) { + construct( rParent, rxStrm, rSysFileName ); } void OlePropertyStreamObject::implDump() { - BinaryInputStream& rStrm = in(); - Output& rOut = out(); - OUStringVector aGuidVec; ::std::vector< sal_uInt32 > aStartPosVec; // dump header writeEmptyItem( "HEADER" ); { - IndentGuard aIndGuard( rOut ); + IndentGuard aIndGuard( mxOut ); dumpHex< sal_uInt16 >( "byte-order", "OLEPROP-BYTE-ORDER" ); dumpDec< sal_uInt16 >( "version" ); dumpDec< sal_uInt16 >( "os-minor" ); @@ -276,29 +356,26 @@ void OlePropertyStreamObject::implDump() // dump table of section positions { - TableGuard aTabGuard( rOut, 15, 60 ); - rOut.resetItemIndex(); - for( sal_Int32 nSectIdx = 0; !rStrm.isEof() && (nSectIdx < nSectCount); ++nSectIdx ) + TableGuard aTabGuard( mxOut, 15, 60 ); + mxOut->resetItemIndex(); + for( sal_Int32 nSectIdx = 0; !mxStrm->isEof() && (nSectIdx < nSectCount); ++nSectIdx ) { - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#section" ); aGuidVec.push_back( dumpGuid( "guid" ) ); aStartPosVec.push_back( dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" ) ); } } } - rOut.emptyLine(); + mxOut->emptyLine(); // dump sections - for( size_t nSectIdx = 0; !rStrm.isEof() && (nSectIdx < aStartPosVec.size()); ++nSectIdx ) + for( size_t nSectIdx = 0; !mxStrm->isEof() && (nSectIdx < aStartPosVec.size()); ++nSectIdx ) dumpSection( aGuidVec[ nSectIdx ], aStartPosVec[ nSectIdx ] ); } void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nStartPos ) { - BinaryInputStream& rStrm = in(); - Output& rOut = out(); - // property ID names mxPropIds = cfg().createNameList< ConstList >( "OLEPROP-IDS" ); OUString aGuidName = cfg().getStringOption( rGuid, OUString() ); @@ -317,7 +394,7 @@ void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nSt writeSectionHeader( rGuid, nStartPos ); // seek to section - IndentGuard aIndGuard( rOut ); + IndentGuard aIndGuard( mxOut ); if( startElement( nStartPos ) ) { // dump section header @@ -326,11 +403,11 @@ void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nSt // dump table of property positions { - TableGuard aTabGuard( rOut, 15, 25 ); - rOut.resetItemIndex(); - for( sal_Int32 nPropIdx = 0; !rStrm.isEof() && (nPropIdx < nPropCount); ++nPropIdx ) + TableGuard aTabGuard( mxOut, 15, 25 ); + mxOut->resetItemIndex(); + for( sal_Int32 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx ) { - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#property" ); sal_Int32 nPropId = dumpDec< sal_Int32 >( "id", mxPropIds ); sal_uInt32 nPropPos = nStartPos + dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" ); @@ -338,10 +415,10 @@ void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nSt } } } - rOut.emptyLine(); + mxOut->emptyLine(); // code page property - meTextEnc = osl_getThreadTextEncoding(); + meTextEnc = RTL_TEXTENCODING_MS_1252; mbIsUnicode = false; PropertyPosMap::iterator aCodePageIt = aPropMap.find( OLEPROP_ID_CODEPAGE ); if( aCodePageIt != aPropMap.end() ) @@ -369,16 +446,16 @@ void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nSt void OlePropertyStreamObject::dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos ) { writePropertyHeader( nPropId, nStartPos ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( startElement( nStartPos ) ) dumpPropertyContents( nPropId ); - out().emptyLine(); + mxOut->emptyLine(); } void OlePropertyStreamObject::dumpCodePageProperty( sal_uInt32 nStartPos ) { writePropertyHeader( OLEPROP_ID_CODEPAGE, nStartPos ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( startElement( nStartPos ) ) { sal_Int32 nType = dumpPropertyType(); @@ -393,27 +470,27 @@ void OlePropertyStreamObject::dumpCodePageProperty( sal_uInt32 nStartPos ) else dumpPropertyContents( OLEPROP_ID_CODEPAGE ); } - out().emptyLine(); + mxOut->emptyLine(); } void OlePropertyStreamObject::dumpDictionaryProperty( sal_uInt32 nStartPos ) { writePropertyHeader( OLEPROP_ID_DICTIONARY, nStartPos ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); if( startElement( nStartPos ) ) { sal_Int32 nCount = dumpDec< sal_Int32 >( "count" ); - for( sal_Int32 nIdx = 0; !in().isEof() && (nIdx < nCount); ++nIdx ) + for( sal_Int32 nIdx = 0; !mxStrm->isEof() && (nIdx < nCount); ++nIdx ) { - MultiItemsGuard aMultiGuard( out() ); - TableGuard aTabGuard( out(), 10, 20 ); + MultiItemsGuard aMultiGuard( mxOut ); + TableGuard aTabGuard( mxOut, 10, 20 ); sal_Int32 nId = dumpDec< sal_Int32 >( "id" ); OUString aName = dumpString8( "name" ); if( mxPropIds.get() ) mxPropIds->setName( nId, aName ); } } - out().emptyLine(); + mxOut->emptyLine(); } void OlePropertyStreamObject::dumpPropertyContents( sal_Int32 nPropId ) @@ -423,11 +500,11 @@ void OlePropertyStreamObject::dumpPropertyContents( sal_Int32 nPropId ) { sal_Int32 nBaseType = nType & 0x0FFF; sal_Int32 nElemCount = dumpDec< sal_Int32 >( "element-count" ); - for( sal_Int32 nElemIdx = 0; !in().isEof() && (nElemIdx < nElemCount); ++nElemIdx ) + for( sal_Int32 nElemIdx = 0; !mxStrm->isEof() && (nElemIdx < nElemCount); ++nElemIdx ) { - out().resetItemIndex( nElemIdx ); + mxOut->resetItemIndex( nElemIdx ); writeEmptyItem( "#element" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpPropertyValue( nPropId, nBaseType ); } } @@ -491,7 +568,7 @@ OUString OlePropertyStreamObject::dumpCharArray8( const String& rName, sal_Int32 if( nNewLen > 0 ) { ::std::vector< sal_Char > aBuffer( nNewLen + 1 ); - in().readMemory( &aBuffer.front(), nNewLen ); + mxStrm->readMemory( &aBuffer.front(), nNewLen ); aBuffer[ nNewLen ] = 0; aData = OStringToOUString( OString( &aBuffer.front() ), meTextEnc ); } @@ -511,7 +588,7 @@ OUString OlePropertyStreamObject::dumpCharArray16( const String& rName, sal_Int3 ::std::vector< sal_Unicode > aBuffer; aBuffer.reserve( nNewLen + 1 ); for( size_t nIdx = 0; nIdx < nNewLen; ++nIdx ) - aBuffer.push_back( static_cast< sal_Unicode >( in().readuInt16() ) ); + aBuffer.push_back( static_cast< sal_Unicode >( mxStrm->readuInt16() ) ); aBuffer.push_back( 0 ); OUString aData( &aBuffer.front() ); writeStringItem( rName, aData ); @@ -521,15 +598,15 @@ OUString OlePropertyStreamObject::dumpCharArray16( const String& rName, sal_Int3 bool OlePropertyStreamObject::startElement( sal_uInt32 nStartPos ) { - in().seek( nStartPos ); - if( in().isEof() ) + mxStrm->seek( nStartPos ); + if( mxStrm->isEof() ) writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); - return !in().isEof(); + return !mxStrm->isEof(); } void OlePropertyStreamObject::writeSectionHeader( const OUString& rGuid, sal_uInt32 nStartPos ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "SECTION" ); writeHexItem( "pos", nStartPos, "CONV-DEC" ); writeGuidItem( "guid", rGuid ); @@ -537,7 +614,7 @@ void OlePropertyStreamObject::writeSectionHeader( const OUString& rGuid, sal_uIn void OlePropertyStreamObject::writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "PROPERTY" ); writeHexItem( "pos", nStartPos, "CONV-DEC" ); writeDecItem( "id", nPropId, mxPropIds ); @@ -562,7 +639,9 @@ void OleStorageObject::construct( const ObjectBase& rParent ) void OleStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& /*rStrgPath*/, const OUString& rStrmName, const OUString& rSysFileName ) { - if( rStrmName.equalsAscii( "\005SummaryInformation" ) || rStrmName.equalsAscii( "\005DocumentSummaryInformation" ) ) + if( rStrmName.equalsAscii( "\001CompObj" ) ) + OleCompObjObject( *this, rxStrm, rSysFileName ).dump(); + else if( rStrmName.equalsAscii( "\005SummaryInformation" ) || rStrmName.equalsAscii( "\005DocumentSummaryInformation" ) ) OlePropertyStreamObject( *this, rxStrm, rSysFileName ).dump(); else BinaryStreamObject( *this, rxStrm, rSysFileName ).dump(); @@ -571,40 +650,394 @@ void OleStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const // ============================================================================ // ============================================================================ -void OcxPropertyObjectBase::construct( const ObjectBase& rParent, +ComCtlObjectBase::ComCtlObjectBase( const InputObjectBase& rParent, + sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) : + mnDataId5( nDataId5 ), + mnDataId6( nDataId6 ), + mnVersion( nVersion ), + mbCommonPart( bCommonPart ), + mbComplexPart( bComplexPart ) +{ + construct( rParent ); +} + +void ComCtlObjectBase::implDump() +{ + sal_uInt32 nCommonSize = 0; + dumpComCtlSize() && dumpComCtlData( nCommonSize ) && (!mbCommonPart || dumpComCtlCommon( nCommonSize )) && (!mbComplexPart || dumpComCtlComplex()); +} + +void ComCtlObjectBase::implDumpCommonExtra( sal_Int64 /*nEndPos*/ ) +{ +} + +void ComCtlObjectBase::implDumpCommonTrailing() +{ +} + +bool ComCtlObjectBase::dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor ) +{ + // no idea if all this is correct... + sal_uInt32 nId = dumpHex< sal_uInt32 >( "header-id", "COMCTL-HEADER-IDS" ); + ItemGuard aItem( mxOut, "version" ); + sal_uInt16 nMinor, nMajor; + *mxStrm >> nMinor >> nMajor; + mxOut->writeDec( nMajor ); + mxOut->writeChar( '.' ); + mxOut->writeDec( nMinor ); + return !mxStrm->isEof() && (nId == nExpId) && ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor)); +} + +bool ComCtlObjectBase::dumpComCtlSize() +{ + if( dumpComCtlHeader( 0x12344321, 0, 8 ) ) + { + IndentGuard aIndGuard( mxOut ); + dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" ); + dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" ); + return !mxStrm->isEof(); + } + return false; +} + +bool ComCtlObjectBase::dumpComCtlData( sal_uInt32& ornCommonPartSize ) +{ + if( dumpComCtlHeader( (mnVersion == 5) ? mnDataId5 : mnDataId6, mnVersion ) ) + { + IndentGuard aIndGuard( mxOut ); + if( mbCommonPart ) + ornCommonPartSize = dumpDec< sal_uInt32 >( "common-part-size" ); + implDumpProperties(); + return !mxStrm->isEof(); + } + return false; +} + +bool ComCtlObjectBase::dumpComCtlCommon( sal_uInt32 nPartSize ) +{ + sal_Int64 nEndPos = mxStrm->tell() + nPartSize; + if( (nPartSize >= 16) && dumpComCtlHeader( 0xABCDEF01, 5, 0 ) ) + { + IndentGuard aIndGuard( mxOut ); + dumpUnknown( 4 ); + dumpHex< sal_uInt32 >( "common-flags", "COMCTL-COMMON-FLAGS" ); + implDumpCommonExtra( nEndPos ); + dumpRemainingTo( nEndPos ); + implDumpCommonTrailing(); + return !mxStrm->isEof(); + } + return false; +} + +bool ComCtlObjectBase::dumpComCtlComplex() +{ + if( dumpComCtlHeader( 0xBDECDE1F, 5, 1 ) ) + { + IndentGuard aIndGuard( mxOut ); + sal_uInt32 nFlags = dumpHex< sal_uInt32 >( "comctl-complex-flags", "COMCTL-COMPLEX-FLAGS" ); + if( !mxStrm->isEof() && (nFlags & 0x01) ) + { + writeEmptyItem( "font" ); + IndentGuard aIndGuard2( mxOut ); + OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() ); + if( aClassName.equalsAscii( "StdFont" ) ) + StdFontObject( *this ).dump(); + } + if( !mxStrm->isEof() && (nFlags & 0x02) ) + { + writeEmptyItem( "mouse-icon" ); + IndentGuard aIndGuard2( mxOut ); + OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() ); + if( aClassName.equalsAscii( "StdPic" ) ) + StdPicObject( *this ).dump(); + } + return !mxStrm->isEof(); + } + return false; +} + +// ============================================================================ + +ComCtlScrollBarObject::ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, SAL_MAX_UINT32, 0x99470A83, nVersion, true, true ) +{ +} + +void ComCtlScrollBarObject::implDumpProperties() +{ + dumpHex< sal_uInt32 >( "flags", "COMCTL-SCROLLBAR-FLAGS" ); + dumpDec< sal_Int32 >( "large-change" ); + dumpDec< sal_Int32 >( "small-change" ); + dumpDec< sal_Int32 >( "min" ); + dumpDec< sal_Int32 >( "max" ); + dumpDec< sal_Int32 >( "value" ); +} + +// ============================================================================ + +ComCtlProgressBarObject::ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E84, 0x97AB8A01, nVersion, true, true ) +{ +} + +void ComCtlProgressBarObject::implDumpProperties() +{ + dumpDec< float >( "min" ); + dumpDec< float >( "max" ); + if( mnVersion == 6 ) + { + dumpBool< sal_uInt16 >( "vertical" ); + dumpBool< sal_uInt16 >( "smooth-scroll" ); + } +} + +// ============================================================================ + +ComCtlSliderObject::ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E86, 0x0A2BAE11, nVersion, true, true ) +{ +} + +void ComCtlSliderObject::implDumpProperties() +{ + dumpBool< sal_Int32 >( "vertical" ); + dumpDec< sal_Int32 >( "large-change" ); + dumpDec< sal_Int32 >( "small-change" ); + dumpDec< sal_Int32 >( "min" ); + dumpDec< sal_Int32 >( "max" ); + dumpDec< sal_Int16 >( "select-range", "COMCTL-SLIDER-SELECTRANGE" ); + dumpUnused( 2 ); + dumpDec< sal_Int32 >( "select-start" ); + dumpDec< sal_Int32 >( "select-length" ); + dumpDec< sal_Int32 >( "tick-style", "COMCTL-SLIDER-TICKSTYLE" ); + dumpDec< sal_Int32 >( "tick-frequency" ); + dumpDec< sal_Int32 >( "value" ); + if( mnVersion == 6 ) + dumpBool< sal_Int32 >( "tooltip-below" ); +} + +// ============================================================================ + +ComCtlUpDownObject::ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xFF3626A0, 0xFF3626A0, nVersion, false, false ) +{ +} + +void ComCtlUpDownObject::implDumpProperties() +{ + dumpUnknown( 16 ); // buddy-property, somehow + dumpDec< sal_Int32 >( "buddy-control" ); + dumpUnknown( 8 ); + dumpDec< sal_Int32 >( "value" ); + dumpUnknown( 4 ); + dumpDec< sal_Int32 >( "increment" ); + dumpDec< sal_Int32 >( "max" ); + dumpDec< sal_Int32 >( "min" ); + dumpHex< sal_uInt32 >( "flags-1", "COMCTL-UPDOWN-FLAGS1" ); + dumpHex< sal_uInt32 >( "flags-2", "COMCTL-UPDOWN-FLAGS2" ); + dumpUnknown( 4 ); +} + +// ============================================================================ + +ComCtlImageListObject::ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E80, 0xE6E17E80, nVersion, true, false ) +{ +} + +void ComCtlImageListObject::implDumpProperties() +{ + dumpDec< sal_uInt16 >( "image-width" ); + dumpDec< sal_uInt16 >( "image-height" ); + dumpOleColor( "mask-color" ); + dumpBool< sal_Int16 >( "use-mask-color" ); + dumpUnknown( 2 ); +} + +void ComCtlImageListObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ ) +{ + dumpUnknown( 4 ); + dumpOleColor( "back-color" ); + dumpUnknown( 4 ); + sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" ); + mxOut->resetItemIndex(); + for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex ) + { + writeEmptyItem( "#image" ); + IndentGuard aIndGuard( mxOut ); + sal_uInt8 nFlags = dumpHex< sal_uInt8 >( "text-flags", "COMCTL-IMAGELIST-TEXTFLAGS" ); + if( nFlags & 0x01 ) dumpUniString32( "caption" ); + if( nFlags & 0x02 ) dumpUniString32( "key" ); + } +} + +void ComCtlImageListObject::implDumpCommonTrailing() +{ + sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" ); + mxOut->resetItemIndex(); + for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex ) + { + writeEmptyItem( "#image" ); + IndentGuard aIndGuard( mxOut ); + dumpDec< sal_Int32 >( "index" ); + StdPicObject( *this ).dump(); + } +} + +// ============================================================================ + +ComCtlTabStripObject::ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E8A, 0xD12A7AC1, nVersion, true, true ) +{ +} + +void ComCtlTabStripObject::implDumpProperties() +{ + dumpHex< sal_uInt32 >( "flags-1", "COMCTL-TABSTRIP-FLAGS1" ); + dumpDec< sal_uInt16 >( "tab-fixed-width", "CONV-HMM-TO-CM" ); + dumpDec< sal_uInt16 >( "tab-fixed-height", "CONV-HMM-TO-CM" ); + if( mnVersion == 6 ) + { + dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TABSTRIP-FLAGS2" ); + dumpDec< sal_uInt16 >( "tab-min-width", "CONV-HMM-TO-CM" ); + dumpUnknown( 2 ); + dumpHex< sal_uInt32 >( "flags-3", "COMCTL-TABSTRIP-FLAGS3" ); + } +} + +void ComCtlTabStripObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ ) +{ + dumpUnknown( 12 ); + dumpUniString32( "image-list" ); + sal_Int32 nTabCount = dumpDec< sal_Int32 >( "tab-count" ); + mxOut->resetItemIndex(); + for( sal_Int32 nTabIndex = 0; (nTabIndex < nTabCount) && !mxStrm->isEof(); ++nTabIndex ) + { + writeEmptyItem( "#tab" ); + IndentGuard aIndGuard( mxOut ); + dumpUnknown( 4 ); + sal_uInt32 nTabFlags = dumpHex< sal_uInt32 >( "tab-flags", "COMCTL-TABSTRIP-TABFLAGS" ); + if( nTabFlags & 0x01 ) dumpUniString32( "caption" ); + if( nTabFlags & 0x02 ) dumpUniString32( "key" ); + if( nTabFlags & 0x04 ) dumpUniString32( "tag" ); + if( nTabFlags & 0x08 ) dumpUniString32( "tooltip" ); + dumpDec< sal_uInt16 >( "image-id" ); + } +} + +// ============================================================================ + +ComCtlTreeViewObject::ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E8E, 0x6AC13CB1, nVersion, true, true ), + mnStringFlags( 0 ) +{ +} + +void ComCtlTreeViewObject::implDumpProperties() +{ + dumpHex< sal_uInt32 >( "flags", "COMCTL-TREEVIEW-FLAGS" ); + dumpDec< sal_Int32 >( "indentation", "CONV-HMM-TO-CM" ); + if( mnVersion == 6 ) + dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TREEVIEW-FLAGS2" ); + mnStringFlags = dumpHex< sal_uInt32 >( "string-flags", "COMCTL-TREEVIEW-STRINGFLAGS" ); +} + +void ComCtlTreeViewObject::implDumpCommonExtra( sal_Int64 nEndPos ) +{ + dumpOleColor( "text-color" ); + dumpOleColor( "back-color" ); + dumpUnknown( 4 ); + if( mnStringFlags & 0x02 ) + dumpUniString32( "image-list" ); + dumpUniString32( "path-separator" ); +} + +// ============================================================================ + +ComCtlStatusBarObject::ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) : + ComCtlObjectBase( rParent, 0xE6E17E88, SAL_MAX_UINT32, nVersion, true, true ) +{ +} + +void ComCtlStatusBarObject::implDumpProperties() +{ + dumpBool< sal_Int32 >( "style-simple-text" ); + dumpBool< sal_Int16 >( "show-tips" ); + dumpUnknown( 2 ); +} + +void ComCtlStatusBarObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ ) +{ + dumpUnknown( 12 ); + dumpUniString32( "simple-text" ); + sal_Int32 nPanelCount = dumpDec< sal_Int32 >( "panel-count" ); + mxOut->resetItemIndex(); + for( sal_Int32 nPanelIndex = 0; (nPanelIndex < nPanelCount) && !mxStrm->isEof(); ++nPanelIndex ) + { + writeEmptyItem( "#panel" ); + IndentGuard aIndGuard( mxOut ); + dumpHex< sal_uInt32 >( "panel-flags", "COMCTL-STATUSBAR-PANELFLAGS" ); + dumpDec< sal_Int32 >( "current-width", "CONV-HMM-TO-CM" ); + dumpDec< sal_Int32 >( "minimal-width", "CONV-HMM-TO-CM" ); + sal_uInt32 nTextFlags = dumpHex< sal_uInt32 >( "text-flags", "COMCTL-STATUSBAR-TEXTFLAGS" ); + if( nTextFlags & 0x01 ) dumpUniString32( "text" ); + if( nTextFlags & 0x02 ) dumpUniString32( "vis-text" ); + if( nTextFlags & 0x04 ) dumpUniString32( "key" ); + if( nTextFlags & 0x08 ) dumpUniString32( "tag" ); + if( nTextFlags & 0x10 ) dumpUniString32( "tooltip" ); + } +} + +void ComCtlStatusBarObject::implDumpCommonTrailing() +{ + sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" ); + mxOut->resetItemIndex(); + for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex ) + { + writeEmptyItem( "#image" ); + IndentGuard aIndGuard( mxOut ); + dumpDec< sal_Int32 >( "panel-index" ); + StdPicObject( *this ).dump(); + } +} + +// ============================================================================ +// ============================================================================ + +void AxPropertyObjectBase::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const String& rPropNameList, bool b64BitPropFlags ) { - InputObjectBase::construct( rParent, rxStrm, rSysFileName ); - constructOcxPropObj( rPropNameList, b64BitPropFlags ); + OleInputObjectBase::construct( rParent, rxStrm, rSysFileName ); + constructAxPropObj( rPropNameList, b64BitPropFlags ); } -void OcxPropertyObjectBase::construct( const OutputObjectBase& rParent, +void AxPropertyObjectBase::construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const String& rPropNameList, bool b64BitPropFlags ) { - InputObjectBase::construct( rParent, rxStrm ); - constructOcxPropObj( rPropNameList, b64BitPropFlags ); + OleInputObjectBase::construct( rParent, rxStrm ); + constructAxPropObj( rPropNameList, b64BitPropFlags ); } -void OcxPropertyObjectBase::construct( const InputObjectBase& rParent, +void AxPropertyObjectBase::construct( const InputObjectBase& rParent, const String& rPropNameList, bool b64BitPropFlags ) { - InputObjectBase::construct( rParent ); - constructOcxPropObj( rPropNameList, b64BitPropFlags ); + OleInputObjectBase::construct( rParent ); + constructAxPropObj( rPropNameList, b64BitPropFlags ); } -bool OcxPropertyObjectBase::implIsValid() const +bool AxPropertyObjectBase::implIsValid() const { - return InputObjectBase::implIsValid() && in().isSeekable(); + return OleInputObjectBase::implIsValid() && mxStrm->isSeekable(); } -void OcxPropertyObjectBase::implDump() +void AxPropertyObjectBase::implDump() { mbValid = true; // header setAlignAnchor(); dumpVersion(); sal_uInt16 nSize = dumpDec< sal_uInt16 >( "size" ); - mnPropertiesEnd = in().tell() + nSize; + mnPropertiesEnd = mxStrm->tell() + nSize; // property flags maLargeProps.clear(); maStreamProps.clear(); @@ -618,17 +1051,17 @@ void OcxPropertyObjectBase::implDump() implDumpExtended(); } -void OcxPropertyObjectBase::implDumpShortProperties() +void AxPropertyObjectBase::implDumpShortProperties() { } -void OcxPropertyObjectBase::implDumpExtended() +void AxPropertyObjectBase::implDumpExtended() { } -bool OcxPropertyObjectBase::ensureValid( bool bCondition ) +bool AxPropertyObjectBase::ensureValid( bool bCondition ) { - if( mbValid && (!bCondition || in().isEof()) ) + if( mbValid && (!bCondition || mxStrm->isEof()) ) { if( !bCondition ) writeInfoItem( "state", OOX_DUMP_ERRASCII( "format-error" ) ); @@ -637,12 +1070,12 @@ bool OcxPropertyObjectBase::ensureValid( bool bCondition ) return mbValid; } -void OcxPropertyObjectBase::setAlignAnchor() +void AxPropertyObjectBase::setAlignAnchor() { - mnPropertiesStart = in().tell(); + mnPropertiesStart = mxStrm->tell(); } -bool OcxPropertyObjectBase::startNextProperty() +bool AxPropertyObjectBase::startNextProperty() { if( mnCurrProp == 0 ) mnCurrProp = 1; else mnCurrProp <<= 1; bool bHasProp = getFlag( mnPropFlags, mnCurrProp ); @@ -650,12 +1083,12 @@ bool OcxPropertyObjectBase::startNextProperty() return ensureValid() && bHasProp; } -OUString OcxPropertyObjectBase::getPropertyName() const +OUString AxPropertyObjectBase::getPropertyName() const { return cfg().getName( mxPropNames, mnCurrProp ); } -sal_uInt32 OcxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList ) +sal_uInt32 AxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList ) { if( startNextProperty() ) { @@ -669,9 +1102,8 @@ sal_uInt32 OcxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault ) { if( startNextProperty() ) { - MultiItemsGuard aMultiGuard( out() ); alignInput< sal_uInt32 >(); - return dumpHex< sal_uInt32 >( getPropertyName(), "OCX-COLOR" ); + return dumpOleColor( getPropertyName() ); } return nDefault; } @@ -686,41 +1118,41 @@ sal_Unicode OcxPropertyObjectBase::dumpUnicodeProperty() return '\0'; } -void OcxPropertyObjectBase::dumpUnknownProperty() +void AxPropertyObjectBase::dumpUnknownProperty() { if( startNextProperty() ) ensureValid( false ); } -void OcxPropertyObjectBase::dumpPosProperty() +void AxPropertyObjectBase::dumpPosProperty() { if( startNextProperty() ) maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_POS, getPropertyName(), 8 ) ); } -void OcxPropertyObjectBase::dumpSizeProperty() +void AxPropertyObjectBase::dumpSizeProperty() { if( startNextProperty() ) maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_SIZE, getPropertyName(), 8 ) ); } -void OcxPropertyObjectBase::dumpGuidProperty( OUString* pValue ) +void AxPropertyObjectBase::dumpGuidProperty( OUString* pValue ) { if( startNextProperty() ) maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_GUID, getPropertyName(), 16, pValue ) ); } -void OcxPropertyObjectBase::dumpStringProperty( OUString* pValue ) +void AxPropertyObjectBase::dumpStringProperty( OUString* pValue ) { if( startNextProperty() ) { alignInput< sal_uInt32 >(); - sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "OCX-STRINGLEN" ); + sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "AX-STRINGLEN" ); maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_STRING, getPropertyName(), nLen, pValue ) ); } } -void OcxPropertyObjectBase::dumpStringArrayProperty() +void AxPropertyObjectBase::dumpStringArrayProperty() { if( startNextProperty() ) { @@ -730,7 +1162,7 @@ void OcxPropertyObjectBase::dumpStringArrayProperty() } } -void OcxPropertyObjectBase::dumpStreamProperty() +void AxPropertyObjectBase::dumpStreamProperty() { if( startNextProperty() ) { @@ -740,26 +1172,26 @@ void OcxPropertyObjectBase::dumpStreamProperty() } } -void OcxPropertyObjectBase::dumpEmbeddedFont() +void AxPropertyObjectBase::dumpEmbeddedFont() { if( ensureValid() ) { writeEmptyItem( "embedded-fontdata" ); - IndentGuard aIndGuard( out() ); - OcxCFontNewObject( *this ).dump(); + IndentGuard aIndGuard( mxOut ); + AxCFontNewObject( *this ).dump(); } } -void OcxPropertyObjectBase::dumpToPosition( sal_Int64 nPos ) +void AxPropertyObjectBase::dumpToPosition( sal_Int64 nPos ) { dumpRemainingTo( nPos ); mbValid = true; ensureValid(); } -void OcxPropertyObjectBase::constructOcxPropObj( const String& rPropNameList, bool b64BitPropFlags ) +void AxPropertyObjectBase::constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags ) { - if( InputObjectBase::implIsValid() ) + if( OleInputObjectBase::implIsValid() ) { mxPropNames = cfg().getNameList( rPropNameList ); mb64BitPropFlags = b64BitPropFlags; @@ -767,19 +1199,19 @@ void OcxPropertyObjectBase::constructOcxPropObj( const String& rPropNameList, bo } } -void OcxPropertyObjectBase::dumpVersion() +void AxPropertyObjectBase::dumpVersion() { - ItemGuard aItem( out(), "version" ); + ItemGuard aItem( mxOut, "version" ); sal_uInt8 nMinor, nMajor; - in() >> nMinor >> nMajor; - out().writeDec( nMajor ); - out().writeChar( '.' ); - out().writeDec( nMinor ); + *mxStrm >> nMinor >> nMajor; + mxOut->writeDec( nMajor ); + mxOut->writeChar( '.' ); + mxOut->writeDec( nMinor ); } -OUString OcxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSize, bool bArray ) +OUString AxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSize, bool bArray ) { - bool bCompressed = getFlag( nSize, OCX_STRING_COMPRESSED ); + bool bCompressed = getFlag( nSize, AX_STRING_COMPRESSED ); sal_uInt32 nBufSize = extractValue< sal_uInt32 >( nSize, 0, 31 ); OUString aString = bCompressed ? dumpCharArray( rName, nBufSize, RTL_TEXTENCODING_ISO_8859_1 ) : @@ -788,30 +1220,30 @@ OUString OcxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSiz return aString; } -void OcxPropertyObjectBase::dumpShortProperties() +void AxPropertyObjectBase::dumpShortProperties() { if( ensureValid() ) { writeEmptyItem( "short-properties" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); implDumpShortProperties(); alignInput< sal_uInt32 >(); } } -void OcxPropertyObjectBase::dumpLargeProperties() +void AxPropertyObjectBase::dumpLargeProperties() { if( ensureValid( mnPropFlags == 0 ) && !maLargeProps.empty() ) { writeEmptyItem( "large-properties" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); for( LargePropertyVector::iterator aIt = maLargeProps.begin(), aEnd = maLargeProps.end(); ensureValid() && (aIt != aEnd); ++aIt ) { switch( aIt->mePropType ) { case LargeProperty::PROPTYPE_POS: { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( aIt->maItemName ); dumpDec< sal_Int32 >( "top", "CONV-HMM-TO-CM" ); dumpDec< sal_Int32 >( "left", "CONV-HMM-TO-CM" ); @@ -819,7 +1251,7 @@ void OcxPropertyObjectBase::dumpLargeProperties() break; case LargeProperty::PROPTYPE_SIZE: { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( aIt->maItemName ); dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" ); dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" ); @@ -842,13 +1274,13 @@ void OcxPropertyObjectBase::dumpLargeProperties() case LargeProperty::PROPTYPE_STRINGARRAY: { writeEmptyItem( aIt->maItemName ); - IndentGuard aIndGuard2( out() ); - out().resetItemIndex(); - sal_Int64 nEndPos = in().tell() + aIt->mnDataSize; - while( in().tell() < nEndPos ) + IndentGuard aIndGuard2( mxOut ); + mxOut->resetItemIndex(); + sal_Int64 nEndPos = mxStrm->tell() + aIt->mnDataSize; + while( mxStrm->tell() < nEndPos ) { - MultiItemsGuard aMultiGuard( out() ); - sal_uInt32 nDataSize = dumpHex< sal_uInt32 >( "#flags", "OCX-ARRAYSTRINGLEN" ); + MultiItemsGuard aMultiGuard( mxOut ); + sal_uInt32 nDataSize = dumpHex< sal_uInt32 >( "#flags", "AX-ARRAYSTRINGLEN" ); dumpString( "string", nDataSize, true ); } dumpToPosition( nEndPos ); @@ -862,20 +1294,20 @@ void OcxPropertyObjectBase::dumpLargeProperties() if( ensureValid() && !maStreamProps.empty() ) { writeEmptyItem( "stream-properties" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); for( StreamPropertyVector::iterator aIt = maStreamProps.begin(), aEnd = maStreamProps.end(); ensureValid() && (aIt != aEnd); ++aIt ) { writeEmptyItem( aIt->maItemName ); if( ensureValid( aIt->mnData == 0xFFFF ) ) { - IndentGuard aIndGuard2( out() ); + IndentGuard aIndGuard2( mxOut ); OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() ); if( aClassName.equalsAscii( "StdFont" ) ) StdFontObject( *this ).dump(); else if( aClassName.equalsAscii( "StdPic" ) ) StdPicObject( *this ).dump(); else if( aClassName.equalsAscii( "CFontNew" ) ) - OcxCFontNewObject( *this ).dump(); + AxCFontNewObject( *this ).dump(); else ensureValid( false ); } @@ -885,43 +1317,43 @@ void OcxPropertyObjectBase::dumpLargeProperties() // ============================================================================ -OcxCFontNewObject::OcxCFontNewObject( const InputObjectBase& rParent ) +AxCFontNewObject::AxCFontNewObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-CFONTNEW-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-CFONTNEW-PROPERTIES" ); } -void OcxCFontNewObject::implDumpShortProperties() +void AxCFontNewObject::implDumpShortProperties() { dumpStringProperty(); - dumpFlagsProperty( 0, "OCX-CFONTNEW-FLAGS" ); + dumpFlagsProperty( 0, "AX-CFONTNEW-FLAGS" ); dumpDecProperty< sal_Int32 >( 160 ); dumpDecProperty< sal_Int32 >( 0 ); - dumpDecProperty< sal_uInt8 >( 1, "CHARSET" ); + dumpDecProperty< sal_uInt8 >( WINDOWS_CHARSET_DEFAULT, "CHARSET" ); dumpDecProperty< sal_uInt8 >( 0, "FONT-PITCHFAMILY" ); - dumpDecProperty< sal_uInt8 >( 1, "OCX-CFONTNEW-ALIGNMENT" ); + dumpDecProperty< sal_uInt8 >( 1, "AX-CFONTNEW-ALIGNMENT" ); dumpDecProperty< sal_uInt16 >( 400, "FONT-WEIGHT" ); } // ============================================================================ -OcxColumnInfoObject::OcxColumnInfoObject( const InputObjectBase& rParent ) +AxColumnInfoObject::AxColumnInfoObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-COLUMNINFO-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-COLUMNINFO-PROPERTIES" ); } -void OcxColumnInfoObject::implDumpShortProperties() +void AxColumnInfoObject::implDumpShortProperties() { dumpDecProperty< sal_Int32 >( -1, "CONV-HMM-TO-CM" ); } // ============================================================================ -OcxCommandButtonObject::OcxCommandButtonObject( const InputObjectBase& rParent ) +AxCommandButtonObject::AxCommandButtonObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-COMMANDBUTTON-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-COMMANDBUTTON-PROPERTIES" ); } -void OcxCommandButtonObject::implDumpShortProperties() +void AxCommandButtonObject::implDumpShortProperties() { dumpColorProperty( 0x80000012 ); dumpColorProperty( 0x80000008 ); @@ -936,42 +1368,42 @@ void OcxCommandButtonObject::implDumpShortProperties() dumpStreamProperty(); } -void OcxCommandButtonObject::implDumpExtended() +void AxCommandButtonObject::implDumpExtended() { dumpEmbeddedFont(); } // ============================================================================ -OcxMorphControlObject::OcxMorphControlObject( const InputObjectBase& rParent ) +AxMorphControlObject::AxMorphControlObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-MORPH-PROPERTIES", true ); + AxPropertyObjectBase::construct( rParent, "AX-MORPH-PROPERTIES", true ); } -void OcxMorphControlObject::implDumpShortProperties() +void AxMorphControlObject::implDumpShortProperties() { dumpFlagsProperty( 0x2C80081B ); dumpColorProperty( 0x80000005 ); dumpColorProperty( 0x80000008 ); dumpDecProperty< sal_uInt32 >( 0 ); dumpBorderStyleProperty< sal_uInt8 >( 0 ); - dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-SCROLLBARS" ); - mnCtrlType = dumpDecProperty< sal_uInt8 >( 1, "OCX-MORPH-CONTROLTYPE" ); + dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SCROLLBARS" ); + mnCtrlType = dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-CONTROLTYPE" ); dumpMousePtrProperty(); dumpSizeProperty(); dumpUnicodeProperty(); dumpDecProperty< sal_uInt32 >( 0, "CONV-HMM-TO-CM" ); - dumpDecProperty< sal_uInt16 >( 1, "OCX-MORPH-BOUNDCOLUMN" ); - dumpDecProperty< sal_Int16 >( -1, "OCX-MORPH-TEXTCOLUMN" ); - dumpDecProperty< sal_Int16 >( 1, "OCX-MORPH-COLUMNCOUNT" ); + dumpDecProperty< sal_uInt16 >( 1, "AX-MORPH-BOUNDCOLUMN" ); + dumpDecProperty< sal_Int16 >( -1, "AX-MORPH-TEXTCOLUMN" ); + dumpDecProperty< sal_Int16 >( 1, "AX-MORPH-COLUMNCOUNT" ); dumpDecProperty< sal_uInt16 >( 8 ); mnColInfoCount = dumpDecProperty< sal_uInt16 >( 1 ); - dumpDecProperty< sal_uInt8 >( 2, "OCX-MORPH-MATCHENTRYTYPE" ); - dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-LISTSTYLE" ); - dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-SHOWDROPDOWNMODE" ); + dumpDecProperty< sal_uInt8 >( 2, "AX-MORPH-MATCHENTRYTYPE" ); + dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-LISTSTYLE" ); + dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SHOWDROPDOWNMODE" ); dumpUnknownProperty(); - dumpDecProperty< sal_uInt8 >( 1, "OCX-MORPH-DROPDOWNSTYLE" ); - dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-SELECTIONTYPE" ); + dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-DROPDOWNSTYLE" ); + dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SELECTIONTYPE" ); dumpStringProperty(); dumpStringProperty(); dumpImagePosProperty(); @@ -985,34 +1417,34 @@ void OcxMorphControlObject::implDumpShortProperties() dumpStringProperty(); } -void OcxMorphControlObject::implDumpExtended() +void AxMorphControlObject::implDumpExtended() { dumpEmbeddedFont(); dumpColumnInfos(); } -void OcxMorphControlObject::dumpColumnInfos() +void AxMorphControlObject::dumpColumnInfos() { if( ensureValid() && (mnColInfoCount > 0) && ((mnCtrlType == 2) || (mnCtrlType == 3)) ) { - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < mnColInfoCount); ++nIdx ) { writeEmptyItem( "#column-info" ); - IndentGuard aIndGuard( out() ); - OcxColumnInfoObject( *this ).dump(); + IndentGuard aIndGuard( mxOut ); + AxColumnInfoObject( *this ).dump(); } } } // ============================================================================ -OcxLabelObject::OcxLabelObject( const InputObjectBase& rParent ) +AxLabelObject::AxLabelObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-LABEL-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-LABEL-PROPERTIES" ); } -void OcxLabelObject::implDumpShortProperties() +void AxLabelObject::implDumpShortProperties() { dumpColorProperty( 0x80000012 ); dumpColorProperty( 0x8000000F ); @@ -1029,19 +1461,19 @@ void OcxLabelObject::implDumpShortProperties() dumpStreamProperty(); } -void OcxLabelObject::implDumpExtended() +void AxLabelObject::implDumpExtended() { dumpEmbeddedFont(); } // ============================================================================ -OcxImageObject::OcxImageObject( const InputObjectBase& rParent ) +AxImageObject::AxImageObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-IMAGE-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-IMAGE-PROPERTIES" ); } -void OcxImageObject::implDumpShortProperties() +void AxImageObject::implDumpShortProperties() { dumpUnknownProperty(); dumpUnknownProperty(); @@ -1062,12 +1494,12 @@ void OcxImageObject::implDumpShortProperties() // ============================================================================ -OcxScrollBarObject::OcxScrollBarObject( const InputObjectBase& rParent ) +AxScrollBarObject::AxScrollBarObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-SCROLLBAR-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-SCROLLBAR-PROPERTIES" ); } -void OcxScrollBarObject::implDumpShortProperties() +void AxScrollBarObject::implDumpShortProperties() { dumpColorProperty( 0x80000012 ); dumpColorProperty( 0x8000000F ); @@ -1083,19 +1515,19 @@ void OcxScrollBarObject::implDumpShortProperties() dumpDecProperty< sal_Int32 >( 1 ); dumpDecProperty< sal_Int32 >( 1 ); dumpOrientationProperty(); - dumpDecProperty< sal_Int16 >( -1, "OCX-SCROLLBAR-PROPTHUMB" ); + dumpDecProperty< sal_Int16 >( -1, "AX-SCROLLBAR-PROPTHUMB" ); dumpDelayProperty(); dumpStreamProperty(); } // ============================================================================ -OcxSpinButtonObject::OcxSpinButtonObject( const InputObjectBase& rParent ) +AxSpinButtonObject::AxSpinButtonObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-SPINBUTTON-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-SPINBUTTON-PROPERTIES" ); } -void OcxSpinButtonObject::implDumpShortProperties() +void AxSpinButtonObject::implDumpShortProperties() { dumpColorProperty( 0x80000012 ); dumpColorProperty( 0x8000000F ); @@ -1116,12 +1548,12 @@ void OcxSpinButtonObject::implDumpShortProperties() // ============================================================================ -OcxTabStripObject::OcxTabStripObject( const InputObjectBase& rParent ) +AxTabStripObject::AxTabStripObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-TABSTRIP-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "AX-TABSTRIP-PROPERTIES" ); } -void OcxTabStripObject::implDumpShortProperties() +void AxTabStripObject::implDumpShortProperties() { dumpDecProperty< sal_Int32 >( -1 ); dumpColorProperty( 0x8000000F ); @@ -1131,8 +1563,8 @@ void OcxTabStripObject::implDumpShortProperties() dumpStringArrayProperty(); dumpMousePtrProperty(); dumpUnknownProperty(); - dumpDecProperty< sal_uInt32 >( 0, "OCX-TABSTRIP-ORIENTATION" ); - dumpDecProperty< sal_uInt32 >( 0, "OCX-TABSTRIP-TABSTYLE" ); + dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-ORIENTATION" ); + dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-TABSTYLE" ); dumpBoolProperty(); dumpHmmProperty(); dumpHmmProperty(); @@ -1150,35 +1582,43 @@ void OcxTabStripObject::implDumpShortProperties() dumpStreamProperty(); } -void OcxTabStripObject::implDumpExtended() +void AxTabStripObject::implDumpExtended() { dumpEmbeddedFont(); if( mnTabFlagCount > 0 ) { writeEmptyItem( "tab-flags" ); - IndentGuard aIndGuard( out() ); - out().resetItemIndex(); + IndentGuard aIndGuard( mxOut ); + mxOut->resetItemIndex(); for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnTabFlagCount); ++nIdx ) - dumpHex< sal_uInt32 >( "#flags", "OCX-TABSTRIP-FLAGS" ); + dumpHex< sal_uInt32 >( "#flags", "AX-TABSTRIP-FLAGS" ); } } +// ============================================================================ // ============================================================================ -OcxControlObject::OcxControlObject( const InputObjectBase& rParent, const OUString& rProgId, sal_Int64 nLength ) : - maProgId( rProgId ), - mnLength( nLength ) +FormControlStreamObject::FormControlStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const OUString* pProgId ) { - InputObjectBase::construct( rParent ); + construct( rParent, rxStrm, rSysFileName ); + constructFormCtrlStrmObj( pProgId ); } -void OcxControlObject::implDump() +FormControlStreamObject::FormControlStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString* pProgId ) { - sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int64 >( mnLength, 0 ); - if( (maProgId.getLength() > 0) && (mnLength > 0) && !in().isEof() ) + construct( rParent, rxStrm ); + constructFormCtrlStrmObj( pProgId ); +} + +void FormControlStreamObject::implDump() +{ + if( mbReadGuid ) + maProgId = cfg().getStringOption( dumpGuid(), OUString() ); + + if( (maProgId.getLength() > 0) && !mxStrm->isEof() ) { if( maProgId.equalsAscii( "Forms.CommandButton.1" ) ) - OcxCommandButtonObject( *this ).dump(); + AxCommandButtonObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.TextBox.1" ) || maProgId.equalsAscii( "Forms.ListBox.1" ) || maProgId.equalsAscii( "Forms.ComboBox.1" ) || @@ -1186,161 +1626,76 @@ void OcxControlObject::implDump() maProgId.equalsAscii( "Forms.OptionButton.1" ) || maProgId.equalsAscii( "Forms.ToggleButton.1" ) || maProgId.equalsAscii( "RefEdit.Ctrl" ) ) - OcxMorphControlObject( *this ).dump(); + AxMorphControlObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.Label.1" ) ) - OcxLabelObject( *this ).dump(); + AxLabelObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.Image.1" ) ) - OcxImageObject( *this ).dump(); + AxImageObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.ScrollBar.1" ) ) - OcxScrollBarObject( *this ).dump(); + AxScrollBarObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.SpinButton.1" ) ) - OcxSpinButtonObject( *this ).dump(); + AxSpinButtonObject( *this ).dump(); else if( maProgId.equalsAscii( "Forms.TabStrip.1" ) ) - OcxTabStripObject( *this ).dump(); + AxTabStripObject( *this ).dump(); + else if( maProgId.equalsAscii( "MSComCtl2.FlatScrollBar.2" ) ) + ComCtlScrollBarObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.ProgCtrl.1" ) ) + ComCtlProgressBarObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComctlLib.ProgCtrl.2" ) ) + ComCtlProgressBarObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.Slider.1" ) ) + ComCtlSliderObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComctlLib.Slider.2" ) ) + ComCtlSliderObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "ComCtl2.UpDown.1" ) ) + ComCtlUpDownObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComCtl2.UpDown.2" ) ) + ComCtlUpDownObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.ImageListCtrl.1" ) ) + ComCtlImageListObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComctlLib.ImageListCtrl.2" ) ) + ComCtlImageListObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.TabStrip.1" ) ) + ComCtlTabStripObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComctlLib.TabStrip.2" ) ) + ComCtlTabStripObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.TreeCtrl.1" ) ) + ComCtlTreeViewObject( *this, 5 ).dump(); + else if( maProgId.equalsAscii( "MSComctlLib.TreeCtrl.2" ) ) + ComCtlTreeViewObject( *this, 6 ).dump(); + else if( maProgId.equalsAscii( "COMCTL.SBarCtrl.1" ) ) + ComCtlStatusBarObject( *this, 5 ).dump(); else if( maProgId.equalsAscii( "StdPic" ) ) StdPicObject( *this ).dump(); } - dumpRemainingTo( nEndPos ); -} - -// ============================================================================ - -OcxGuidControlObject::OcxGuidControlObject( const InputObjectBase& rParent, sal_Int64 nLength ) : - mnLength( nLength ) -{ - InputObjectBase::construct( rParent ); -} - -OcxGuidControlObject::OcxGuidControlObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ) -{ - mnLength = rxStrm.get() ? rxStrm->getLength() : -1; - InputObjectBase::construct( rParent, rxStrm ); -} - -OcxGuidControlObject::OcxGuidControlObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) -{ - mnLength = rxStrm.get() ? rxStrm->getLength() : -1; - InputObjectBase::construct( rParent, rxStrm, rSysFileName ); -} - -void OcxGuidControlObject::implDump() -{ - OUString aProgId = cfg().getStringOption( dumpGuid(), OUString() ); - OcxControlObject( *this, aProgId, mnLength - 16 ).dump(); -} - -// ============================================================================ - -OcxControlsStreamObject::OcxControlsStreamObject( const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, OcxFormSharedData& rFormData ) : - mrFormData( rFormData ) -{ - InputObjectBase::construct( rParent, rxStrm, rSysFileName ); -} - -void OcxControlsStreamObject::implDump() -{ - for( OcxFormSiteInfoVector::iterator aIt = mrFormData.maSiteInfos.begin(), aEnd = mrFormData.maSiteInfos.end(); !in().isEof() && (aIt != aEnd); ++aIt ) - { - if( (aIt->mbInStream) && (aIt->mnLength > 0) ) - { - out().emptyLine(); - writeDecItem( "control-id", aIt->mnId ); - writeInfoItem( "prog-id", aIt->maProgId ); - IndentGuard aIndGuard( out() ); - OcxControlObject( *this, aIt->maProgId, aIt->mnLength ).dump(); - } - } dumpRemainingStream(); } -// ============================================================================ -// ============================================================================ - -OcxPageObject::OcxPageObject( const InputObjectBase& rParent ) +void FormControlStreamObject::constructFormCtrlStrmObj( const OUString* pProgId ) { - OcxPropertyObjectBase::construct( rParent, "OCX-PAGE-PROPERTIES" ); -} - -void OcxPageObject::implDumpShortProperties() -{ - dumpUnknownProperty(); - dumpDecProperty< sal_uInt32 >( 0, "OCX-PAGE-TRANSITIONEFFECT" ); - dumpDecProperty< sal_uInt32 >( 0, "OCX-CONV-MS" ); + mbReadGuid = pProgId == 0; + if( pProgId ) + maProgId = *pProgId; } // ============================================================================ - -OcxMultiPageObject::OcxMultiPageObject( const InputObjectBase& rParent ) -{ - OcxPropertyObjectBase::construct( rParent, "OCX-MULTIPAGE-PROPERTIES" ); -} - -void OcxMultiPageObject::implDumpShortProperties() -{ - dumpUnknownProperty(); - mnPageCount = dumpDecProperty< sal_Int32 >( 0 ); - dumpDecProperty< sal_Int32 >( 0 ); - dumpBoolProperty(); -} - -void OcxMultiPageObject::implDumpExtended() -{ - if( ensureValid() && (mnPageCount > 0) ) - { - writeEmptyItem( "page-ids" ); - IndentGuard aIndGuard( out() ); - out().resetItemIndex(); - for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnPageCount); ++nIdx ) - dumpDec< sal_Int32 >( "#id" ); - } -} - // ============================================================================ -OcxMultiPageStreamObject::OcxMultiPageStreamObject( const ObjectBase& rParent, - const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, OcxFormSharedData& rFormData ) : +VbaFormClassInfoObject::VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) : mrFormData( rFormData ) { - InputObjectBase::construct( rParent, rxStrm, rSysFileName ); + AxPropertyObjectBase::construct( rParent, "VBA-CLASSINFO-PROPERTIES" ); } -void OcxMultiPageStreamObject::implDump() -{ - for( size_t nIdx = 0, nCount = mrFormData.maSiteInfos.size(); !in().isEof() && (nIdx < nCount); ++nIdx ) - { - out().emptyLine(); - writeEmptyItem( "page" ); - IndentGuard aIndGuard( out() ); - OcxPageObject( *this ).dump(); - } - if( !in().isEof() ) - { - out().emptyLine(); - writeEmptyItem( "multi-page" ); - IndentGuard aIndGuard( out() ); - OcxMultiPageObject( *this ).dump(); - } - dumpRemainingStream(); -} - -// ============================================================================ -// ============================================================================ - -OcxFormClassInfoObject::OcxFormClassInfoObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ) : - mrFormData( rFormData ) -{ - OcxPropertyObjectBase::construct( rParent, "OCX-CLASSINFO-PROPERTIES" ); -} - -void OcxFormClassInfoObject::implDumpShortProperties() +void VbaFormClassInfoObject::implDumpShortProperties() { mrFormData.maClassInfoProgIds.push_back( OUString() ); dumpGuidProperty( &mrFormData.maClassInfoProgIds.back() ); dumpGuidProperty(); dumpUnknownProperty(); dumpGuidProperty(); - dumpFlagsProperty( 0, "OCX-CLASSINFO-FLAGS" ); + dumpFlagsProperty( 0, "VBA-CLASSINFO-FLAGS" ); + dumpDecProperty< sal_uInt32 >( 0 ); dumpDecProperty< sal_Int32 >( -1 ); dumpDecProperty< sal_uInt16 >( 0 ); dumpDecProperty< sal_uInt16 >( 0 ); @@ -1356,32 +1711,32 @@ void OcxFormClassInfoObject::implDumpShortProperties() namespace { -const sal_uInt32 OCX_FORMSITE_OBJSTREAM = 0x0010; +const sal_uInt32 VBA_FORMSITE_OBJSTREAM = 0x0010; -const sal_uInt16 OCX_FORMSITE_CLASSTABLEINDEX = 0x8000; -const sal_uInt16 OCX_FORMSITE_CLASSTABLEMASK = 0x7FFF; +const sal_uInt16 VBA_FORMSITE_CLASSTABLEINDEX = 0x8000; +const sal_uInt16 VBA_FORMSITE_CLASSTABLEMASK = 0x7FFF; } // namespace // ---------------------------------------------------------------------------- -OcxFormSiteObject::OcxFormSiteObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ) : +VbaFormSiteObject::VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) : mrFormData( rFormData ) { - OcxPropertyObjectBase::construct( rParent, "OCX-FORMSITE-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "VBA-FORMSITE-PROPERTIES" ); } -void OcxFormSiteObject::implDumpShortProperties() +void VbaFormSiteObject::implDumpShortProperties() { - OcxFormSiteInfo aSiteInfo; + VbaFormSiteInfo aSiteInfo; dumpStringProperty(); dumpStringProperty(); sal_Int32 nId = dumpDecProperty< sal_Int32 >( 0 ); dumpDecProperty< sal_Int32 >( 0 ); - sal_uInt32 nFlags = dumpFlagsProperty( 0x00000033, "OCX-FORMSITE-FLAGS" ); + sal_uInt32 nFlags = dumpFlagsProperty( 0x00000033, "VBA-FORMSITE-FLAGS" ); sal_uInt32 nLength = dumpDecProperty< sal_uInt32 >( 0 ); dumpDecProperty< sal_Int16 >( -1 ); - sal_uInt16 nClassId = dumpHexProperty< sal_uInt16 >( 0x7FFF, "OCX-FORMSITE-CLASSIDCACHE" ); + sal_uInt16 nClassId = dumpHexProperty< sal_uInt16 >( 0x7FFF, "VBA-FORMSITE-CLASSIDCACHE" ); dumpPosProperty(); dumpDecProperty< sal_uInt16 >( 0 ); dumpUnknownProperty(); @@ -1390,38 +1745,38 @@ void OcxFormSiteObject::implDumpShortProperties() dumpStringProperty(); dumpStringProperty(); - sal_uInt16 nIndex = nClassId & OCX_FORMSITE_CLASSTABLEMASK; - if( getFlag( nClassId, OCX_FORMSITE_CLASSTABLEINDEX ) ) + sal_uInt16 nIndex = nClassId & VBA_FORMSITE_CLASSTABLEMASK; + if( getFlag( nClassId, VBA_FORMSITE_CLASSTABLEINDEX ) ) { if( nIndex < mrFormData.maClassInfoProgIds.size() ) aSiteInfo.maProgId = mrFormData.maClassInfoProgIds[ nIndex ]; } else { - if( cfg().hasName( "OCX-FORMSITE-CLASSNAMES", nIndex ) ) - aSiteInfo.maProgId = cfg().getName( "OCX-FORMSITE-CLASSNAMES", nIndex ); + if( cfg().hasName( "VBA-FORMSITE-CLASSNAMES", nIndex ) ) + aSiteInfo.maProgId = cfg().getName( "VBA-FORMSITE-CLASSNAMES", nIndex ); } aSiteInfo.mnId = nId; aSiteInfo.mnLength = nLength; - aSiteInfo.mbInStream = getFlag( nFlags, OCX_FORMSITE_OBJSTREAM ); + aSiteInfo.mbInStream = getFlag( nFlags, VBA_FORMSITE_OBJSTREAM ); mrFormData.maSiteInfos.push_back( aSiteInfo ); } // ============================================================================ -OcxFormDesignExtObject::OcxFormDesignExtObject( const InputObjectBase& rParent ) +VbaFormDesignExtObject::VbaFormDesignExtObject( const InputObjectBase& rParent ) { - OcxPropertyObjectBase::construct( rParent, "OCX-FORMDESIGNEXT-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, "VBA-FORMDESIGNEXT-PROPERTIES" ); } -void OcxFormDesignExtObject::implDumpShortProperties() +void VbaFormDesignExtObject::implDumpShortProperties() { - dumpFlagsProperty( 0x00015F55, "OCX-FORMDESIGNEXT-FLAGS" ); + dumpFlagsProperty( 0x00015F55, "VBA-FORMDESIGNEXT-FLAGS" ); dumpHmmProperty(); dumpHmmProperty(); - dumpDecProperty< sal_Int8 >( 0, "OCX-FORMDESIGNEXT-CLICKCTRLMODE" ); - dumpDecProperty< sal_Int8 >( 0, "OCX-FORMDESIGNEXT-DBLCLICKCTRLMODE" ); + dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-CLICKCTRLMODE" ); + dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-DBLCLICKCTRLMODE" ); } // ============================================================================ @@ -1438,13 +1793,13 @@ const sal_uInt8 OCX_FORM_SITECOUNTTYPE_MASK = 0x7F; // ---------------------------------------------------------------------------- -OcxFormObject::OcxFormObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, OcxFormSharedData& rFormData ) : +VbaFStreamObject::VbaFStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) : mrFormData( rFormData ) { - OcxPropertyObjectBase::construct( rParent, rxStrm, rSysFileName, "OCX-FORM-PROPERTIES" ); + AxPropertyObjectBase::construct( rParent, rxStrm, rSysFileName, "VBA-FORM-PROPERTIES" ); } -void OcxFormObject::implDumpShortProperties() +void VbaFStreamObject::implDumpShortProperties() { dumpUnknownProperty(); dumpColorProperty( 0x8000000F ); @@ -1452,17 +1807,17 @@ void OcxFormObject::implDumpShortProperties() dumpDecProperty< sal_uInt32 >( 0 ); dumpUnknownProperty(); dumpUnknownProperty(); - mnFlags = dumpFlagsProperty( 0x00000004, "OCX-FORM-FLAGS" ); + mnFlags = dumpFlagsProperty( 0x00000004, "VBA-FORM-FLAGS" ); dumpBorderStyleProperty< sal_uInt8 >( 0 ); dumpMousePtrProperty(); - dumpHexProperty< sal_uInt8 >( 0x0C, "OCX-FORM-SCROLLBARS" ); + dumpHexProperty< sal_uInt8 >( 0x0C, "VBA-FORM-SCROLLBARS" ); dumpSizeProperty(); dumpSizeProperty(); dumpPosProperty(); dumpDecProperty< sal_uInt32 >( 0 ); dumpUnknownProperty(); dumpStreamProperty(); - dumpDecProperty< sal_uInt8 >( 0, "OCX-FORM-CYCLE" ); + dumpDecProperty< sal_uInt8 >( 0, "VBA-FORM-CYCLE" ); dumpSpecialEffectProperty< sal_uInt8 >( 0 ); dumpColorProperty( 0x80000012 ); dumpStringProperty(); @@ -1476,7 +1831,7 @@ void OcxFormObject::implDumpShortProperties() dumpDecProperty< sal_uInt32 >( 0 ); } -void OcxFormObject::implDumpExtended() +void VbaFStreamObject::implDumpExtended() { dumpClassInfos(); dumpSiteData(); @@ -1484,54 +1839,54 @@ void OcxFormObject::implDumpExtended() dumpRemainingStream(); } -void OcxFormObject::dumpClassInfos() +void VbaFStreamObject::dumpClassInfos() { if( ensureValid() && !getFlag( mnFlags, OCX_FORM_SKIPCLASSTABLE ) ) { - out().emptyLine(); + mxOut->emptyLine(); sal_uInt16 nCount = dumpDec< sal_uInt16 >( "class-info-count" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx ) { writeEmptyItem( "#class-info" ); - IndentGuard aIndGuard( out() ); - OcxFormClassInfoObject( *this, mrFormData ).dump(); + IndentGuard aIndGuard( mxOut ); + VbaFormClassInfoObject( *this, mrFormData ).dump(); } } } -void OcxFormObject::dumpFormSites( sal_uInt32 nCount ) +void VbaFStreamObject::dumpFormSites( sal_uInt32 nCount ) { - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt32 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx ) { - out().emptyLine(); + mxOut->emptyLine(); writeEmptyItem( "#form-site" ); - IndentGuard aIndGuard( out() ); - OcxFormSiteObject( *this, mrFormData ).dump(); + IndentGuard aIndGuard( mxOut ); + VbaFormSiteObject( *this, mrFormData ).dump(); } } -void OcxFormObject::dumpSiteData() +void VbaFStreamObject::dumpSiteData() { if( ensureValid() ) { - out().emptyLine(); + mxOut->emptyLine(); setAlignAnchor(); sal_uInt32 nSiteCount = dumpDec< sal_uInt32 >( "site-count" ); sal_uInt32 nSiteLength = dumpDec< sal_uInt32 >( "site-data-size" ); - sal_Int64 nEndPos = in().tell() + nSiteLength; - if( ensureValid( nEndPos <= in().getLength() ) ) + sal_Int64 nEndPos = mxStrm->tell() + nSiteLength; + if( ensureValid( nEndPos <= mxStrm->getLength() ) ) { - out().resetItemIndex(); + mxOut->resetItemIndex(); sal_uInt32 nSiteIdx = 0; while( ensureValid() && (nSiteIdx < nSiteCount) ) { - out().emptyLine(); + mxOut->emptyLine(); writeEmptyItem( "#site-info" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpDec< sal_uInt8 >( "depth" ); - sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "OCX-FORM-SITE-TYPECOUNT" ); + sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "VBA-FORM-SITE-TYPECOUNT" ); if( getFlag( nTypeCount, OCX_FORM_SITECOUNTTYPE_COUNT ) ) { dumpDec< sal_uInt8 >( "repeated-type" ); @@ -1549,46 +1904,141 @@ void OcxFormObject::dumpSiteData() } } -void OcxFormObject::dumpDesignExtender() +void VbaFStreamObject::dumpDesignExtender() { if( ensureValid() && getFlag( mnFlags, OCX_FORM_HASDESIGNEXTENDER ) ) { - out().emptyLine(); + mxOut->emptyLine(); writeEmptyItem( "design-extender" ); - IndentGuard aIndGuard( out() ); - OcxFormDesignExtObject( *this ).dump(); + IndentGuard aIndGuard( mxOut ); + VbaFormDesignExtObject( *this ).dump(); + } +} + +// ============================================================================ + +VbaOStreamObject::VbaOStreamObject( const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) : + mrFormData( rFormData ) +{ + OleInputObjectBase::construct( rParent, rxStrm, rSysFileName ); +} + +void VbaOStreamObject::implDump() +{ + for( VbaFormSiteInfoVector::iterator aIt = mrFormData.maSiteInfos.begin(), aEnd = mrFormData.maSiteInfos.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt ) + { + if( (aIt->mbInStream) && (aIt->mnLength > 0) ) + { + mxOut->emptyLine(); + writeDecItem( "control-id", aIt->mnId ); + writeInfoItem( "prog-id", aIt->maProgId ); + IndentGuard aIndGuard( mxOut ); + RelativeInputStreamRef xRelStrm( new RelativeInputStream( *mxStrm, aIt->mnLength ) ); + FormControlStreamObject( *this, xRelStrm, &aIt->maProgId ).dump(); + } } + dumpRemainingStream(); +} + +// ============================================================================ + +VbaPageObject::VbaPageObject( const InputObjectBase& rParent ) +{ + AxPropertyObjectBase::construct( rParent, "VBA-PAGE-PROPERTIES" ); +} + +void VbaPageObject::implDumpShortProperties() +{ + dumpUnknownProperty(); + dumpDecProperty< sal_uInt32 >( 0, "VBA-PAGE-TRANSITIONEFFECT" ); + dumpDecProperty< sal_uInt32 >( 0, "AX-CONV-MS" ); } // ============================================================================ -OcxFormStorageObject::OcxFormStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) : +VbaMultiPageObject::VbaMultiPageObject( const InputObjectBase& rParent ) +{ + AxPropertyObjectBase::construct( rParent, "VBA-MULTIPAGE-PROPERTIES" ); +} + +void VbaMultiPageObject::implDumpShortProperties() +{ + dumpUnknownProperty(); + mnPageCount = dumpDecProperty< sal_Int32 >( 0 ); + dumpDecProperty< sal_Int32 >( 0 ); + dumpBoolProperty(); +} + +void VbaMultiPageObject::implDumpExtended() +{ + if( ensureValid() && (mnPageCount > 0) ) + { + writeEmptyItem( "page-ids" ); + IndentGuard aIndGuard( mxOut ); + mxOut->resetItemIndex(); + for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnPageCount); ++nIdx ) + dumpDec< sal_Int32 >( "#id" ); + } +} + +// ============================================================================ + +VbaXStreamObject::VbaXStreamObject( const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) : + mrFormData( rFormData ) +{ + InputObjectBase::construct( rParent, rxStrm, rSysFileName ); +} + +void VbaXStreamObject::implDump() +{ + for( size_t nIdx = 0, nCount = mrFormData.maSiteInfos.size(); !mxStrm->isEof() && (nIdx < nCount); ++nIdx ) + { + mxOut->emptyLine(); + writeEmptyItem( "page" ); + IndentGuard aIndGuard( mxOut ); + VbaPageObject( *this ).dump(); + } + if( !mxStrm->isEof() ) + { + mxOut->emptyLine(); + writeEmptyItem( "multi-page" ); + IndentGuard aIndGuard( mxOut ); + VbaMultiPageObject( *this ).dump(); + } + dumpRemainingStream(); +} + +// ============================================================================ + +VbaContainerStorageObject::VbaContainerStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) : OleStorageObject( rParent, rxStrg, rSysPath ) { addPreferredStream( "f" ); } -void OcxFormStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) +void VbaContainerStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) { if( rStrmName.equalsAscii( "f" ) ) - OcxFormObject( *this, rxStrm, rSysFileName, maFormData ).dump(); + VbaFStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); else if( rStrmName.equalsAscii( "o" ) ) - OcxControlsStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); + VbaOStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); else if( rStrmName.equalsAscii( "x" ) ) - OcxMultiPageStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); + VbaXStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); else OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); } -void OcxFormStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) +void VbaContainerStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) { if( isFormStorage( rStrgPath ) ) - OcxFormStorageObject( *this, rxStrg, rSysPath ).dump(); + VbaContainerStorageObject( *this, rxStrg, rSysPath ).dump(); else OleStorageObject( *this, rxStrg, rSysPath ).dump(); } -bool OcxFormStorageObject::isFormStorage( const OUString& rStrgPath ) const +bool VbaContainerStorageObject::isFormStorage( const OUString& rStrgPath ) const { if( (rStrgPath.getLength() >= 3) && (rStrgPath[ 0 ] == 'i') ) { @@ -1597,7 +2047,7 @@ bool OcxFormStorageObject::isFormStorage( const OUString& rStrgPath ) const aId = aId.copy( 1 ); sal_Int32 nId = aId.toInt32(); if( (nId > 0) && (OUString::valueOf( nId ) == aId) ) - for( OcxFormSiteInfoVector::const_iterator aIt = maFormData.maSiteInfos.begin(), aEnd = maFormData.maSiteInfos.end(); aIt != aEnd; ++aIt ) + for( VbaFormSiteInfoVector::const_iterator aIt = maFormData.maSiteInfos.begin(), aEnd = maFormData.maSiteInfos.end(); aIt != aEnd; ++aIt ) if( aIt->mnId == nId ) return true; } @@ -1608,7 +2058,7 @@ bool OcxFormStorageObject::isFormStorage( const OUString& rStrgPath ) const // ============================================================================ VbaSharedData::VbaSharedData() : - meTextEnc( osl_getThreadTextEncoding() ) + meTextEnc( RTL_TEXTENCODING_MS_1252 ) { } @@ -1659,7 +2109,7 @@ void VbaDirStreamObject::implDumpRecordBody() switch( getRecId() ) { case 0x0003: - mrVbaData.meTextEnc = ::oox::xls::BiffHelper::calcTextEncodingFromCodePage( dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ) ); + mrVbaData.meTextEnc = rtl_getTextEncodingFromWindowsCodePage( dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ) ); break; case 0x0004: dumpByteString( "name" ); @@ -1730,7 +2180,7 @@ void VbaDirStreamObject::implDumpRecordBody() dumpUniString( "constants" ); break; case 0x003D: - dumpUniString( "helpfile-path" ); + dumpByteString( "helpfile-path" ); break; case 0x003E: dumpUniString( "name" ); @@ -1759,7 +2209,7 @@ OUString VbaDirStreamObject::dumpUniString( const String& rName ) OUString VbaDirStreamObject::dumpByteStringWithLength( const String& rName ) { - return dumpCharArray( rName, in().readInt32(), mrVbaData.meTextEnc ); + return dumpCharArray( rName, mxStrm->readInt32(), mrVbaData.meTextEnc ); } // ============================================================================ @@ -1776,10 +2226,10 @@ VbaModuleStreamObject::VbaModuleStreamObject( void VbaModuleStreamObject::implDump() { dumpBinary( "perf-cache", mnStrmOffset ); - out().emptyLine(); + mxOut->emptyLine(); writeEmptyItem( "source-code" ); - IndentGuard aIndGuard( out() ); - BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( in() ) ); + IndentGuard aIndGuard( mxOut ); + BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxStrm ) ); TextStreamObject( *this, xVbaStrm, mrVbaData.meTextEnc ).dump(); } @@ -1805,7 +2255,7 @@ void VbaStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const // ============================================================================ VbaFormStorageObject::VbaFormStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) : - OcxFormStorageObject( rParent, rxStrg, rSysPath ), + VbaContainerStorageObject( rParent, rxStrg, rSysPath ), mrVbaData( rVbaData ) { } @@ -1815,7 +2265,7 @@ void VbaFormStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, c if( rStrmName.equalsAscii( "\003VBFrame" ) ) TextStreamObject( *this, rxStrm, mrVbaData.meTextEnc, rSysFileName ).dump(); else - OcxFormStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); + VbaContainerStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); } // ============================================================================ @@ -1845,6 +2295,19 @@ void VbaProjectStorageObject::implDumpStorage( const StorageRef& rxStrg, const O // ============================================================================ // ============================================================================ +ActiveXStorageObject::ActiveXStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) : + VbaContainerStorageObject( rParent, rxStrg, rSysPath ) +{ +} + +void ActiveXStorageObject::implDumpBaseStream( const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) +{ + FormControlStreamObject( *this, rxStrm, rSysFileName ).dump(); +} + +// ============================================================================ +// ============================================================================ + } // namespace dump } // namespace oox diff --git a/oox/source/dump/oledumper.ini b/oox/source/dump/oledumper.ini index c398b0c01e51..7efe424b0ddc 100644 --- a/oox/source/dump/oledumper.ini +++ b/oox/source/dump/oledumper.ini @@ -4,7 +4,39 @@ # Path to additional configuration data, relative to this file. include-config-file=dumperbase.ini -# StdFont ==================================================================== +# OLE name lists ============================================================= + +constlist=OLE-STD-CLIPBOARD-FORMAT + 2=bmp + 3=wmf + 8=dib + 14=emf +end + +combilist=OLE-COLOR + 0x0000FFFF=uint32,dec,palette-index,,filter=0xFF000000~0x01000000 + 0x000000FF=uint32,dec,red,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 + 0x0000FF00=uint32,dec,green,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 + 0x00FF0000=uint32,dec,blue,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 + 0x0000FFFF=uint32,dec,system-color,SYSTEMCOLOR,filter=0xFF000000~0x80000000 + 0xFF000000=uint8,dec,type,OLE-COLORTYPE +end + +constlist=OLE-COLORTYPE + 0x00=default + 0x01=palette + 0x02=rgb + 0x80=system-color +end + +multilist=OLE-MOUSEPTR + 0=default,arrow,cross,i-beam + 6=size-diag-down,size-vert,size-diag-up,size-hor + 10=up-arrow,hour-glass,no-drop,app-starting,help,size-all + 99=custom +end + +# StdFont -------------------------------------------------------------------- {0BE35203-8F91-11CE-9DE3-00AA004BB851}=StdFont @@ -17,11 +49,13 @@ end unitconverter=STDFONT-HEIGHT,/10000,pt -# StdPic ===================================================================== +# StdPic --------------------------------------------------------------------- {0BE35204-8F91-11CE-9DE3-00AA004BB851}=StdPic -# StdHlink =================================================================== +shortlist=STDPIC-ID,0x0000746C,StdPic + +# StdHlink ------------------------------------------------------------------- {79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}=StdHlink {79EAC9E0-BAF9-11CE-8C82-00AA004BA90B}=URLMoniker @@ -62,7 +96,7 @@ flagslist=STDHLINK-URL-FLAGS 0x00008000=no-encode-forbidden-chars end -# OLE name lists ============================================================= +# OLE property stream -------------------------------------------------------- {F29F85E0-4FF9-1068-AB91-08002B27B3D9}=GlobalDocProp {D5CDD502-2E9C-101B-9397-08002B2CF9AE}=BuiltinDocProp @@ -110,37 +144,210 @@ combilist=OLEPROP-TYPE 0x4000=byref end -# OCX name lists ============================================================= +# ComCtl controls ============================================================ + +constlist=COMCTL-HEADER-IDS + 0x0A2BAE11=COMCTL_SLIDER_60 + 0x12344321=COMCTL_SIZE + 0x6AC13CB1=COMCTL_TREEVIEW_60 + 0x97AB8A01=COMCTL_PROGRESSBAR_60 + 0x99470A83=COMCTL_SCROLLBAR_60 + 0xABCDEF01=COMCTL_COMMONDATA + 0xBDECDE1F=COMCTL_COMPLEXDATA + 0xD12A7AC1=COMCTL_TABSTRIP_60 + 0xE6E17E80=COMCTL_IMAGELIST_50_60 + 0xE6E17E84=COMCTL_PROGRESSBAR_50 + 0xE6E17E86=COMCTL_SLIDER_50 + 0xE6E17E88=COMCTL_STATUSBAR_50 + 0xE6E17E8A=COMCTL_TABSTRIP_50 + 0xE6E17E8E=COMCTL_TREEVIEW_50 + 0xFF3626A0=COMCTL_UPDOWN_50_60 +end + +combilist=COMCTL-COMMON-FLAGS + ignore=0xFFFF8000 + 0x00000001=flat-border + 0x00000002=enabled + 0x00000004=3d-border + 0x000007F8=uint8,dec,mouse-ptr,OLE-MOUSEPTR + 0x00000800=ole-drag-auto + 0x00002000=ole-drop-manual +end + +flagslist=COMCTL-COMPLEX-FLAGS + ignore=0xFFFFFFFC + 0x00000001=font + 0x00000002=mouse-icon +end + +# flat scrollbar ------------------------------------------------------------- + +{FE38753A-44A3-11D1-B5B7-0000C09000C4}=MSComCtl2.FlatScrollBar.2 + +combilist=COMCTL-SCROLLBAR-FLAGS + 0x00000003=uint8,dec,appearance,COMCTL-SCROLLBAR-APPEARANCE + 0x0000000C=uint8,dec,arrows,COMCTL-SCROLLBAR-ARROWS + 0x00000010=!vertical!horizontal +end + +shortlist=COMCTL-SCROLLBAR-APPEARANCE,0,3d,flat,track-3d +shortlist=COMCTL-SCROLLBAR-ARROWS,0,both,left-up,right-down + +# progress bar --------------------------------------------------------------- {0713E8D2-850A-101B-AFC0-4210102A8DA7}=COMCTL.ProgCtrl.1 +{35053A22-8589-11D1-B16A-00C0F0283628}=MSComctlLib.ProgCtrl.2 -combilist=OCX-COLOR - 0x0000FFFF=uint32,dec,palette-index,,filter=0xFF000000~0x01000000 - 0x000000FF=uint32,dec,red,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 - 0x0000FF00=uint32,dec,green,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 - 0x00FF0000=uint32,dec,blue,,filter=0xFF000000~0x00000000,filter=0xFF000000~0x02000000 - 0x0000FFFF=uint32,dec,system-color,SYSTEMCOLOR,filter=0xFF000000~0x80000000 - 0xFF000000=uint8,dec,type,OCX-COLORTYPE +# slider --------------------------------------------------------------------- + +{373FF7F0-EB8B-11CD-8820-08002B2F4F5A}=COMCTL.Slider.1 +{F08DF954-8592-11D1-B16A-00C0F0283628}=MSComctlLib.Slider.2 + +constlist=COMCTL-SLIDER-SELECTRANGE + 0x00000000=off + 0x0000FFFF=on + end + +shortlist=COMCTL-SLIDER-TICKSTYLE,0,bottom-right,top-left,both,no-ticks + +# updown --------------------------------------------------------------------- + +{026371C0-1B7C-11CF-9D53-00AA003C9CB6}=ComCtl2.UpDown.1 +{603C7E80-87C2-11D1-8BE3-0000F8754DA1}=MSComCtl2.UpDown.2 + +flagslist=COMCTL-UPDOWN-FLAGS1 + 0x00000001=!align-left!align-right + 0x00000004=!vertical!horizontal + end + +flagslist=COMCTL-UPDOWN-FLAGS2 + 0x00000004=wrap + 0x00000020=ole-drop-manual + 0x00000080=enabled + end + +# image list ----------------------------------------------------------------- + +{58DA8D8F-9D6A-101B-AFC0-4210102A8DA7}=COMCTL.ImageListCtrl.1 +{2C247F23-8591-11D1-B16A-00C0F0283628}=MSComctlLib.ImageListCtrl.2 + +flagslist=COMCTL-IMAGELIST-TEXTFLAGS + 0x01=key + 0x02=tag end -constlist=OCX-COLORTYPE - 0x00=default - 0x01=palette - 0x02=rgb - 0x80=system-color +# tab strip ------------------------------------------------------------------ + +{9ED94440-E5E8-101B-B9B5-444553540000}=COMCTL.TabStrip.1 +{1EFB6596-857C-11D1-B16A-00C0F0283628}=MSComctlLib.TabStrip.2 + +combilist=COMCTL-TABSTRIP-FLAGS1 + ignore=0xFFFFFFE0 + 0x00000001=multi-row + 0x00000002=show-tooltips + 0x00000018=uint8,dec,tab-width-style,COMCTL-TABSTRIP-TABWIDTHSTYLE +end + +combilist=COMCTL-TABSTRIP-FLAGS2 + ignore=0xFFFF0000 + 0x00000003=uint8,dec,style,COMCTL-TABSTRIP-STYLE + 0x00000004=hot-tracking + 0x00000008=multi-select + 0x00000030=uint8,dec,placement,COMCTL-TABSTRIP-PLACEMENT + 0x00000040=separators +end + +flagslist=COMCTL-TABSTRIP-FLAGS3 + ignore=0xFFFF0000 + 0x00000001=tabstyle-opposite +end + +shortlist=COMCTL-TABSTRIP-TABWIDTHSTYLE,0,justified,non-justified,fixed +shortlist=COMCTL-TABSTRIP-STYLE,0,tabs,tab-buttons,flat-buttons +shortlist=COMCTL-TABSTRIP-PLACEMENT,0,top,bottom,left,right + +flagslist=COMCTL-TABSTRIP-TABFLAGS + 0x00000001=caption + 0x00000002=key + 0x00000004=tag + 0x00000008=tooltip +end + +# tree view ------------------------------------------------------------------ + +{0713E8A2-850A-101B-AFC0-4210102A8DA7}=COMCTL.TreeCtrl.1 +{C74190B6-8589-11D1-B16A-00C0F0283628}=MSComctlLib.TreeCtrl.2 + +combilist=COMCTL-TREEVIEW-FLAGS + ignore=0xFFFF0000 + 0x00000001=!tree-lines!root-lines + 0x0000001C=uint8,dec,style,COMCTL-TREEVIEW-STYLE + 0x00000020=label-edit + 0x00000080=hide-selection + 0x00000100=sorted +end + +flagslist=COMCTL-TREEVIEW-STRINGFLAGS + ignore=0xFFFFFFF8 + 0x00000001=separator + 0x00000002=image-list +end + +shortlist=COMCTL-TREEVIEW-STYLE,0,text,pic-text,plusminus-text,plusminus-pic-text,treelines-text,treelines-pic-text,treelines-plusminus-text,treelines-plusminus-pic-text + +flagslist=COMCTL-TREEVIEW-FLAGS2 + 0x00000001=checkboxes + 0x00000002=full-row-select + 0x00000004=hot-tracking + 0x00000008=scroll + 0x00000010=single-select +end + +# status bar ----------------------------------------------------------------- + +{6B7E638F-850A-101B-AFC0-4210102A8DA7}=COMCTL.SBarCtrl.1 + +combilist=COMCTL-STATUSBAR-PANELFLAGS + ignore=0xFFFFF000 + 0x00000007=uint8,dec,style,COMCTL-STATUSBAR-STYLE + 0x00000018=uint8,dec,alignment,COMCTL-STATUSBAR-ALIGN + 0x00000060=uint8,dec,bevel,COMCTL-STATUSBAR-BEVEL + 0x00000080=enabled + 0x00000300=uint8,dec,autosize,COMCTL-STATUSBAR-AUTOSIZE + 0x00000400=visible +end + +shortlist=COMCTL-STATUSBAR-STYLE,0,text,caps,num,ins,scrl,time,date,kana +shortlist=COMCTL-STATUSBAR-ALIGN,0,left,center,right +shortlist=COMCTL-STATUSBAR-BEVEL,0,no-bevel,inset,raised +shortlist=COMCTL-STATUSBAR-AUTOSIZE,0,no-auto,spring,content + +flagslist=COMCTL-STATUSBAR-TEXTFLAGS + 0x00000001=text + 0x00000002=vis-text + 0x00000004=key + 0x00000008=tag + 0x00000010=tooltip end -combilist=OCX-STRINGLEN +# other controls ============================================================= + +# Microsoft Web Browser +{8856F961-340A-11D0-A96B-00C04FD705A2}=Shell.Explorer.2 + +# ActiveX name lists ========================================================= + +combilist=AX-STRINGLEN 0x80000000=!unicode!compressed 0x7FFFFFFF=int32,dec,buffer-size end -combilist=OCX-ARRAYSTRINGLEN +combilist=AX-ARRAYSTRINGLEN 0x80000000=!unicode!compressed 0x7FFFFFFF=int32,dec,len end -combilist=OCX-FLAGS +combilist=AX-FLAGS 0x00000001=reserved-1 0x00000002=enabled 0x00000004=locked @@ -151,7 +358,7 @@ combilist=OCX-FLAGS 0x00001000=existing-entries-only 0x00002000=caption-left 0x00004000=editable - 0x00078000=uint8,dec,ime-mode,OCX-IMEMODE + 0x00078000=uint8,dec,ime-mode,AX-IMEMODE 0x00080000=drag-enabled 0x00100000=enter-as-newline 0x00200000=keep-selection @@ -166,7 +373,7 @@ combilist=OCX-FLAGS 0x80000000=multi-line end -multilist=OCX-IMEMODE +multilist=AX-IMEMODE 0=no-control,on,off,disabled 4=hiragana,fillwidth-katakana,halfwidth-katakana 7=fullwidth-alpha,halfwidth-alpha @@ -174,33 +381,26 @@ multilist=OCX-IMEMODE 11=fullwidth-hanzi,halfwidth-hanzi end -multilist=OCX-MOUSEPTR - 0=default,arrow,cross,i-beam - 6=size-diag-down,size-vert,size-diag-up,size-hor - 10=up-arrow,hour-glass,no-drop,app-starting,help,size-all - 99=custom +combilist=AX-IMAGEPOS + 0x0000FFFF=uint16,dec,image,AX-POS + 0xFFFF0000=uint16,dec,label,AX-POS end -combilist=OCX-IMAGEPOS - 0x0000FFFF=uint16,dec,image,OCX-POS - 0xFFFF0000=uint16,dec,label,OCX-POS -end - -unitconverter=OCX-CONV-MS,1,ms +unitconverter=AX-CONV-MS,1,ms -shortlist=OCX-ENABLED,0,disabled,enabled -shortlist=OCX-BORDERSTYLE,0,none,single -shortlist=OCX-SPECIALEFFECT,0,flat,raised,sunken,etched,,,bump -shortlist=OCX-ORIENTATION,-1,auto,vertical,horizontal -shortlist=OCX-POS,0,top-left,top,top-right,left,center,right,bottom-left,bottom,bottom-right -shortlist=OCX-IMAGEALIGN,0,top-left,top-right,center,bottom-left,bottom-right -shortlist=OCX-IMAGESIZEMODE,0,clip,stretch,,stretch-ratio +shortlist=AX-ENABLED,0,disabled,enabled +shortlist=AX-BORDERSTYLE,0,none,single +shortlist=AX-SPECIALEFFECT,0,flat,raised,sunken,etched,,,bump +shortlist=AX-ORIENTATION,-1,auto,vertical,horizontal +shortlist=AX-POS,0,top-left,top,top-right,left,center,right,bottom-left,bottom,bottom-right +shortlist=AX-IMAGEALIGN,0,top-left,top-right,center,bottom-left,bottom-right +shortlist=AX-IMAGESIZEMODE,0,clip,stretch,,stretch-ratio # CFontNew ------------------------------------------------------------------- {AFC20920-DA4E-11CE-B94300AA006887B4}=CFontNew -flagslist=OCX-CFONTNEW-PROPERTIES +flagslist=AX-CFONTNEW-PROPERTIES 0x0001=font-name 0x0002=flags 0x0004=font-size @@ -211,7 +411,7 @@ flagslist=OCX-CFONTNEW-PROPERTIES 0x0080=font-weight end -flagslist=OCX-CFONTNEW-FLAGS +flagslist=AX-CFONTNEW-FLAGS 0x00000001=bold 0x00000002=italic 0x00000004=underline @@ -221,11 +421,11 @@ flagslist=OCX-CFONTNEW-FLAGS 0x40000000=auto-color end -shortlist=OCX-CFONTNEW-ALIGNMENT,1,left,right,center +shortlist=AX-CFONTNEW-ALIGNMENT,1,left,right,center # column info ---------------------------------------------------------------- -flagslist=OCX-COLUMNINFO-PROPERTIES +flagslist=AX-COLUMNINFO-PROPERTIES 0x00000001=column-width end @@ -233,7 +433,7 @@ end {D7053240-CE69-11CD-A777-00DD01143C57}=Forms.CommandButton.1 -flagslist=OCX-COMMANDBUTTON-PROPERTIES +flagslist=AX-COMMANDBUTTON-PROPERTIES 0x00000001=text-color 0x00000002=fill-color 0x00000004=flags @@ -257,7 +457,7 @@ end {8BD21D60-EC42-11CE-9E0D-00AA006002F3}=Forms.ToggleButton.1 {00024512-0000-0000-C000-000000000046}=RefEdit.Ctrl -flagslist=OCX-MORPH-PROPERTIES +flagslist=AX-MORPH-PROPERTIES 0x0000000000000001=flags 0x0000000000000002=fill-color 0x0000000000000004=text-color @@ -291,26 +491,26 @@ flagslist=OCX-MORPH-PROPERTIES 0x0000000100000000=groupname end -shortlist=OCX-MORPH-SCROLLBARS,0,none,horizontal,vertical,both -shortlist=OCX-MORPH-CONTROLTYPE,1,edit,listbox,combobox,checkbox,optionbutton,togglebutton,dropdown-listbox -shortlist=OCX-MORPH-MATCHENTRYTYPE,0,first-letter,complete,none -shortlist=OCX-MORPH-LISTSTYLE,0,plain,with-buttons -shortlist=OCX-MORPH-SHOWDROPDOWNMODE,0,never,on-focus,always -shortlist=OCX-MORPH-DROPDOWNSTYLE,0,no-symbol,arrow,ellipsis,underline -shortlist=OCX-MORPH-SELECTIONTYPE,0,single,multi,range +shortlist=AX-MORPH-SCROLLBARS,0,none,horizontal,vertical,both +shortlist=AX-MORPH-CONTROLTYPE,1,edit,listbox,combobox,checkbox,optionbutton,togglebutton,dropdown-listbox +shortlist=AX-MORPH-MATCHENTRYTYPE,0,first-letter,complete,none +shortlist=AX-MORPH-LISTSTYLE,0,plain,with-buttons +shortlist=AX-MORPH-SHOWDROPDOWNMODE,0,never,on-focus,always +shortlist=AX-MORPH-DROPDOWNSTYLE,0,no-symbol,arrow,ellipsis,underline +shortlist=AX-MORPH-SELECTIONTYPE,0,single,multi,range -constlist=OCX-MORPH-BOUNDCOLUMN +constlist=AX-MORPH-BOUNDCOLUMN default= 0=value-is-row-index end -constlist=OCX-MORPH-TEXTCOLUMN +constlist=AX-MORPH-TEXTCOLUMN default= -1=first-column-with-width 0=row-numbers end -constlist=OCX-MORPH-COLUMNCOUNT +constlist=AX-MORPH-COLUMNCOUNT default= -1=all-columns end @@ -319,7 +519,7 @@ end {978C9E23-D4B0-11CE-BF2D-00AA003F40D0}=Forms.Label.1 -flagslist=OCX-LABEL-PROPERTIES +flagslist=AX-LABEL-PROPERTIES 0x00000001=text-color 0x00000002=fill-color 0x00000004=flags @@ -339,7 +539,7 @@ end {4C599241-6926-101B-9992-00000B65C6F9}=Forms.Image.1 -flagslist=OCX-IMAGE-PROPERTIES +flagslist=AX-IMAGE-PROPERTIES 0x00000004=auto-size 0x00000008=border-color 0x00000010=fill-color @@ -359,7 +559,7 @@ end {DFD181E0-5E2F-11CE-A449-00AA004A803D}=Forms.ScrollBar.1 -flagslist=OCX-SCROLLBAR-PROPERTIES +flagslist=AX-SCROLLBAR-PROPERTIES 0x00000001=arrow-color 0x00000002=fill-color 0x00000004=flags @@ -379,13 +579,13 @@ flagslist=OCX-SCROLLBAR-PROPERTIES 0x00010000=mouse-icon end -shortlist=OCX-SCROLLBAR-PROPTHUMB,-1,proportional,fixed +shortlist=AX-SCROLLBAR-PROPTHUMB,-1,proportional,fixed # spin button ---------------------------------------------------------------- {79176FB0-B7F2-11CE-97EF-00AA006D2776}=Forms.SpinButton.1 -flagslist=OCX-SPINBUTTON-PROPERTIES +flagslist=AX-SPINBUTTON-PROPERTIES 0x00000001=arrow-color 0x00000002=fill-color 0x00000004=flags @@ -407,7 +607,7 @@ end {EAE50EB0-4A62-11CE-BED6-00AA00611080}=Forms.TabStrip.1 -flagslist=OCX-TABSTRIP-PROPERTIES +flagslist=AX-TABSTRIP-PROPERTIES 0x00000001=selected-tab 0x00000002=fill-color 0x00000004=text-color @@ -431,40 +631,19 @@ flagslist=OCX-TABSTRIP-PROPERTIES 0x01000000=mouse-icon end -shortlist=OCX-TABSTRIP-ORIENTATION,0,top,bottom,left,right -shortlist=OCX-TABSTRIP-TABSTYLE,0,tabs,buttons,none +shortlist=AX-TABSTRIP-ORIENTATION,0,top,bottom,left,right +shortlist=AX-TABSTRIP-TABSTYLE,0,tabs,buttons,none -flagslist=OCX-TABSTRIP-FLAGS +flagslist=AX-TABSTRIP-FLAGS 0x00000001=visible 0x00000002=enabled end -# frame ---------------------------------------------------------------------- - -{6E182020-F460-11CE-9BCD-00AA00608E01}=Forms.Frame.1 - -# page ----------------------------------------------------------------------- - -flagslist=OCX-PAGE-PROPERTIES - 0x00000002=transition-effect - 0x00000004=transition-period -end - -shortlist=OCX-PAGE-TRANSITIONEFFECT,0,none,cover-up,cover-right-up,cover-right,cover-right-down,cover-down,cover-left-down,cover-left,cover-left-up,push-up,push-right,push-down,push-left - -# multi page ----------------------------------------------------------------- - -{46E31370-3F7A-11CE-BED6-00AA00611080}=Forms.MultiPage.1 - -flagslist=OCX-MULTIPAGE-PROPERTIES - 0x00000002=page-count - 0x00000004=id - 0x00000008=enabled -end +# VBA forms ================================================================== # form class info ------------------------------------------------------------ -flagslist=OCX-CLASSINFO-PROPERTIES +flagslist=VBA-CLASSINFO-PROPERTIES 0x00000001=class-id 0x00000002=disp-event 0x00000008=default-prog @@ -481,18 +660,18 @@ flagslist=OCX-CLASSINFO-PROPERTIES 0x00004000=set-rowset end -combilist=OCX-CLASSINFO-FLAGS - 0x0000FFFF=uint16,hex,classtable-flags,OCX-CLASSTABLE-CLASSFLAGS - 0xFFFF0000=uint16,hex,var-flags,OCX-CLASSTABLE-VARFLAGS +combilist=VBA-CLASSINFO-FLAGS + 0x0000FFFF=uint16,hex,classtable-flags,VBA-CLASSTABLE-CLASSFLAGS + 0xFFFF0000=uint16,hex,var-flags,VBA-CLASSTABLE-VARFLAGS end -flagslist=OCX-CLASSTABLE-CLASSFLAGS +flagslist=VBA-CLASSTABLE-CLASSFLAGS 0x0001=exclusive-value 0x0002=dual-interface 0x0004=no-aggregation end -flagslist=OCX-CLASSTABLE-VARFLAGS +flagslist=VBA-CLASSTABLE-VARFLAGS 0x0001=read-only 0x0002=source 0x0004=bindable @@ -510,7 +689,7 @@ end # form site ------------------------------------------------------------------ -flagslist=OCX-FORMSITE-PROPERTIES +flagslist=VBA-FORMSITE-PROPERTIES 0x00000001=name 0x00000002=tag 0x00000004=id @@ -527,7 +706,7 @@ flagslist=OCX-FORMSITE-PROPERTIES 0x00004000=row-source end -flagslist=OCX-FORMSITE-FLAGS +flagslist=VBA-FORMSITE-FLAGS 0x00000001=tabstop 0x00000002=visible 0x00000004=default @@ -540,7 +719,18 @@ flagslist=OCX-FORMSITE-FLAGS 0x00040000=container end -constlist=OCX-FORMSITE-CLASSNAMES +combilist=VBA-FORMSITE-CLASSIDCACHE + 0x7FFF=uint16,dec,cache-idx,VBA-FORMSITE-CLASSIDCACHEINDEX,filter=0x8000~0x0000 + 0x7FFF=uint16,dec,class-table-idx,,filter=0x8000~0x8000 + 0x8000=!predefined-class-id!class-table-index +end + +constlist=VBA-FORMSITE-CLASSIDCACHEINDEX + include=VBA-FORMSITE-CLASSNAMES + 0x7FFF=invalid +end + +constlist=VBA-FORMSITE-CLASSNAMES 7=Forms.Form.1 12=Forms.Image.1 14=Forms.Frame.1 @@ -559,20 +749,9 @@ constlist=OCX-FORMSITE-CLASSNAMES 57=Forms.MultiPage.1 end -constlist=OCX-FORMSITE-CLASSIDCACHEINDEX - include=OCX-FORMSITE-CLASSNAMES - 0x7FFF=invalid -end - -combilist=OCX-FORMSITE-CLASSIDCACHE - 0x7FFF=uint16,dec,cache-idx,OCX-FORMSITE-CLASSIDCACHEINDEX,filter=0x8000~0x0000 - 0x7FFF=uint16,dec,class-table-idx,,filter=0x8000~0x8000 - 0x8000=!predefined-class-id!class-table-index -end - # form design extender ------------------------------------------------------ -flagslist=OCX-FORMDESIGNEXT-PROPERTIES +flagslist=VBA-FORMDESIGNEXT-PROPERTIES 0x00000001=flags 0x00000002=grid-x 0x00000004=grid-y @@ -580,7 +759,7 @@ flagslist=OCX-FORMDESIGNEXT-PROPERTIES 0x00000010=dblclick-control-mode end -flagslist=OCX-FORMDESIGNEXT-FLAGS +flagslist=VBA-FORMDESIGNEXT-FLAGS 0x00000001=inherit-design-mode 0x00000002=design-mode 0x00000004=inherit-show-toolbox @@ -601,14 +780,15 @@ flagslist=OCX-FORMDESIGNEXT-FLAGS 0x00020000=immediate-layout end -shortlist=OCX-FORMDESIGNEXT-CLICKCTRLMODE,-2,inherit,default,insertion-point,select-then-insert -shortlist=OCX-FORMDESIGNEXT-DBLCLICKCTRLMODE,-2,inherit,,select-text,edit-code,edit-properties +shortlist=VBA-FORMDESIGNEXT-CLICKCTRLMODE,-2,inherit,default,insertion-point,select-then-insert +shortlist=VBA-FORMDESIGNEXT-DBLCLICKCTRLMODE,-2,inherit,,select-text,edit-code,edit-properties # form ----------------------------------------------------------------------- {C62A69F0-16DC-11CE-9E98-00AA00574A4F}=Forms.Form.1 +{6E182020-F460-11CE-9BCD-00AA00608E01}=Forms.Frame.1 -flagslist=OCX-FORM-PROPERTIES +flagslist=VBA-FORM-PROPERTIES 0x00000002=fill-color 0x00000004=text-color 0x00000008=next-available-id @@ -635,13 +815,13 @@ flagslist=OCX-FORM-PROPERTIES 0x08000000=draw-buffer end -flagslist=OCX-FORM-FLAGS +flagslist=VBA-FORM-FLAGS 0x00000004=enabled 0x00004000=has-design-extender 0x00008000=!has-class-table!skip-class-table end -flagslist=OCX-FORM-SCROLLBARS +flagslist=VBA-FORM-SCROLLBARS 0x01=horizontal 0x02=vertical 0x04=keep-horizontal @@ -649,24 +829,43 @@ flagslist=OCX-FORM-SCROLLBARS 0x10=vertical-left end -shortlist=OCX-FORM-CYCLE,0,all-forms,,current-form +shortlist=VBA-FORM-CYCLE,0,all-forms,,current-form -combilist=OCX-FORM-SITE-TYPECOUNT +combilist=VBA-FORM-SITE-TYPECOUNT 0x7F=uint8,dec,type-count 0x80=!type!count end -# VBA name lists ============================================================= +# page ----------------------------------------------------------------------- + +flagslist=VBA-PAGE-PROPERTIES + 0x00000002=transition-effect + 0x00000004=transition-period +end + +shortlist=VBA-PAGE-TRANSITIONEFFECT,0,none,cover-up,cover-right-up,cover-right,cover-right-down,cover-down,cover-left-down,cover-left,cover-left-up,push-up,push-right,push-down,push-left + +# multi page ----------------------------------------------------------------- + +{46E31370-3F7A-11CE-BED6-00AA00611080}=Forms.MultiPage.1 + +flagslist=VBA-MULTIPAGE-PROPERTIES + 0x00000002=page-count + 0x00000004=id + 0x00000008=enabled +end + +# VBA project name lists ===================================================== multilist=VBA-DIR-RECORD-NAMES - 0x0000=,PROJECTSYSKIND,PROJECTLCID,PROJECTCODEPAGE,PROJECTNAME,PROJECTDOCSTRING,PROJECTHELPFILEPATH,PROJECTHELPCONTEXT + 0x0000=,PROJECTSYSKIND,PROJECTLCID,PROJECTCODEPAGE,PROJECTNAME,PROJECTDOCSTRING,PROJECTHELPFILEPATH1,PROJECTHELPCONTEXT 0x0008=PROJECTLIBFLAGS,PROJECTVERSION,,,PROJECTCONSTANTS,REFERENCEREGISTERED,REFERENCEPROJECT,PROJECTMODULES 0x0010=PROJECTEND,,,PROJECTCOOKIE,PROJECTLCIDINVOKE,,REFERENCENAME, 0x0018=,MODULENAME,MODULESTREAMNAME,,MODULEDOCSTRING,,MODULEHELPCONTEXT, - 0x0020=,PROCEDURALMODULE,DOCUMENTMODULE,,,MODULEREADONLY,, + 0x0020=,MODULETYPEPROCEDURAL,MODULETYPEDOCUMENT,,,MODULEREADONLY,, 0x0028=MODULEPRIVATE,,,MODULEEND,MODULECOOKIE,,,REFERENCECONTROL 0x0030=REFERENCEEXTENDED,MODULEOFFSET,MODULESTREAMNAMEUNICODE,REFERENCEORIGINAL,,,, - 0x0038=,,,,PROJECTCONSTANTSUNICODE,PROJECTHELPFILEPATHUNICODE,REFERENCENAMEUNICODE, + 0x0038=,,,,PROJECTCONSTANTSUNICODE,PROJECTHELPFILEPATH2,REFERENCENAMEUNICODE, 0x0040=PROJECTDOCSTRINGUNICODE,,,,,,,MODULENAMEUNICODE 0x0048=MODULEDOCSTRINGUNICODE,,,,,,, end diff --git a/oox/source/dump/pptxdumper.cxx b/oox/source/dump/pptxdumper.cxx index e58991dbecc9..e01d7d349855 100644 --- a/oox/source/dump/pptxdumper.cxx +++ b/oox/source/dump/pptxdumper.cxx @@ -26,8 +26,8 @@ ************************************************************************/ #include "oox/dump/pptxdumper.hxx" -#include "oox/helper/olestorage.hxx" #include "oox/helper/zipstorage.hxx" +#include "oox/ole/olestorage.hxx" #include "oox/dump/biffdumper.hxx" #include "oox/dump/oledumper.hxx" #include "oox/dump/xlsbdumper.hxx" @@ -91,17 +91,18 @@ void RootStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, cons { if( rStrgPath.equalsAscii( "ppt" ) && rStrmName.equalsAscii( "vbaProject.bin" ) ) { - StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) ); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, false ) ); VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump(); } else if( rStrgPath.equalsAscii( "ppt/embeddings" ) ) { - StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) ); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, false ) ); OleStorageObject( *this, xStrg, rSysFileName ).dump(); } else if( rStrgPath.equalsAscii( "ppt/activeX" ) ) { - OcxGuidControlObject( *this, rxStrm, rSysFileName ).dump(); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, true ) ); + ActiveXStorageObject( *this, xStrg, rSysFileName ).dump(); } else { diff --git a/oox/source/dump/xlsbdumper.cxx b/oox/source/dump/xlsbdumper.cxx index a9674951225b..80fccddff2ea 100644 --- a/oox/source/dump/xlsbdumper.cxx +++ b/oox/source/dump/xlsbdumper.cxx @@ -30,9 +30,9 @@ #include "oox/dump/biffdumper.hxx" #include "oox/dump/oledumper.hxx" #include "oox/dump/pptxdumper.hxx" -#include "oox/helper/olestorage.hxx" #include "oox/helper/zipstorage.hxx" #include "oox/core/filterbase.hxx" +#include "oox/ole/olestorage.hxx" #include "oox/xls/biffhelper.hxx" #include "oox/xls/formulabase.hxx" #include "oox/xls/richstring.hxx" @@ -82,8 +82,8 @@ RecordObjectBase::~RecordObjectBase() void RecordObjectBase::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) { - mxStrm.reset( new RecordInputStream( getRecordDataSequence() ) ); - SequenceRecordObjectBase::construct( rParent, rxStrm, rSysFileName, mxStrm, "RECORD-NAMES", "SIMPLE-RECORDS" ); + mxBiffStrm.reset( new RecordInputStream( getRecordDataSequence() ) ); + SequenceRecordObjectBase::construct( rParent, rxStrm, rSysFileName, mxBiffStrm, "RECORD-NAMES", "SIMPLE-RECORDS" ); if( SequenceRecordObjectBase::implIsValid() ) mxErrCodes = cfg().getNameList( "ERRORCODES" ); } @@ -111,22 +111,22 @@ OUString RecordObjectBase::getErrorName( sal_uInt8 nErrCode ) const void RecordObjectBase::readAddress( Address& orAddress ) { - in() >> orAddress.mnRow >> orAddress.mnCol; + *mxStrm >> orAddress.mnRow >> orAddress.mnCol; } void RecordObjectBase::readRange( Range& orRange ) { - in() >> orRange.maFirst.mnRow >> orRange.maLast.mnRow >> orRange.maFirst.mnCol >> orRange.maLast.mnCol; + *mxStrm >> orRange.maFirst.mnRow >> orRange.maLast.mnRow >> orRange.maFirst.mnCol >> orRange.maLast.mnCol; } void RecordObjectBase::readRangeList( RangeList& orRanges ) { sal_Int32 nCount; - in() >> nCount; + *mxStrm >> nCount; if( nCount >= 0 ) { orRanges.resize( getLimitedValue< size_t, sal_Int32 >( nCount, 0, SAL_MAX_UINT16 ) ); - for( RangeList::iterator aIt = orRanges.begin(), aEnd = orRanges.end(); !in().isEof() && (aIt != aEnd); ++aIt ) + for( RangeList::iterator aIt = orRanges.begin(), aEnd = orRanges.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt ) readRange( *aIt ); } else @@ -150,11 +150,11 @@ void RecordObjectBase::writeFontPortions( const FontPortionModelList& rPortions if( !rPortions.empty() ) { writeDecItem( "font-count", static_cast< sal_uInt32 >( rPortions.size() ) ); - IndentGuard aIndGuard( out() ); - TableGuard aTabGuard( out(), 14 ); + IndentGuard aIndGuard( mxOut ); + TableGuard aTabGuard( mxOut, 14 ); for( FontPortionModelList::const_iterator aIt = rPortions.begin(), aEnd = rPortions.end(); aIt != aEnd; ++aIt ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeDecItem( "char-pos", aIt->mnPos ); writeDecItem( "font-id", aIt->mnFontId, "FONTNAMES" ); } @@ -166,11 +166,11 @@ void RecordObjectBase::writePhoneticPortions( const PhoneticPortionModelList& rP if( !rPortions.empty() ) { writeDecItem( "portion-count", static_cast< sal_uInt32 >( rPortions.size() ) ); - IndentGuard aIndGuard( out() ); - TableGuard aTabGuard( out(), 14, 21 ); + IndentGuard aIndGuard( mxOut ); + TableGuard aTabGuard( mxOut, 14, 21 ); for( PhoneticPortionModelList::const_iterator aIt = rPortions.begin(), aEnd = rPortions.end(); aIt != aEnd; ++aIt ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeDecItem( "char-pos", aIt->mnPos ); writeDecItem( "base-text-start", aIt->mnBasePos ); writeDecItem( "base-text-length", aIt->mnBaseLen ); @@ -183,7 +183,7 @@ void RecordObjectBase::writePhoneticPortions( const PhoneticPortionModelList& rP sal_uInt8 RecordObjectBase::dumpBoolean( const String& rName ) { sal_uInt8 nBool; - in() >> nBool; + *mxStrm >> nBool; writeBooleanItem( rName( "boolean" ), nBool ); return nBool; } @@ -191,7 +191,7 @@ sal_uInt8 RecordObjectBase::dumpBoolean( const String& rName ) sal_uInt8 RecordObjectBase::dumpErrorCode( const String& rName ) { sal_uInt8 nErrCode; - in() >> nErrCode; + *mxStrm >> nErrCode; writeErrorCodeItem( rName( "error-code" ), nErrCode ); return nErrCode; } @@ -200,25 +200,25 @@ OUString RecordObjectBase::dumpString( const String& rName, bool bRich, bool b32 { sal_uInt8 nFlags = bRich ? dumpHex< sal_uInt8 >( "flags", "STRING-FLAGS" ) : 0; - OUString aString = mxStrm->readString( b32BitLen ); + OUString aString = mxBiffStrm->readString( b32BitLen ); writeStringItem( rName( "text" ), aString ); // --- formatting --- if( getFlag( nFlags, OOBIN_STRINGFLAG_FONTS ) ) { - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); FontPortionModelList aPortions; - aPortions.importPortions( *mxStrm ); + aPortions.importPortions( *mxBiffStrm ); writeFontPortions( aPortions ); } // --- phonetic text --- if( getFlag( nFlags, OOBIN_STRINGFLAG_PHONETICS ) ) { - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpString( "phonetic-text" ); PhoneticPortionModelList aPortions; - aPortions.importPortions( *mxStrm ); + aPortions.importPortions( *mxBiffStrm ); writePhoneticPortions( aPortions ); dumpDec< sal_uInt16 >( "font-id", "FONTNAMES" ); dumpHex< sal_uInt16 >( "flags", "PHONETIC-FLAGS" ); @@ -229,7 +229,7 @@ OUString RecordObjectBase::dumpString( const String& rName, bool bRich, bool b32 void RecordObjectBase::dumpColor( const String& rName ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( rName( "color" ) ); switch( extractValue< sal_uInt8 >( dumpDec< sal_uInt8 >( "flags", "COLOR-FLAGS" ), 1, 7 ) ) { @@ -246,12 +246,12 @@ void RecordObjectBase::dumpColor( const String& rName ) DateTime RecordObjectBase::dumpPivotDateTime( const String& rName ) { DateTime aDateTime; - aDateTime.Year = in().readuInt16(); - aDateTime.Month = in().readuInt16(); - aDateTime.Day = in().readuInt8(); - aDateTime.Hours = in().readuInt8(); - aDateTime.Minutes = in().readuInt8(); - aDateTime.Seconds = in().readuInt8(); + aDateTime.Year = mxStrm->readuInt16(); + aDateTime.Month = mxStrm->readuInt16(); + aDateTime.Day = mxStrm->readuInt8(); + aDateTime.Hours = mxStrm->readuInt8(); + aDateTime.Minutes = mxStrm->readuInt8(); + aDateTime.Seconds = mxStrm->readuInt8(); writeDateTimeItem( rName, aDateTime ); return aDateTime; } @@ -259,7 +259,7 @@ DateTime RecordObjectBase::dumpPivotDateTime( const String& rName ) sal_Int32 RecordObjectBase::dumpColIndex( const String& rName ) { sal_Int32 nCol; - in() >> nCol; + *mxStrm >> nCol; writeColIndexItem( rName( "col-idx" ), nCol ); return nCol; } @@ -267,7 +267,7 @@ sal_Int32 RecordObjectBase::dumpColIndex( const String& rName ) sal_Int32 RecordObjectBase::dumpRowIndex( const String& rName ) { sal_Int32 nRow; - in() >> nRow; + *mxStrm >> nRow; writeRowIndexItem( rName( "row-idx" ), nRow ); return nRow; } @@ -275,7 +275,7 @@ sal_Int32 RecordObjectBase::dumpRowIndex( const String& rName ) sal_Int32 RecordObjectBase::dumpColRange( const String& rName ) { sal_Int32 nCol1, nCol2; - in() >> nCol1 >> nCol2; + *mxStrm >> nCol1 >> nCol2; writeColRangeItem( rName( "col-range" ), nCol1, nCol2 ); return nCol2 - nCol1 + 1; } @@ -283,7 +283,7 @@ sal_Int32 RecordObjectBase::dumpColRange( const String& rName ) sal_Int32 RecordObjectBase::dumpRowRange( const String& rName ) { sal_Int32 nRow1, nRow2; - in() >> nRow1 >> nRow2; + *mxStrm >> nRow1 >> nRow2; writeRowRangeItem( rName( "row-range" ), nRow1, nRow2 ); return nRow2 - nRow1 + 1; } @@ -363,26 +363,25 @@ void FormulaObject::dumpNameFormula( const String& rName ) void FormulaObject::implDump() { { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( maName ); writeDecItem( "formula-size", mnSize ); } if( mnSize < 0 ) return; - BinaryInputStream& rStrm = in(); - sal_Int64 nStartPos = rStrm.tell(); - sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, rStrm.getLength() ); + sal_Int64 nStartPos = mxStrm->tell(); + sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, mxStrm->getLength() ); bool bValid = mxTokens.get(); mxStack.reset( new FormulaStack ); maAddData.clear(); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); { - TableGuard aTabGuard( out(), 8, 18 ); - while( bValid && (rStrm.tell() < nEndPos) ) + TableGuard aTabGuard( mxOut, 8, 18 ); + while( bValid && (mxStrm->tell() < nEndPos) ) { - MultiItemsGuard aMultiGuard( out() ); - writeHexItem( EMPTY_STRING, static_cast< sal_uInt16 >( rStrm.tell() - nStartPos ) ); + MultiItemsGuard aMultiGuard( mxOut ); + writeHexItem( EMPTY_STRING, static_cast< sal_uInt16 >( mxStrm->tell() - nStartPos ) ); sal_uInt8 nTokenId = dumpHex< sal_uInt8 >( EMPTY_STRING, mxTokens ); bValid = mxTokens->hasName( nTokenId ); if( bValid ) @@ -457,7 +456,7 @@ void FormulaObject::implDump() } } - if( nEndPos == rStrm.tell() ) + if( nEndPos == mxStrm->tell() ) { dumpAddTokenData(); if( mnSize > 0 ) @@ -468,7 +467,7 @@ void FormulaObject::implDump() } else { - dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), static_cast< sal_Int32 >( nEndPos - rStrm.tell() ), false ); + dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), static_cast< sal_Int32 >( nEndPos - mxStrm->tell() ), false ); sal_Int32 nAddDataSize = dumpDec< sal_Int32 >( "add-data-size" ); dumpBinary( "add-data", nAddDataSize, false ); } @@ -479,7 +478,7 @@ void FormulaObject::implDump() void FormulaObject::dumpFormula( const String& rName, bool bNameMode ) { maName = rName( "formula" ); - in() >> mnSize; + *mxStrm >> mnSize; mbNameMode = bNameMode; dump(); } @@ -565,7 +564,7 @@ OUString FormulaObject::createPlaceHolder() const OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo** oppFuncInfo ) { - ItemGuard aItemGuard( out(), "func-id" ); + ItemGuard aItem( mxOut, "func-id" ); writeHexItem( EMPTY_STRING, nFuncId, "FUNCID" ); OUStringBuffer aBuffer; const FunctionInfo* pFuncInfo = mxFuncProv->getFuncInfoFromOobFuncId( nFuncId ); @@ -578,10 +577,10 @@ OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo* StringHelper::appendIndex( aBuffer, nFuncId & BIFF_TOK_FUNCVAR_FUNCIDMASK ); } OUString aFuncName = aBuffer.makeStringAndClear(); - aItemGuard.cont(); - out().writeChar( OOX_DUMP_STRQUOTE ); - out().writeString( aFuncName ); - out().writeChar( OOX_DUMP_STRQUOTE ); + aItem.cont(); + mxOut->writeChar( OOX_DUMP_STRQUOTE ); + mxOut->writeString( aFuncName ); + mxOut->writeChar( OOX_DUMP_STRQUOTE ); if( oppFuncInfo ) *oppFuncInfo = pFuncInfo; return aFuncName; } @@ -641,13 +640,13 @@ OUString FormulaObject::dumpTokenRefId() void FormulaObject::dumpIntToken() { dumpDec< sal_uInt16 >( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpDoubleToken() { dumpDec< double >( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpStringToken() @@ -660,13 +659,13 @@ void FormulaObject::dumpStringToken() void FormulaObject::dumpBoolToken() { dumpBoolean( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpErrorToken() { dumpErrorCode( "value" ); - mxStack->pushOperand( out().getLastItemValue() ); + mxStack->pushOperand( mxOut->getLastItemValue() ); } void FormulaObject::dumpMissArgToken() @@ -698,14 +697,14 @@ void FormulaObject::dumpRefToken( const OUString& rTokClass, bool bNameMode ) { TokenAddress aPos = dumpTokenAddress( bNameMode ); writeTokenAddressItem( "addr", aPos, bNameMode ); - mxStack->pushOperand( createRef( out().getLastItemValue() ), rTokClass ); + mxStack->pushOperand( createRef( mxOut->getLastItemValue() ), rTokClass ); } void FormulaObject::dumpAreaToken( const OUString& rTokClass, bool bNameMode ) { TokenRange aRange = dumpTokenRange( bNameMode ); writeTokenRangeItem( "range", aRange, bNameMode ); - mxStack->pushOperand( createRef( out().getLastItemValue() ), rTokClass ); + mxStack->pushOperand( createRef( mxOut->getLastItemValue() ), rTokClass ); } void FormulaObject::dumpRefErrToken( const OUString& rTokClass, bool bArea ) @@ -719,7 +718,7 @@ void FormulaObject::dumpRef3dToken( const OUString& rTokClass, bool bNameMode ) OUString aRef = dumpTokenRefId(); TokenAddress aPos = dumpTokenAddress( bNameMode ); writeTokenAddress3dItem( "addr", aRef, aPos, bNameMode ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } void FormulaObject::dumpArea3dToken( const OUString& rTokClass, bool bNameMode ) @@ -727,7 +726,7 @@ void FormulaObject::dumpArea3dToken( const OUString& rTokClass, bool bNameMode ) OUString aRef = dumpTokenRefId(); TokenRange aRange = dumpTokenRange( bNameMode ); writeTokenRange3dItem( "range", aRef, aRange, bNameMode ); - mxStack->pushOperand( out().getLastItemValue(), rTokClass ); + mxStack->pushOperand( mxOut->getLastItemValue(), rTokClass ); } void FormulaObject::dumpRefErr3dToken( const OUString& rTokClass, bool bArea ) @@ -755,7 +754,7 @@ void FormulaObject::dumpExpToken( const String& rName ) Address aPos; dumpRowIndex( "base-row" ); OUStringBuffer aOp( rName ); - StringHelper::appendIndex( aOp, createPlaceHolder() + out().getLastItemValue() ); + StringHelper::appendIndex( aOp, createPlaceHolder() + mxOut->getLastItemValue() ); mxStack->pushOperand( aOp.makeStringAndClear() ); maAddData.push_back( ADDDATA_EXP ); } @@ -773,7 +772,7 @@ void FormulaObject::dumpBinaryOpToken( const String& rOp ) void FormulaObject::dumpFuncToken( const OUString& rTokClass ) { sal_uInt16 nFuncId; - in() >> nFuncId; + *mxStrm >> nFuncId; const FunctionInfo* pFuncInfo = 0; OUString aFuncName = writeFuncIdItem( nFuncId, &pFuncInfo ); if( pFuncInfo && (pFuncInfo->mnMinParamCount == pFuncInfo->mnMaxParamCount) ) @@ -786,7 +785,7 @@ void FormulaObject::dumpFuncVarToken( const OUString& rTokClass ) { sal_uInt8 nParamCount; sal_uInt16 nFuncId; - in() >> nParamCount >> nFuncId; + *mxStrm >> nParamCount >> nFuncId; bool bCmd = getFlag( nFuncId, BIFF_TOK_FUNCVAR_CMD ); if( bCmd ) writeHexItem( "param-count", nParamCount, "PARAMCOUNT-CMD" ); @@ -803,24 +802,23 @@ void FormulaObject::dumpFuncVarToken( const OUString& rTokClass ) bool FormulaObject::dumpTableToken() { - Output& rOut = out(); dumpUnused( 3 ); sal_uInt16 nFlags = dumpHex< sal_uInt16 >( "flags", "TABLEFLAGS" ); sal_uInt16 nTabId = dumpDec< sal_uInt16 >( "table-id" ); dumpUnused( 2 ); { sal_uInt16 nCol1, nCol2; - in() >> nCol1 >> nCol2; - ItemGuard aItem( rOut, "cols" ); - rOut.writeDec( nCol1 ); + *mxStrm >> nCol1 >> nCol2; + ItemGuard aItem( mxOut, "cols" ); + mxOut->writeDec( nCol1 ); if( nCol1 != nCol2 ) { - rOut.writeChar( OOX_DUMP_RANGESEP ); - rOut.writeDec( nCol2 ); + mxOut->writeChar( OOX_DUMP_RANGESEP ); + mxOut->writeDec( nCol2 ); } } OUStringBuffer aColRange; - StringHelper::appendIndex( aColRange, rOut.getLastItemValue() ); + StringHelper::appendIndex( aColRange, mxOut->getLastItemValue() ); OUStringBuffer aParams; size_t nParams = 0; if( getFlag( nFlags, OOBIN_TOK_TABLE_ALL ) && ++nParams ) @@ -860,7 +858,7 @@ bool FormulaObject::dumpAttrToken() case OOBIN_TOK_ATTR_CHOOSE: { sal_uInt16 nCount = dumpDec< sal_uInt16 >( "choices" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_uInt16 nIdx = 0; nIdx < nCount; ++nIdx ) dumpDec< sal_uInt16 >( "#skip" ); dumpDec< sal_uInt16 >( "skip-err" ); @@ -892,27 +890,25 @@ bool FormulaObject::dumpAttrToken() void FormulaObject::dumpAddTokenData() { - Output& rOut = out(); - rOut.resetItemIndex(); - BinaryInputStream& rStrm = in(); - sal_Int32 nAddDataSize = (in().getLength() - in().tell() >= 4) ? dumpDec< sal_Int32 >( "add-data-size" ) : 0; - sal_Int64 nEndPos = ::std::min< sal_Int64 >( rStrm.tell() + nAddDataSize, rStrm.getLength() ); - for( AddDataTypeVec::const_iterator aIt = maAddData.begin(), aEnd = maAddData.end(); (aIt != aEnd) && !rStrm.isEof() && (rStrm.tell() < nEndPos); ++aIt ) + mxOut->resetItemIndex(); + sal_Int32 nAddDataSize = (mxStrm->getLength() - mxStrm->tell() >= 4) ? dumpDec< sal_Int32 >( "add-data-size" ) : 0; + sal_Int64 nEndPos = ::std::min< sal_Int64 >( mxStrm->tell() + nAddDataSize, mxStrm->getLength() ); + for( AddDataTypeVec::const_iterator aIt = maAddData.begin(), aEnd = maAddData.end(); (aIt != aEnd) && !mxStrm->isEof() && (mxStrm->tell() < nEndPos); ++aIt ) { AddDataType eType = *aIt; { - ItemGuard aItem( rOut, "#add-data" ); + ItemGuard aItem( mxOut, "#add-data" ); switch( eType ) { - case ADDDATA_EXP: rOut.writeAscii( "tExp" ); break; - case ADDDATA_ARRAY: rOut.writeAscii( "tArray" ); break; - case ADDDATA_MEMAREA: rOut.writeAscii( "tMemArea" ); break; + case ADDDATA_EXP: mxOut->writeAscii( "tExp" ); break; + case ADDDATA_ARRAY: mxOut->writeAscii( "tArray" ); break; + case ADDDATA_MEMAREA: mxOut->writeAscii( "tMemArea" ); break; } } size_t nIdx = aIt - maAddData.begin(); - IndentGuard aIndGuard( rOut ); + IndentGuard aIndGuard( mxOut ); switch( eType ) { case ADDDATA_EXP: dumpAddDataExp( nIdx ); break; @@ -926,7 +922,7 @@ void FormulaObject::dumpAddTokenData() void FormulaObject::dumpAddDataExp( size_t nIdx ) { dumpColIndex( "base-col" ); - mxStack->replaceOnTop( createPlaceHolder( nIdx ), out().getLastItemValue() ); + mxStack->replaceOnTop( createPlaceHolder( nIdx ), mxOut->getLastItemValue() ); } void FormulaObject::dumpAddDataArray( size_t nIdx ) @@ -935,7 +931,7 @@ void FormulaObject::dumpAddDataArray( size_t nIdx ) dumpaddDataArrayHeader( nCols, nRows ); OUStringBuffer aOp; - TableGuard aTabGuard( out(), 17 ); + TableGuard aTabGuard( mxOut, 17 ); for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) { OUStringBuffer aArrayLine; @@ -954,28 +950,26 @@ void FormulaObject::dumpAddDataMemArea( size_t /*nIdx*/ ) void FormulaObject::dumpaddDataArrayHeader( sal_Int32& rnCols, sal_Int32& rnRows ) { - Output& rOut = out(); - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); rnRows = dumpDec< sal_Int32 >( "height" ); rnCols = dumpDec< sal_Int32 >( "width" ); - ItemGuard aItem( rOut, "size" ); - rOut.writeDec( rnCols ); - rOut.writeChar( 'x' ); - rOut.writeDec( rnRows ); + ItemGuard aItem( mxOut, "size" ); + mxOut->writeDec( rnCols ); + mxOut->writeChar( 'x' ); + mxOut->writeDec( rnRows ); aItem.cont(); - rOut.writeDec( rnCols * rnRows ); + mxOut->writeDec( rnCols * rnRows ); } OUString FormulaObject::dumpaddDataArrayValue() { - Output& rOut = out(); - MultiItemsGuard aMultiGuard( rOut ); + MultiItemsGuard aMultiGuard( mxOut ); OUStringBuffer aValue; switch( dumpDec< sal_uInt8 >( "type", "ARRAYVALUE-TYPE" ) ) { case OOBIN_TOK_ARRAY_DOUBLE: dumpDec< double >( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); break; case OOBIN_TOK_ARRAY_STRING: aValue.append( dumpString( "value", false, false ) ); @@ -983,11 +977,11 @@ OUString FormulaObject::dumpaddDataArrayValue() break; case OOBIN_TOK_ARRAY_BOOL: dumpBoolean( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); break; case OOBIN_TOK_ARRAY_ERROR: dumpErrorCode( "value" ); - aValue.append( rOut.getLastItemValue() ); + aValue.append( mxOut->getLastItemValue() ); dumpUnused( 3 ); break; } @@ -1150,11 +1144,11 @@ void RecordStreamObject::implDumpRecordBody() dumpDec< sal_Int32 >( "formula2-size" ); dumpDec< sal_Int32 >( "formula3-size" ); dumpString( "text" ); - if( in().getLength() - in().tell() >= 8 ) + if( mxStrm->getRemaining() >= 8 ) mxFmlaObj->dumpNameFormula( "formula1" ); - if( in().getLength() - in().tell() >= 8 ) + if( mxStrm->getRemaining() >= 8 ) mxFmlaObj->dumpNameFormula( "formula2" ); - if( in().getLength() - in().tell() >= 8 ) + if( mxStrm->getRemaining() >= 8 ) mxFmlaObj->dumpNameFormula( "formula3" ); } break; @@ -1272,10 +1266,10 @@ void RecordStreamObject::implDumpRecordBody() dumpString( "name" ); mxFmlaObj->dumpNameFormula(); dumpString( "comment" ); - if( in().getLength() - in().tell() >= 4 ) dumpString( "menu-text" ); - if( in().getLength() - in().tell() >= 4 ) dumpString( "description-text" ); - if( in().getLength() - in().tell() >= 4 ) dumpString( "help-text" ); - if( in().getLength() - in().tell() >= 4 ) dumpString( "statusbar-text" ); + if( mxStrm->getRemaining() >= 4 ) dumpString( "menu-text" ); + if( mxStrm->getRemaining() >= 4 ) dumpString( "description-text" ); + if( mxStrm->getRemaining() >= 4 ) dumpString( "help-text" ); + if( mxStrm->getRemaining() >= 4 ) dumpString( "statusbar-text" ); break; case OOBIN_ID_DIMENSION: @@ -1288,16 +1282,16 @@ void RecordStreamObject::implDumpRecordBody() case OOBIN_ID_DXF: dumpHex< sal_uInt32 >( "flags", "DXF-FLAGS" ); - for( sal_uInt16 nIndex = 0, nCount = dumpDec< sal_uInt16 >( "subrec-count" ); !in().isEof() && (nIndex < nCount); ++nIndex ) + for( sal_uInt16 nIndex = 0, nCount = dumpDec< sal_uInt16 >( "subrec-count" ); !mxStrm->isEof() && (nIndex < nCount); ++nIndex ) { - out().startMultiItems(); - sal_Int64 nStartPos = in().tell(); + mxOut->startMultiItems(); + sal_Int64 nStartPos = mxStrm->tell(); writeEmptyItem( "SUBREC" ); sal_uInt16 nSubRecId = dumpDec< sal_uInt16 >( "id", "DXF-SUBREC" ); sal_uInt16 nSubRecSize = dumpDec< sal_uInt16 >( "size" ); sal_Int64 nEndPos = nStartPos + nSubRecSize; - out().endMultiItems(); - IndentGuard aIndGuard( out() ); + mxOut->endMultiItems(); + IndentGuard aIndGuard( mxOut ); switch( nSubRecId ) { case 0: @@ -1438,11 +1432,11 @@ void RecordStreamObject::implDumpRecordBody() case OOBIN_ID_EXTERNALSHEETS: { sal_Int32 nCount = dumpDec< sal_Int32 >( "ref-count" ); - TableGuard aTabGuard( out(), 13, 17, 24 ); - out().resetItemIndex(); - for( sal_Int32 nRefId = 0; !in().isEof() && (nRefId < nCount); ++nRefId ) + TableGuard aTabGuard( mxOut, 13, 17, 24 ); + mxOut->resetItemIndex(); + for( sal_Int32 nRefId = 0; !mxStrm->isEof() && (nRefId < nCount); ++nRefId ) { - MultiItemsGuard aMultiGuard( out() ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#ref" ); dumpDec< sal_Int32 >( "extref-id" ); dumpDec< sal_Int32 >( "first-sheet", "EXTERNALSHEETS-ID" ); @@ -1461,8 +1455,8 @@ void RecordStreamObject::implDumpRecordBody() break; case OOBIN_ID_EXTSHEETNAMES: - out().resetItemIndex(); - for( sal_Int32 nSheet = 0, nCount = dumpDec< sal_Int32 >( "sheet-count" ); !in().isEof() && (nSheet < nCount); ++nSheet ) + mxOut->resetItemIndex(); + for( sal_Int32 nSheet = 0, nCount = dumpDec< sal_Int32 >( "sheet-count" ); !mxStrm->isEof() && (nSheet < nCount); ++nSheet ) dumpString( "#sheet-name" ); break; @@ -1477,11 +1471,11 @@ void RecordStreamObject::implDumpRecordBody() dumpColor( "fg-color" ); dumpColor( "bg-color" ); dumpGradientHead(); - out().resetItemIndex(); - for( sal_Int32 nStop = 0, nStopCount = dumpDec< sal_Int32 >( "stop-count" ); (nStop < nStopCount) && !in().isEof(); ++nStop ) + mxOut->resetItemIndex(); + for( sal_Int32 nStop = 0, nStopCount = dumpDec< sal_Int32 >( "stop-count" ); (nStop < nStopCount) && !mxStrm->isEof(); ++nStop ) { writeEmptyItem( "#stop" ); - IndentGuard aIndGuard( out() ); + IndentGuard aIndGuard( mxOut ); dumpColor( "stop-color" ); dumpDec< double >( "stop-position" ); } @@ -1739,7 +1733,7 @@ void RecordStreamObject::implDumpRecordBody() { sal_uInt16 nType = dumpDec< sal_uInt16 >( "type", "PCITEM_ARRAY-TYPE" ); sal_Int32 nCount = dumpDec< sal_Int32 >( "count" ); - out().resetItemIndex(); + mxOut->resetItemIndex(); for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx ) { switch( nType ) @@ -1839,8 +1833,8 @@ void RecordStreamObject::implDumpRecordBody() case OOBIN_ID_PTCOLFIELDS: dumpDec< sal_Int32 >( "count" ); - out().resetItemIndex(); - while( in().getRemaining() >= 4 ) + mxOut->resetItemIndex(); + while( mxStrm->getRemaining() >= 4 ) dumpDec< sal_Int32 >( "#field", "PT-FIELDINDEX" ); break; @@ -1948,8 +1942,8 @@ void RecordStreamObject::implDumpRecordBody() case OOBIN_ID_PTROWFIELDS: dumpDec< sal_Int32 >( "count" ); - out().resetItemIndex(); - while( in().getRemaining() >= 4 ) + mxOut->resetItemIndex(); + while( mxStrm->getRemaining() >= 4 ) dumpDec< sal_Int32 >( "#field", "PT-FIELDINDEX" ); break; @@ -1959,8 +1953,8 @@ void RecordStreamObject::implDumpRecordBody() dumpDec< sal_uInt16 >( "height", "CONV-TWIP-TO-PT" ); dumpHex< sal_uInt16 >( "flags", "ROW-FLAGS1" ); dumpHex< sal_uInt8 >( "flags", "ROW-FLAGS2" ); - out().resetItemIndex(); - for( sal_Int32 nSpan = 0, nSpanCount = dumpDec< sal_Int32 >( "row-spans-count" ); !in().isEof() && (nSpan < nSpanCount); ++nSpan ) + mxOut->resetItemIndex(); + for( sal_Int32 nSpan = 0, nSpanCount = dumpDec< sal_Int32 >( "row-spans-count" ); !mxStrm->isEof() && (nSpan < nSpanCount); ++nSpan ) dumpRowRange( "#row-spans" ); break; @@ -2205,12 +2199,12 @@ void RootStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, cons { if( rStrgPath.equalsAscii( "xl" ) && rStrmName.equalsAscii( "vbaProject.bin" ) ) { - StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) ); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, false ) ); VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump(); } else if( rStrgPath.equalsAscii( "xl/embeddings" ) ) { - StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) ); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, false ) ); OleStorageObject( *this, xStrg, rSysFileName ).dump(); } else if( @@ -2228,7 +2222,8 @@ void RootStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, cons } else if( rStrgPath.equalsAscii( "xl/activeX" ) ) { - OcxGuidControlObject( *this, rxStrm, rSysFileName ).dump(); + StorageRef xStrg( new ::oox::ole::OleStorage( getFactory(), xInStrm, true ) ); + ActiveXStorageObject( *this, xStrg, rSysFileName ).dump(); } else { diff --git a/oox/source/helper/binaryinputstream.cxx b/oox/source/helper/binaryinputstream.cxx index 5ba4a8b0b73b..9ca6938f2ff1 100644 --- a/oox/source/helper/binaryinputstream.cxx +++ b/oox/source/helper/binaryinputstream.cxx @@ -30,6 +30,7 @@ #include #include #include +#include "oox/helper/binaryoutputstream.hxx" using ::rtl::OString; using ::rtl::OStringBuffer; @@ -102,6 +103,25 @@ OUString BinaryInputStream::readUnicodeArray( sal_Int32 nChars, bool bAllowNulCh return aBuffer.makeStringAndClear(); } +void BinaryInputStream::copyToStream( BinaryOutputStream& rOutStrm, sal_Int64 nBytes ) +{ + if( nBytes > 0 ) + { + sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, INPUTSTREAM_BUFFERSIZE ); + StreamDataSequence aBuffer( nBufferSize ); + while( nBytes > 0 ) + { + sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, nBufferSize ); + sal_Int32 nBytesRead = readData( aBuffer, nReadSize ); + rOutStrm.writeData( aBuffer ); + if( nReadSize == nBytesRead ) + nBytes -= nReadSize; + else + nBytes = 0; + } + } +} + void BinaryInputStream::readAtom( void* opMem, sal_uInt8 nSize ) { readMemory( opMem, nSize ); @@ -214,7 +234,7 @@ sal_Int32 SequenceInputStream::readMemory( void* opMem, sal_Int32 nBytes ) sal_Int32 nReadBytes = 0; if( !mbEof ) { - nReadBytes = ::std::min< sal_Int32 >( nBytes, mrData.getLength() - mnPos ); + nReadBytes = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, mrData.getLength() - mnPos ); if( nReadBytes > 0 ) memcpy( opMem, mrData.getConstArray() + mnPos, static_cast< size_t >( nReadBytes ) ); mnPos += nReadBytes; @@ -227,7 +247,7 @@ void SequenceInputStream::skip( sal_Int32 nBytes ) { if( !mbEof ) { - sal_Int32 nSkipBytes = ::std::min< sal_Int32 >( nBytes, mrData.getLength() - mnPos ); + sal_Int32 nSkipBytes = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, mrData.getLength() - mnPos ); mnPos += nSkipBytes; mbEof = nSkipBytes < nBytes; } @@ -235,5 +255,78 @@ void SequenceInputStream::skip( sal_Int32 nBytes ) // ============================================================================ +RelativeInputStream::RelativeInputStream( BinaryInputStream& rInStrm, sal_Int64 nLength ) : + mrInStrm( rInStrm ), + mnStartPos( rInStrm.tell() ), + mnRelPos( 0 ) +{ + sal_Int64 nRemaining = rInStrm.getRemaining(); + mnLength = (nRemaining >= 0) ? ::std::min( nLength, nRemaining ) : nLength; + mbEof = mnLength < 0; +} + +bool RelativeInputStream::isSeekable() const +{ + return mrInStrm.isSeekable(); +} + +sal_Int64 RelativeInputStream::getLength() const +{ + return mnLength; +} + +sal_Int64 RelativeInputStream::tell() const +{ + return mnRelPos; +} + +void RelativeInputStream::seek( sal_Int64 nPos ) +{ + if( mrInStrm.isSeekable() && (mnStartPos >= 0) ) + { + mnRelPos = getLimitedValue< sal_Int64, sal_Int64 >( nPos, 0, mnLength ); + mrInStrm.seek( mnStartPos + mnRelPos ); + mbEof = (mnRelPos != nPos) || mrInStrm.isEof(); + } +} + +sal_Int32 RelativeInputStream::readData( StreamDataSequence& orData, sal_Int32 nBytes ) +{ + sal_Int32 nReadBytes = 0; + if( !mbEof ) + { + sal_Int32 nRealBytes = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, mnLength - mnRelPos ); + nReadBytes = mrInStrm.readData( orData, nRealBytes ); + mnRelPos += nReadBytes; + mbEof = (nRealBytes < nBytes) || mrInStrm.isEof(); + } + return nReadBytes; +} + +sal_Int32 RelativeInputStream::readMemory( void* opMem, sal_Int32 nBytes ) +{ + sal_Int32 nReadBytes = 0; + if( !mbEof ) + { + sal_Int32 nRealBytes = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, mnLength - mnRelPos ); + nReadBytes = mrInStrm.readMemory( opMem, nRealBytes ); + mnRelPos += nReadBytes; + mbEof = (nRealBytes < nBytes) || mrInStrm.isEof(); + } + return nReadBytes; +} + +void RelativeInputStream::skip( sal_Int32 nBytes ) +{ + if( !mbEof ) + { + sal_Int32 nSkipBytes = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, mnLength - mnRelPos ); + mnRelPos += nSkipBytes; + mbEof = nSkipBytes < nBytes; + } +} + +// ============================================================================ + } // namespace oox diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx index be6bc6d67577..f39ac9d8f1b2 100644 --- a/oox/source/helper/binaryoutputstream.cxx +++ b/oox/source/helper/binaryoutputstream.cxx @@ -27,7 +27,6 @@ #include "oox/helper/binaryoutputstream.hxx" #include -#include "oox/helper/binaryinputstream.hxx" #include using ::com::sun::star::uno::UNO_QUERY; @@ -42,25 +41,6 @@ const sal_Int32 OUTPUTSTREAM_BUFFERSIZE = 0x8000; // ============================================================================ -void BinaryOutputStream::copyStream( BinaryInputStream& rInStrm, sal_Int64 nBytes ) -{ - if( nBytes > 0 ) - { - sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, OUTPUTSTREAM_BUFFERSIZE ); - StreamDataSequence aBuffer( nBufferSize ); - while( nBytes > 0 ) - { - sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, nBufferSize ); - sal_Int32 nBytesRead = rInStrm.readData( aBuffer, nReadSize ); - writeData( aBuffer ); - if( nReadSize == nBytesRead ) - nBytes -= nReadSize; - else - nBytes = 0; - } - } -} - void BinaryOutputStream::writeAtom( const void* pMem, sal_uInt8 nSize ) { writeMemory( pMem, nSize ); diff --git a/oox/source/helper/binarystreambase.cxx b/oox/source/helper/binarystreambase.cxx index be6b17d3aab9..86eae793a3c1 100644 --- a/oox/source/helper/binarystreambase.cxx +++ b/oox/source/helper/binarystreambase.cxx @@ -61,7 +61,24 @@ void BinaryStreamBase::seek( sal_Int64 ) sal_Int64 BinaryStreamBase::getRemaining() const { - return isSeekable() ? ::std::max< sal_Int64 >( getLength() - tell(), 0 ) : -1; + // do not use isSeekable(), implementations may provide stream position and size even if not seekable + sal_Int64 nPos = tell(); + sal_Int64 nLen = getLength(); + return ((nPos >= 0) && (nLen >= 0)) ? ::std::max< sal_Int64 >( nLen - nPos, 0 ) : -1; +} + +void BinaryStreamBase::align( sal_Int32 nBlockSize, sal_Int64 nAnchorPos ) +{ + sal_Int64 nStrmPos = tell(); + // nothing to do, if stream is at anchor position + if( isSeekable() && (0 <= nAnchorPos) && (nAnchorPos != nStrmPos) && (nBlockSize > 1) ) + { + // prevent modulo with negative arguments... + sal_Int64 nSkipSize = (nAnchorPos < nStrmPos) ? + (nBlockSize - ((nStrmPos - nAnchorPos - 1) % nBlockSize) - 1) : + ((nAnchorPos - nStrmPos) % nBlockSize); + seek( nStrmPos + nSkipSize ); + } } // ============================================================================ @@ -135,7 +152,7 @@ sal_Int64 SequenceSeekableStream::tell() const void SequenceSeekableStream::seek( sal_Int64 nPos ) { mnPos = getLimitedValue< sal_Int32, sal_Int64 >( nPos, 0, mrData.getLength() ); - mbEof = mnPos < nPos; + mbEof = mnPos != nPos; } // ============================================================================ diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx index 3e54cd16c2bc..6e57ac8f2b2f 100644 --- a/oox/source/helper/graphichelper.cxx +++ b/oox/source/helper/graphichelper.cxx @@ -26,42 +26,236 @@ ************************************************************************/ #include "oox/helper/graphichelper.hxx" +#include +#include +#include +#include +#include #include #include +#include #include #include +#include "tokens.hxx" +#include "oox/helper/containerhelper.hxx" using ::rtl::OUString; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::awt::DeviceInfo; +using ::com::sun::star::awt::Point; +using ::com::sun::star::awt::Size; +using ::com::sun::star::awt::XDevice; +using ::com::sun::star::awt::XUnitConversion; using ::com::sun::star::beans::PropertyValue; -using ::com::sun::star::io::XInputStream; -using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::frame::XFrame; +using ::com::sun::star::frame::XFramesSupplier; using ::com::sun::star::graphic::GraphicObject; using ::com::sun::star::graphic::XGraphic; using ::com::sun::star::graphic::XGraphicObject; using ::com::sun::star::graphic::XGraphicProvider; +using ::com::sun::star::io::XInputStream; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; namespace oox { // ============================================================================ -GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxFactory ) : - mxGraphicProvider( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ), +namespace { + +inline sal_Int32 lclConvertScreenPixelToHmm( double fPixel, double fPixelPerHmm ) +{ + return static_cast< sal_Int32 >( (fPixelPerHmm > 0.0) ? (fPixel / fPixelPerHmm + 0.5) : 0.0 ); +} + +} // namespace + +// ============================================================================ + +GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalFactory ) : + mxGraphicProvider( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ), maGraphicObjScheme( CREATE_OUSTRING( "vnd.sun.star.GraphicObject:" ) ) { - ::comphelper::ComponentContext aContext( rxFactory ); + ::comphelper::ComponentContext aContext( rxGlobalFactory ); mxCompContext = aContext.getUNOContext(); + + //! TODO: get colors from system + maSystemPalette[ XML_3dDkShadow ] = 0x716F64; + maSystemPalette[ XML_3dLight ] = 0xF1EFE2; + maSystemPalette[ XML_activeBorder ] = 0xD4D0C8; + maSystemPalette[ XML_activeCaption ] = 0x0054E3; + maSystemPalette[ XML_appWorkspace ] = 0x808080; + maSystemPalette[ XML_background ] = 0x004E98; + maSystemPalette[ XML_btnFace ] = 0xECE9D8; + maSystemPalette[ XML_btnHighlight ] = 0xFFFFFF; + maSystemPalette[ XML_btnShadow ] = 0xACA899; + maSystemPalette[ XML_btnText ] = 0x000000; + maSystemPalette[ XML_captionText ] = 0xFFFFFF; + maSystemPalette[ XML_gradientActiveCaption ] = 0x3D95FF; + maSystemPalette[ XML_gradientInactiveCaption ] = 0xD8E4F8; + maSystemPalette[ XML_grayText ] = 0xACA899; + maSystemPalette[ XML_highlight ] = 0x316AC5; + maSystemPalette[ XML_highlightText ] = 0xFFFFFF; + maSystemPalette[ XML_hotLight ] = 0x000080; + maSystemPalette[ XML_inactiveBorder ] = 0xD4D0C8; + maSystemPalette[ XML_inactiveCaption ] = 0x7A96DF; + maSystemPalette[ XML_inactiveCaptionText ] = 0xD8E4F8; + maSystemPalette[ XML_infoBk ] = 0xFFFFE1; + maSystemPalette[ XML_infoText ] = 0x000000; + maSystemPalette[ XML_menu ] = 0xFFFFFF; + maSystemPalette[ XML_menuBar ] = 0xECE9D8; + maSystemPalette[ XML_menuHighlight ] = 0x316AC5; + maSystemPalette[ XML_menuText ] = 0x000000; + maSystemPalette[ XML_scrollBar ] = 0xD4D0C8; + maSystemPalette[ XML_window ] = 0xFFFFFF; + maSystemPalette[ XML_windowFrame ] = 0x000000; + maSystemPalette[ XML_windowText ] = 0x000000; + + // get the metric of the output device + if( rxGlobalFactory.is() ) try + { + Reference< XFramesSupplier > xFramesSupp( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY_THROW ); + Reference< XFrame > xFrame( xFramesSupp->getActiveFrame(), UNO_SET_THROW ); + Reference< XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW ); + mxUnitConversion.set( xDevice, UNO_QUERY ); + maDeviceInfo = xDevice->getInfo(); + mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0; + mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0; + } + catch( Exception& ) + { + OSL_ENSURE( false, "GraphicHelper::GraphicHelper - cannot get output device info" ); + } } GraphicHelper::~GraphicHelper() { } -Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStream >& rxInStrm ) +sal_Int32 GraphicHelper::getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ) const +{ + const sal_Int32* pnColor = ContainerHelper::getMapElement( maSystemPalette, nToken ); + return pnColor ? *pnColor : nDefaultRgb; +} + +sal_Int32 GraphicHelper::getSchemeColor( sal_Int32 /*nToken*/ ) const +{ + OSL_ENSURE( false, "GraphicHelper::getSchemeColor - scheme colors not implemented" ); + return API_RGB_TRANSPARENT; +} + +sal_Int32 GraphicHelper::getPaletteColor( sal_Int32 /*nPaletteIdx*/ ) const +{ + OSL_ENSURE( false, "GraphicHelper::getPaletteColor - palette colors not implemented" ); + return API_RGB_TRANSPARENT; +} + +const DeviceInfo& GraphicHelper::getDeviceInfo() const +{ + return maDeviceInfo; +} + +sal_Int32 GraphicHelper::convertScreenPixelXToHmm( double fPixelX ) const +{ + return lclConvertScreenPixelToHmm( fPixelX, mfPixelPerHmmX ); +} + +sal_Int32 GraphicHelper::convertScreenPixelYToHmm( double fPixelY ) const +{ + return lclConvertScreenPixelToHmm( fPixelY, mfPixelPerHmmY ); +} + +Point GraphicHelper::convertScreenPixelToHmm( const Point& rPixel ) const +{ + return Point( convertScreenPixelXToHmm( rPixel.X ), convertScreenPixelYToHmm( rPixel.Y ) ); +} + +Size GraphicHelper::convertScreenPixelToHmm( const Size& rPixel ) const +{ + return Size( convertScreenPixelXToHmm( rPixel.Width ), convertScreenPixelYToHmm( rPixel.Height ) ); +} + +double GraphicHelper::convertHmmToScreenPixelX( sal_Int32 nHmmX ) const +{ + return nHmmX * mfPixelPerHmmX; +} + +double GraphicHelper::convertHmmToScreenPixelY( sal_Int32 nHmmY ) const +{ + return nHmmY * mfPixelPerHmmY; +} + +Point GraphicHelper::convertHmmToScreenPixel( const Point& rHmm ) const +{ + return Point( + static_cast< sal_Int32 >( convertHmmToScreenPixelX( rHmm.X ) + 0.5 ), + static_cast< sal_Int32 >( convertHmmToScreenPixelY( rHmm.Y ) + 0.5 ) ); +} + +Size GraphicHelper::convertHmmToScreenPixel( const Size& rHmm ) const +{ + return Size( + static_cast< sal_Int32 >( convertHmmToScreenPixelX( rHmm.Width ) + 0.5 ), + static_cast< sal_Int32 >( convertHmmToScreenPixelY( rHmm.Height ) + 0.5 ) ); +} + +Point GraphicHelper::convertAppFontToHmm( const Point& rAppFont ) const +{ + if( mxUnitConversion.is() ) try + { + Point aPixel = mxUnitConversion->convertPointToPixel( rAppFont, ::com::sun::star::util::MeasureUnit::APPFONT ); + return convertScreenPixelToHmm( aPixel ); + } + catch( Exception& ) + { + } + return Point( 0, 0 ); +} + +Size GraphicHelper::convertAppFontToHmm( const Size& rAppFont ) const +{ + if( mxUnitConversion.is() ) try + { + Size aPixel = mxUnitConversion->convertSizeToPixel( rAppFont, ::com::sun::star::util::MeasureUnit::APPFONT ); + return convertScreenPixelToHmm( aPixel ); + } + catch( Exception& ) + { + } + return Size( 0, 0 ); +} + +Point GraphicHelper::convertHmmToAppFont( const Point& rHmm ) const +{ + if( mxUnitConversion.is() ) try + { + Point aPixel = convertHmmToScreenPixel( rHmm ); + return mxUnitConversion->convertPointToLogic( aPixel, ::com::sun::star::util::MeasureUnit::APPFONT ); + } + catch( Exception& ) + { + } + return Point( 0, 0 ); +} + +Size GraphicHelper::convertHmmToAppFont( const Size& rHmm ) const +{ + if( mxUnitConversion.is() ) try + { + Size aPixel = convertHmmToScreenPixel( rHmm ); + return mxUnitConversion->convertSizeToLogic( aPixel, ::com::sun::star::util::MeasureUnit::APPFONT ); + } + catch( Exception& ) + { + } + return Size( 0, 0 ); +} + +Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStream >& rxInStrm ) const { Reference< XGraphic > xGraphic; if( rxInStrm.is() && mxGraphicProvider.is() ) try @@ -77,7 +271,7 @@ Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStrea return xGraphic; } -Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rGraphicData ) +Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rGraphicData ) const { Reference< XGraphic > xGraphic; if( rGraphicData.hasElements() ) @@ -88,7 +282,7 @@ Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rG return xGraphic; } -OUString GraphicHelper::createGraphicObject( const Reference< XGraphic >& rxGraphic ) +OUString GraphicHelper::createGraphicObject( const Reference< XGraphic >& rxGraphic ) const { OUString aGraphicObjUrl; if( mxCompContext.is() && rxGraphic.is() ) try @@ -104,12 +298,12 @@ OUString GraphicHelper::createGraphicObject( const Reference< XGraphic >& rxGrap return aGraphicObjUrl; } -OUString GraphicHelper::importGraphicObject( const Reference< XInputStream >& rxInStrm ) +OUString GraphicHelper::importGraphicObject( const Reference< XInputStream >& rxInStrm ) const { return createGraphicObject( importGraphic( rxInStrm ) ); } -OUString GraphicHelper::importGraphicObject( const StreamDataSequence& rGraphicData ) +OUString GraphicHelper::importGraphicObject( const StreamDataSequence& rGraphicData ) const { return createGraphicObject( importGraphic( rGraphicData ) ); } diff --git a/oox/source/helper/makefile.mk b/oox/source/helper/makefile.mk index 4a91a7a47764..3518db0c6d7c 100644 --- a/oox/source/helper/makefile.mk +++ b/oox/source/helper/makefile.mk @@ -48,12 +48,12 @@ SLOFILES = \ $(SLO)$/containerhelper.obj \ $(SLO)$/graphichelper.obj \ $(SLO)$/modelobjecthelper.obj \ - $(SLO)$/olestorage.obj \ $(SLO)$/progressbar.obj \ $(SLO)$/propertymap.obj \ $(SLO)$/propertyset.obj \ $(SLO)$/recordinputstream.obj \ $(SLO)$/storagebase.obj \ + $(SLO)$/textinputstream.obj \ $(SLO)$/zipstorage.obj # --- Targets ------------------------------------------------------- diff --git a/oox/source/helper/modelobjecthelper.cxx b/oox/source/helper/modelobjecthelper.cxx index d1996991090a..6528fea5634d 100644 --- a/oox/source/helper/modelobjecthelper.cxx +++ b/oox/source/helper/modelobjecthelper.cxx @@ -44,11 +44,11 @@ namespace oox { // ============================================================================ -ModelObjectHelper::ModelObjectHelper( const Reference< XMultiServiceFactory >& rxFactory ) : - maMarkerContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ), - maDashContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ), - maGradientContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.GradientTable" ) ), - maBitmapContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.BitmapTable" ) ), +ModelObjectHelper::ModelObjectHelper( const Reference< XMultiServiceFactory >& rxModelFactory ) : + maMarkerContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ), + maDashContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ), + maGradientContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.GradientTable" ) ), + maBitmapContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.BitmapTable" ) ), maDashNameBase( CREATE_OUSTRING( "msLineDash " ) ), maGradientNameBase( CREATE_OUSTRING( "msFillGradient " ) ), maBitmapNameBase( CREATE_OUSTRING( "msFillBitmap " ) ) diff --git a/oox/source/helper/olestorage.cxx b/oox/source/helper/olestorage.cxx deleted file mode 100644 index fe660b27ff2b..000000000000 --- a/oox/source/helper/olestorage.cxx +++ /dev/null @@ -1,180 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "oox/helper/olestorage.hxx" -#include -#include -#include -#include -#include -#include -#include "oox/helper/helper.hxx" - -using ::rtl::OUString; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::container::XNameAccess; -using ::com::sun::star::lang::XMultiServiceFactory; -using ::com::sun::star::beans::PropertyValue; -using ::com::sun::star::embed::XStorage; -using ::com::sun::star::io::XInputStream; -using ::com::sun::star::io::XOutputStream; -using ::com::sun::star::io::XStream; - -namespace oox { - -// ============================================================================ - -OleStorage::OleStorage( - const Reference< XMultiServiceFactory >& rxFactory, - const Reference< XInputStream >& rxInStream, - bool bBaseStreamAccess ) : - StorageBase( rxInStream, bBaseStreamAccess ) -{ - OSL_ENSURE( rxFactory.is(), "OleStorage::OleStorage - missing service factory" ); - // create base storage object - Sequence< Any > aArgs( 2 ); - aArgs[ 0 ] <<= rxInStream; - aArgs[ 1 ] <<= true; // true = do not create a copy of the input stream - mxStorage.set( rxFactory->createInstanceWithArguments( - CREATE_OUSTRING( "com.sun.star.embed.OLESimpleStorage" ), aArgs ), UNO_QUERY ); - mxElements.set( mxStorage, UNO_QUERY ); -} - -OleStorage::OleStorage( - const Reference< XMultiServiceFactory >& rxFactory, - const Reference< XStream >& rxStream, - bool bBaseStreamAccess ) : - StorageBase( rxStream, bBaseStreamAccess ) -{ - OSL_ENSURE( rxFactory.is(), "OleStorage::OleStorage - missing service factory" ); - (void)rxFactory; // prevent compiler warning - OSL_ENSURE( false, "OleStorage::OleStorage - not implemented" ); - mxElements.set( mxStorage, UNO_QUERY ); -} - -OleStorage::OleStorage( const OleStorage& rParentStorage, const Reference< XNameAccess >& rxElementsAccess, const OUString& rElementName ) : - StorageBase( rParentStorage, rElementName ), - mxStorage( rParentStorage.mxStorage ), - mxElements( rxElementsAccess ) -{ - OSL_ENSURE( mxElements.is(), "OleStorage::OleStorage - missing elements access" ); -} - -OleStorage::~OleStorage() -{ -} - -// StorageBase interface ------------------------------------------------------ - -bool OleStorage::implIsStorage() const -{ - if( mxStorage.is() && mxElements.is() ) try - { - /* If this is not a storage, hasElements() throws an exception. But we - do not return the result of hasElements(), because an empty storage - is a valid storage too. */ - mxElements->hasElements(); - return true; - } - catch( Exception& ) - { - } - return false; -} - -Reference< XStorage > OleStorage::implGetXStorage() const -{ - OSL_ENSURE( false, "OleStorage::getXStorage - not implemented" ); - return Reference< XStorage >(); -} - -void OleStorage::implGetElementNames( ::std::vector< OUString >& orElementNames ) const -{ - Sequence< OUString > aNames; - if( mxElements.is() ) try - { - aNames = mxElements->getElementNames(); - if( aNames.getLength() > 0 ) - orElementNames.insert( orElementNames.end(), aNames.getConstArray(), aNames.getConstArray() + aNames.getLength() ); - } - catch( Exception& ) - { - } -} - -StorageRef OleStorage::implOpenSubStorage( const OUString& rElementName, bool bCreate ) -{ - OSL_ENSURE( !bCreate, "OleStorage::implOpenSubStorage - creating substorages not implemented" ); - (void)bCreate; // prevent compiler warning - StorageRef xSubStorage; - if( mxElements.is() ) try - { - Reference< XNameAccess > xSubElements( mxElements->getByName( rElementName ), UNO_QUERY_THROW ); - xSubStorage.reset( new OleStorage( *this, xSubElements, rElementName ) ); - } - catch( Exception& ) - { - } - return xSubStorage; -} - -Reference< XInputStream > OleStorage::implOpenInputStream( const OUString& rElementName ) -{ - Reference< XInputStream > xInStream; - if( mxElements.is() ) try - { - xInStream.set( mxElements->getByName( rElementName ), UNO_QUERY ); - } - catch( Exception& ) - { - } - return xInStream; -} - -Reference< XOutputStream > OleStorage::implOpenOutputStream( const OUString& rElementName ) -{ - Reference< XOutputStream > xOutStream; - if( mxElements.is() && (rElementName.getLength() > 0) ) try - { - (void)rElementName; // prevent compiler warning - OSL_ENSURE( false, "OleStorage::implOpenOutputStream - not implemented" ); - } - catch( Exception& ) - { - } - return xOutStream; -} - -// ============================================================================ - -} // namespace oox - diff --git a/oox/source/helper/propertyset.cxx b/oox/source/helper/propertyset.cxx index 5477224b9461..c52872e50f2f 100644 --- a/oox/source/helper/propertyset.cxx +++ b/oox/source/helper/propertyset.cxx @@ -57,6 +57,12 @@ bool PropertySet::getAnyProperty( Any& orValue, sal_Int32 nPropId ) const return getAnyProperty( orValue, PropertyMap::getPropertyName( nPropId ) ); } +Any PropertySet::getAnyProperty( sal_Int32 nPropId ) const +{ + Any aValue; + return getAnyProperty( aValue, nPropId ) ? aValue : Any(); +} + bool PropertySet::getBoolProperty( sal_Int32 nPropId ) const { Any aAny; @@ -66,18 +72,17 @@ bool PropertySet::getBoolProperty( sal_Int32 nPropId ) const void PropertySet::getProperties( Sequence< Any >& orValues, const Sequence< OUString >& rPropNames ) const { - if( mxMultiPropSet.is() ) // first try the XMultiPropertySet + if( mxMultiPropSet.is() ) try { - try - { - orValues = mxMultiPropSet->getPropertyValues( rPropNames ); - } - catch( Exception& ) - { - OSL_ENSURE( false, "PropertySet::getProperties - cannot get all property values" ); - } + orValues = mxMultiPropSet->getPropertyValues( rPropNames ); + return; } - else if( mxPropSet.is() ) + catch( Exception& ) + { + OSL_ENSURE( false, "PropertySet::getProperties - cannot get all property values - fallback to single mode" ); + } + + if( mxPropSet.is() ) { sal_Int32 nLen = rPropNames.getLength(); const OUString* pPropName = rPropNames.getConstArray(); @@ -101,18 +106,17 @@ void PropertySet::setProperties( const Sequence< OUString >& rPropNames, const S OSL_ENSURE( rPropNames.getLength() == rValues.getLength(), "PropertySet::setProperties - length of sequences different" ); - if( mxMultiPropSet.is() ) // first try the XMultiPropertySet + if( mxMultiPropSet.is() ) try { - try - { - mxMultiPropSet->setPropertyValues( rPropNames, rValues ); - } - catch( Exception& ) - { - OSL_ENSURE( false, "PropertySet::setProperties - cannot set all property values" ); - } + mxMultiPropSet->setPropertyValues( rPropNames, rValues ); + return; } - else if( mxPropSet.is() ) + catch( Exception& ) + { + OSL_ENSURE( false, "PropertySet::setProperties - cannot set all property values, fallback to single mode" ); + } + + if( mxPropSet.is() ) { const OUString* pPropName = rPropNames.getConstArray(); const OUString* pPropNameEnd = pPropName + rPropNames.getLength(); diff --git a/oox/source/helper/storagebase.cxx b/oox/source/helper/storagebase.cxx index 6f174a74593c..4a05f66db81b 100644 --- a/oox/source/helper/storagebase.cxx +++ b/oox/source/helper/storagebase.cxx @@ -29,11 +29,14 @@ #include #include #include +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/binaryoutputstream.hxx" using ::rtl::OUString; using ::rtl::OUStringBuffer; +using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_SET_THROW; using ::com::sun::star::embed::XStorage; using ::com::sun::star::embed::XTransactedObject; using ::com::sun::star::io::XInputStream; @@ -66,24 +69,25 @@ void lclSplitFirstElement( OUString& orElement, OUString& orRemainder, const OUS StorageBase::StorageBase( const Reference< XInputStream >& rxInStream, bool bBaseStreamAccess ) : mxInStream( rxInStream ), - mpParentStorage( 0 ), - mbBaseStreamAccess( bBaseStreamAccess ) + mbBaseStreamAccess( bBaseStreamAccess ), + mbReadOnly( true ) { OSL_ENSURE( mxInStream.is(), "StorageBase::StorageBase - missing base input stream" ); } StorageBase::StorageBase( const Reference< XStream >& rxOutStream, bool bBaseStreamAccess ) : mxOutStream( rxOutStream ), - mpParentStorage( 0 ), - mbBaseStreamAccess( bBaseStreamAccess ) + mbBaseStreamAccess( bBaseStreamAccess ), + mbReadOnly( false ) { OSL_ENSURE( mxOutStream.is(), "StorageBase::StorageBase - missing base output stream" ); } -StorageBase::StorageBase( const StorageBase& rParentStorage, const OUString& rStorageName ) : +StorageBase::StorageBase( const StorageBase& rParentStorage, const OUString& rStorageName, bool bReadOnly ) : + maParentPath( rParentStorage.getPath() ), maStorageName( rStorageName ), - mpParentStorage( &rParentStorage ), - mbBaseStreamAccess( false ) + mbBaseStreamAccess( false ), + mbReadOnly( bReadOnly ) { } @@ -96,6 +100,16 @@ bool StorageBase::isStorage() const return implIsStorage(); } +bool StorageBase::isRootStorage() const +{ + return implIsStorage() && (maStorageName.getLength() == 0); +} + +bool StorageBase::isReadOnly() const +{ + return mbReadOnly; +} + Reference< XStorage > StorageBase::getXStorage() const { return implGetXStorage(); @@ -108,9 +122,7 @@ const OUString& StorageBase::getName() const OUString StorageBase::getPath() const { - OUStringBuffer aBuffer; - if( mpParentStorage ) - aBuffer.append( mpParentStorage->getPath() ); + OUStringBuffer aBuffer( maParentPath ); if( aBuffer.getLength() > 0 ) aBuffer.append( sal_Unicode( '/' ) ); aBuffer.append( maStorageName ); @@ -123,15 +135,19 @@ void StorageBase::getElementNames( ::std::vector< OUString >& orElementNames ) c implGetElementNames( orElementNames ); } -StorageRef StorageBase::openSubStorage( const OUString& rStorageName, bool bCreate ) +StorageRef StorageBase::openSubStorage( const OUString& rStorageName, bool bCreateMissing ) { StorageRef xSubStorage; - OUString aElement, aRemainder; - lclSplitFirstElement( aElement, aRemainder, rStorageName ); - if( aElement.getLength() > 0 ) - xSubStorage = getSubStorage( aElement, bCreate ); - if( xSubStorage.get() && (aRemainder.getLength() > 0) ) - xSubStorage = xSubStorage->openSubStorage( aRemainder, bCreate ); + OSL_ENSURE( !bCreateMissing || !mbReadOnly, "StorageBase::openSubStorage - cannot create substorage in read-only mode" ); + if( !bCreateMissing || !mbReadOnly ) + { + OUString aElement, aRemainder; + lclSplitFirstElement( aElement, aRemainder, rStorageName ); + if( aElement.getLength() > 0 ) + xSubStorage = getSubStorage( aElement, bCreateMissing ); + if( xSubStorage.get() && (aRemainder.getLength() > 0) ) + xSubStorage = xSubStorage->openSubStorage( aRemainder, bCreateMissing ); + } return xSubStorage; } @@ -163,47 +179,96 @@ Reference< XInputStream > StorageBase::openInputStream( const OUString& rStreamN Reference< XOutputStream > StorageBase::openOutputStream( const OUString& rStreamName ) { Reference< XOutputStream > xOutStream; - OUString aElement, aRemainder; - lclSplitFirstElement( aElement, aRemainder, rStreamName ); - if( aElement.getLength() > 0 ) + OSL_ENSURE( !mbReadOnly, "StorageBase::openOutputStream - cannot create output stream in read-only mode" ); + if( !mbReadOnly ) { - if( aRemainder.getLength() > 0 ) + OUString aElement, aRemainder; + lclSplitFirstElement( aElement, aRemainder, rStreamName ); + if( aElement.getLength() > 0 ) { - StorageRef xSubStorage = getSubStorage( aElement, true ); - if( xSubStorage.get() ) - xOutStream = xSubStorage->openOutputStream( aRemainder ); + if( aRemainder.getLength() > 0 ) + { + StorageRef xSubStorage = getSubStorage( aElement, true ); + if( xSubStorage.get() ) + xOutStream = xSubStorage->openOutputStream( aRemainder ); + } + else + { + xOutStream = implOpenOutputStream( aElement ); + } } - else + else if( mbBaseStreamAccess ) { - xOutStream = implOpenOutputStream( aElement ); + xOutStream = mxOutStream->getOutputStream(); } } - else if( mbBaseStreamAccess ) + return xOutStream; +} + +void StorageBase::copyToStorage( StorageBase& rDestStrg, const OUString& rElementName ) +{ + OSL_ENSURE( rDestStrg.isStorage() && !rDestStrg.isReadOnly(), "StorageBase::copyToStorage - invalid destination" ); + OSL_ENSURE( rElementName.getLength() > 0, "StorageBase::copyToStorage - invalid element name" ); + if( rDestStrg.isStorage() && !rDestStrg.isReadOnly() && (rElementName.getLength() > 0) ) { - xOutStream = mxOutStream->getOutputStream(); + StorageRef xSubStrg = openSubStorage( rElementName, false ); + if( xSubStrg.get() ) + { + StorageRef xDestSubStrg = rDestStrg.openSubStorage( rElementName, true ); + if( xDestSubStrg.get() ) + xSubStrg->copyStorageToStorage( *xDestSubStrg ); + } + else + { + Reference< XInputStream > xInStrm = openInputStream( rElementName ); + if( xInStrm.is() ) + { + Reference< XOutputStream > xOutStrm = rDestStrg.openOutputStream( rElementName ); + if( xOutStrm.is() ) + { + BinaryXInputStream aInStrm( xInStrm, true ); + BinaryXOutputStream aOutStrm( xOutStrm, true ); + aInStrm.copyToStream( aOutStrm ); + } + } + } } - return xOutStream; } -StorageRef StorageBase::getSubStorage( const OUString& rElementName, bool bCreate ) +void StorageBase::copyStorageToStorage( StorageBase& rDestStrg ) { - SubStorageMap::iterator aIt = maSubStorages.find( rElementName ); - return (aIt == maSubStorages.end()) ? - (maSubStorages[ rElementName ] = implOpenSubStorage( rElementName, bCreate )) : aIt->second; + OSL_ENSURE( rDestStrg.isStorage() && !rDestStrg.isReadOnly(), "StorageBase::copyToStorage - invalid destination" ); + if( rDestStrg.isStorage() && !rDestStrg.isReadOnly() ) + { + ::std::vector< OUString > aElements; + getElementNames( aElements ); + for( ::std::vector< OUString >::iterator aIt = aElements.begin(), aEnd = aElements.end(); aIt != aEnd; ++aIt ) + copyToStorage( rDestStrg, *aIt ); + } } void StorageBase::commit() { - for( SubStorageMap::iterator aIt = maSubStorages.begin(); aIt != maSubStorages.end(); aIt ++ ) - aIt->second->commit(); + OSL_ENSURE( !mbReadOnly, "StorageBase::commit - cannot commit in read-only mode" ); + if( !mbReadOnly ) + { + // commit all open substorages + maSubStorages.forEachMem( &StorageBase::commit ); + // commit this storage + implCommit(); + } +} - Reference< XTransactedObject > xTransactedObj( getXStorage(), UNO_QUERY ); +// private -------------------------------------------------------------------- - if( xTransactedObj.is() ) - xTransactedObj->commit(); +StorageRef StorageBase::getSubStorage( const OUString& rElementName, bool bCreateMissing ) +{ + StorageRef& rxSubStrg = maSubStorages[ rElementName ]; + if( !rxSubStrg ) + rxSubStrg = implOpenSubStorage( rElementName, bCreateMissing ); + return rxSubStrg; } // ============================================================================ } // namespace oox - diff --git a/oox/source/helper/textinputstream.cxx b/oox/source/helper/textinputstream.cxx new file mode 100755 index 000000000000..d6d4736f3ca2 --- /dev/null +++ b/oox/source/helper/textinputstream.cxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/helper/textinputstream.hxx" +#include +#include +#include "oox/helper/binaryinputstream.hxx" + +using ::rtl::OStringBuffer; +using ::rtl::OStringToOUString; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + +namespace oox { + +// ============================================================================ + +namespace { + +/** Reads a text line from stream. First, tries to skip the second character of + a two-character line end sequence. Returns the new line-end character. */ +template< typename BufferType, typename CharType, typename StreamDataType > +sal_Unicode lclReadLine( BufferType& orBuffer, BinaryInputStream& rInStrm, sal_Unicode cLastEolChar ) +{ + // try to skip LF following CR, or CR following LF + if( !rInStrm.isEof() && (cLastEolChar != 0) ) + { + CharType cChar = static_cast< CharType >( rInStrm.readValue< StreamDataType >() ); + // return on EOF after line-end + if( rInStrm.isEof() ) + return 0; + // return on sequence of equal line-end characters + bool bIsEolChar = (cChar == 10) || (cChar == 13); + if( bIsEolChar && (cChar == cLastEolChar) ) + return cChar; + // append the character, if it is not the other line-end charcter + if( !bIsEolChar ) + orBuffer.append( cChar ); + } + + // read chars until EOF or line end character (LF or CR) + while( true ) + { + CharType cChar = static_cast< CharType >( rInStrm.readValue< StreamDataType >() ); + if( rInStrm.isEof() ) + return 0; + if( (cChar == 10) || (cChar == 13) ) + return cChar; + orBuffer.append( cChar ); + } +} + +} // namespace + +// ============================================================================ + +TextInputStream::TextInputStream( BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc ) : + mrInStrm( rInStrm ), + meTextEnc( eTextEnc ), + mcLastEolChar( 0 ) +{ +} + +bool TextInputStream::isEof() const +{ + // do not return EOF, if last text line missed line-end character (see below) + return mrInStrm.isEof() && (mcLastEolChar == 0); +} + +OUString TextInputStream::readLine() +{ + if( mrInStrm.isEof() ) + { + mcLastEolChar = 0; + return OUString(); + } + + OUString aLine; + if( meTextEnc == RTL_TEXTENCODING_UCS2 ) + { + // read 16-bit characters for UCS2 encoding + OUStringBuffer aBuffer; + mcLastEolChar = lclReadLine< OUStringBuffer, sal_Unicode, sal_uInt16 >( aBuffer, mrInStrm, mcLastEolChar ); + aLine = aBuffer.makeStringAndClear(); + } + else + { + // otherwise, read 8-bit characters and convert according to text encoding + OStringBuffer aBuffer; + mcLastEolChar = lclReadLine< OStringBuffer, sal_Char, sal_uInt8 >( aBuffer, mrInStrm, mcLastEolChar ); + aLine = OStringToOUString( aBuffer.makeStringAndClear(), meTextEnc ); + } + + // if last line is not empty but line-end character is missing, do not return EOF + if( mrInStrm.isEof() && (aLine.getLength() > 0) ) + mcLastEolChar = 10; + + return aLine; +} + +// ============================================================================ + +} // namespace oox + diff --git a/oox/source/helper/zipstorage.cxx b/oox/source/helper/zipstorage.cxx index c90b2071b133..72b6fcd1bff0 100644 --- a/oox/source/helper/zipstorage.cxx +++ b/oox/source/helper/zipstorage.cxx @@ -26,26 +26,29 @@ ************************************************************************/ #include "oox/helper/zipstorage.hxx" -#include -#include -#include #include +#include +#include #include #include +#include #include #include "oox/helper/helper.hxx" using ::rtl::OUString; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::container::NoSuchElementException; using ::com::sun::star::embed::XStorage; +using ::com::sun::star::embed::XTransactedObject; using ::com::sun::star::io::XInputStream; using ::com::sun::star::io::XOutputStream; using ::com::sun::star::io::XStream; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; namespace oox { @@ -93,7 +96,7 @@ ZipStorage::ZipStorage( } ZipStorage::ZipStorage( const ZipStorage& rParentStorage, const Reference< XStorage >& rxStorage, const OUString& rElementName ) : - StorageBase( rParentStorage, rElementName ), + StorageBase( rParentStorage, rElementName, rParentStorage.isReadOnly() ), mxStorage( rxStorage ) { OSL_ENSURE( mxStorage.is(), "ZipStorage::ZipStorage - missing storage" ); @@ -127,7 +130,7 @@ void ZipStorage::implGetElementNames( ::std::vector< OUString >& orElementNames } } -StorageRef ZipStorage::implOpenSubStorage( const OUString& rElementName, bool bCreate ) +StorageRef ZipStorage::implOpenSubStorage( const OUString& rElementName, bool bCreateMissing ) { Reference< XStorage > xSubXStorage; bool bMissing = false; @@ -138,7 +141,7 @@ StorageRef ZipStorage::implOpenSubStorage( const OUString& rElementName, bool bC xSubXStorage = mxStorage->openStorageElement( rElementName, ::com::sun::star::embed::ElementModes::READ ); } - catch( ::com::sun::star::container::NoSuchElementException& ) + catch( NoSuchElementException& ) { bMissing = true; } @@ -146,15 +149,14 @@ StorageRef ZipStorage::implOpenSubStorage( const OUString& rElementName, bool bC { } - if( bMissing && bCreate ) - try - { - xSubXStorage = mxStorage->openStorageElement( - rElementName, ::com::sun::star::embed::ElementModes::READWRITE ); - } - catch( Exception& ) - { - } + if( bMissing && bCreateMissing ) try + { + xSubXStorage = mxStorage->openStorageElement( + rElementName, ::com::sun::star::embed::ElementModes::READWRITE ); + } + catch( Exception& ) + { + } StorageRef xSubStorage; if( xSubXStorage.is() ) @@ -188,7 +190,17 @@ Reference< XOutputStream > ZipStorage::implOpenOutputStream( const OUString& rEl return xOutStream; } +void ZipStorage::implCommit() const +{ + try + { + Reference< XTransactedObject >( mxStorage, UNO_QUERY_THROW )->commit(); + } + catch( Exception& ) + { + } +} + // ============================================================================ } // namespace oox - diff --git a/oox/source/ole/axbinaryreader.cxx b/oox/source/ole/axbinaryreader.cxx index f49776ef70e5..cb7e292b8cf4 100644 --- a/oox/source/ole/axbinaryreader.cxx +++ b/oox/source/ole/axbinaryreader.cxx @@ -89,13 +89,80 @@ void AxAlignedInputStream::align( size_t nSize ) // ============================================================================ +AxFontData::AxFontData() : + mnFontEffects( 0 ), + mnFontHeight( 160 ), + mnFontCharSet( WINDOWS_CHARSET_DEFAULT ), + mnHorAlign( AX_FONTDATA_LEFT ) +{ +} + +sal_Int16 AxFontData::getHeightPoints() const +{ + /* MSO uses weird font sizes: + 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135, + 8pt->165, 9pt->180, 10pt->195, 11pt->225, ... */ + return getLimitedValue< sal_Int16, sal_Int32 >( (mnFontHeight + 10) / 20, 1, SAL_MAX_INT16 ); +} + +void AxFontData::setHeightPoints( sal_Int16 nPoints ) +{ + mnFontHeight = getLimitedValue< sal_Int32, sal_Int32 >( ((nPoints * 4 + 1) / 3) * 15, 30, 4294967 ); +} + +bool AxFontData::importBinaryModel( BinaryInputStream& rInStrm ) +{ + AxBinaryPropertyReader aReader( rInStrm ); + aReader.readStringProperty( maFontName ); + aReader.readIntProperty< sal_uInt32 >( mnFontEffects ); + aReader.readIntProperty< sal_Int32 >( mnFontHeight ); + aReader.skipIntProperty< sal_Int32 >(); // font offset + aReader.readIntProperty< sal_uInt8 >( mnFontCharSet ); + aReader.skipIntProperty< sal_uInt8 >(); // font pitch/family + aReader.readIntProperty< sal_uInt8 >( mnHorAlign ); + aReader.skipIntProperty< sal_uInt16 >(); // font weight + return aReader.finalizeImport(); +} + +bool AxFontData::importStdFont( BinaryInputStream& rInStrm ) +{ + StdFontInfo aFontInfo; + if( OleHelper::importStdFont( aFontInfo, rInStrm, false ) ) + { + maFontName = aFontInfo.maName; + mnFontEffects = 0; + setFlag( mnFontEffects, AX_FONTDATA_BOLD, aFontInfo.mnWeight >= OLE_STDFONT_BOLD ); + setFlag( mnFontEffects, AX_FONTDATA_ITALIC, getFlag( aFontInfo.mnFlags, OLE_STDFONT_ITALIC ) ); + setFlag( mnFontEffects, AX_FONTDATA_UNDERLINE, getFlag( aFontInfo.mnFlags, OLE_STDFONT_UNDERLINE ) ); + setFlag( mnFontEffects, AX_FONTDATA_STRIKEOUT, getFlag( aFontInfo.mnFlags,OLE_STDFONT_STRIKE ) ); + // StdFont stores font height in 1/10,000 of points + setHeightPoints( getLimitedValue< sal_Int16, sal_Int32 >( aFontInfo.mnHeight / 10000, 0, SAL_MAX_INT16 ) ); + mnFontCharSet = aFontInfo.mnCharSet; + mnHorAlign = AX_FONTDATA_LEFT; + return true; + } + return false; +} + +bool AxFontData::importGuidAndFont( BinaryInputStream& rInStrm ) +{ + OUString aGuid = OleHelper::importGuid( rInStrm ); + if( aGuid.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{AFC20920-DA4E-11CE-B943-00AA006887B4}" ) ) ) + return importBinaryModel( rInStrm ); + if( aGuid.equalsAscii( OLE_GUID_STDFONT ) ) + return importStdFont( rInStrm ); + return false; +} + +// ============================================================================ + AxBinaryPropertyReader::ComplexProperty::~ComplexProperty() { } bool AxBinaryPropertyReader::PairProperty::readProperty( AxAlignedInputStream& rInStrm ) { - rInStrm >> mrnValue1 >> mrnValue2; + rInStrm >> mrPairData.first >> mrPairData.second; return true; } @@ -116,6 +183,17 @@ bool AxBinaryPropertyReader::StringProperty::readProperty( AxAlignedInputStream& return bValidChars; } +bool AxBinaryPropertyReader::GuidProperty::readProperty( AxAlignedInputStream& rInStrm ) +{ + mrGuid = OleHelper::importGuid( rInStrm ); + return true; +} + +bool AxBinaryPropertyReader::FontProperty::readProperty( AxAlignedInputStream& rInStrm ) +{ + return mrFontData.importGuidAndFont( rInStrm ); +} + bool AxBinaryPropertyReader::PictureProperty::readProperty( AxAlignedInputStream& rInStrm ) { return OleHelper::importStdPic( mrPicData, rInStrm, true ); @@ -145,10 +223,10 @@ void AxBinaryPropertyReader::readBoolProperty( bool& orbValue, bool bReverse ) orbValue = startNextProperty() != bReverse; } -void AxBinaryPropertyReader::readPairProperty( sal_Int32& ornValue1, sal_Int32& ornValue2 ) +void AxBinaryPropertyReader::readPairProperty( AxPairData& orPairData ) { if( startNextProperty() ) - maLargeProps.push_back( ComplexPropVector::value_type( new PairProperty( ornValue1, ornValue2 ) ) ); + maLargeProps.push_back( ComplexPropVector::value_type( new PairProperty( orPairData ) ) ); } void AxBinaryPropertyReader::readStringProperty( OUString& orValue ) @@ -160,6 +238,22 @@ void AxBinaryPropertyReader::readStringProperty( OUString& orValue ) } } +void AxBinaryPropertyReader::readGuidProperty( ::rtl::OUString& orGuid ) +{ + if( startNextProperty() ) + maLargeProps.push_back( ComplexPropVector::value_type( new GuidProperty( orGuid ) ) ); +} + +void AxBinaryPropertyReader::readFontProperty( AxFontData& orFontData ) +{ + if( startNextProperty() ) + { + sal_Int16 nData = maInStrm.readAligned< sal_Int16 >(); + if( ensureValid( nData == -1 ) ) + maStreamProps.push_back( ComplexPropVector::value_type( new FontProperty( orFontData ) ) ); + } +} + void AxBinaryPropertyReader::readPictureProperty( StreamDataSequence& orPicData ) { if( startNextProperty() ) diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 9f99bf625333..da0acd233cbb 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -27,20 +27,24 @@ #include "oox/ole/axcontrol.hxx" #include -#include -#include #include #include #include #include #include #include +#include #include +#include #include #include #include -#include +#include +#include #include +#include +#include +#include #include "properties.hxx" #include "tokens.hxx" #include "oox/helper/attributelist.hxx" @@ -48,20 +52,23 @@ #include "oox/helper/graphichelper.hxx" #include "oox/helper/propertymap.hxx" #include "oox/helper/propertyset.hxx" -#include "oox/core/filterbase.hxx" -#include "oox/ole/axbinaryreader.hxx" -#include "oox/ole/axcontrolhelper.hxx" -#include "oox/ole/olehelper.hxx" using ::rtl::OUString; +using ::com::sun::star::awt::Point; +using ::com::sun::star::awt::Size; +using ::com::sun::star::awt::XControlModel; +using ::com::sun::star::container::XIndexContainer; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::drawing::XDrawPage; +using ::com::sun::star::form::XForm; +using ::com::sun::star::form::XFormComponent; +using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::container::XIndexContainer; -using ::com::sun::star::awt::XControlModel; -using ::com::sun::star::form::XFormComponent; -using ::oox::core::FilterBase; +using ::com::sun::star::uno::UNO_SET_THROW; namespace oox { namespace ole { @@ -70,6 +77,29 @@ namespace ole { namespace { +const sal_uInt32 COMCTL_ID_SIZE = 0x12344321; + +const sal_uInt32 COMCTL_ID_COMMONDATA = 0xABCDEF01; +const sal_uInt32 COMCTL_COMMON_FLATBORDER = 0x00000001; +const sal_uInt32 COMCTL_COMMON_ENABLED = 0x00000002; +const sal_uInt32 COMCTL_COMMON_3DBORDER = 0x00000004; +const sal_uInt32 COMCTL_COMMON_OLEDROPMAN = 0x00002000; + +const sal_uInt32 COMCTL_ID_COMPLEXDATA = 0xBDECDE1F; +const sal_uInt32 COMCTL_COMPLEX_FONT = 0x00000001; +const sal_uInt32 COMCTL_COMPLEX_MOUSEICON = 0x00000002; + +const sal_uInt32 COMCTL_ID_SCROLLBAR_60 = 0x99470A83; +const sal_uInt32 COMCTL_SCROLLBAR_HOR = 0x00000010; +const sal_Int32 COMCTL_SCROLLBAR_3D = 0; +const sal_Int32 COMCTL_SCROLLBAR_FLAT = 1; +const sal_Int32 COMCTL_SCROLLBAR_TRACK3D = 2; + +const sal_uInt32 COMCTL_ID_PROGRESSBAR_50 = 0xE6E17E84; +const sal_uInt32 COMCTL_ID_PROGRESSBAR_60 = 0x97AB8A01; + +// ---------------------------------------------------------------------------- + const sal_uInt32 AX_FLAGS_ENABLED = 0x00000002; const sal_uInt32 AX_FLAGS_LOCKED = 0x00000004; const sal_uInt32 AX_FLAGS_OPAQUE = 0x00000008; @@ -99,26 +129,6 @@ const sal_uInt32 AX_MORPHDATA_DEFFLAGS = 0x2C80081B; const sal_uInt32 AX_SPINBUTTON_DEFFLAGS = 0x0000001B; const sal_uInt32 AX_SCROLLBAR_DEFFLAGS = 0x0000001B; -const sal_uInt32 AX_FONT_BOLD = 0x00000001; -const sal_uInt32 AX_FONT_ITALIC = 0x00000002; -const sal_uInt32 AX_FONT_UNDERLINE = 0x00000004; -const sal_uInt32 AX_FONT_STRIKEOUT = 0x00000008; -const sal_uInt32 AX_FONT_DISABLED = 0x00002000; -const sal_uInt32 AX_FONT_AUTOCOLOR = 0x40000000; - -const sal_Int32 AX_FONTALIGN_LEFT = 1; -const sal_Int32 AX_FONTALIGN_RIGHT = 2; -const sal_Int32 AX_FONTALIGN_CENTER = 3; - -const sal_Int32 AX_BORDERSTYLE_NONE = 0; -const sal_Int32 AX_BORDERSTYLE_SINGLE = 1; - -const sal_Int32 AX_SPECIALEFFECT_FLAT = 0; -const sal_Int32 AX_SPECIALEFFECT_RAISED = 1; -const sal_Int32 AX_SPECIALEFFECT_SUNKEN = 2; -const sal_Int32 AX_SPECIALEFFECT_ETCHED = 3; -const sal_Int32 AX_SPECIALEFFECT_BUMPED = 6; - const sal_uInt16 AX_POS_TOPLEFT = 0; const sal_uInt16 AX_POS_TOP = 1; const sal_uInt16 AX_POS_TOPRIGHT = 2; @@ -129,31 +139,21 @@ const sal_uInt16 AX_POS_BOTTOMLEFT = 6; const sal_uInt16 AX_POS_BOTTOM = 7; const sal_uInt16 AX_POS_BOTTOMRIGHT = 8; -#define AX_PICPOS( label, image ) ((AX_POS_##label << 16) | AX_POS_##image) -const sal_uInt32 AX_PICPOS_LEFTTOP = AX_PICPOS( TOPRIGHT, TOPLEFT ); -const sal_uInt32 AX_PICPOS_LEFTCENTER = AX_PICPOS( RIGHT, LEFT ); -const sal_uInt32 AX_PICPOS_LEFTBOTTOM = AX_PICPOS( BOTTOMRIGHT, BOTTOMLEFT ); -const sal_uInt32 AX_PICPOS_RIGHTTOP = AX_PICPOS( TOPLEFT, TOPRIGHT ); -const sal_uInt32 AX_PICPOS_RIGHTCENTER = AX_PICPOS( LEFT, RIGHT ); -const sal_uInt32 AX_PICPOS_RIGHTBOTTOM = AX_PICPOS( BOTTOMLEFT, BOTTOMRIGHT ); -const sal_uInt32 AX_PICPOS_ABOVELEFT = AX_PICPOS( BOTTOMLEFT, TOPLEFT ); -const sal_uInt32 AX_PICPOS_ABOVECENTER = AX_PICPOS( BOTTOM, TOP ); -const sal_uInt32 AX_PICPOS_ABOVERIGHT = AX_PICPOS( BOTTOMRIGHT, TOPRIGHT ); -const sal_uInt32 AX_PICPOS_BELOWLEFT = AX_PICPOS( TOPLEFT, BOTTOMLEFT ); -const sal_uInt32 AX_PICPOS_BELOWCENTER = AX_PICPOS( TOP, BOTTOM ); -const sal_uInt32 AX_PICPOS_BELOWRIGHT = AX_PICPOS( TOPRIGHT, BOTTOMRIGHT ); -const sal_uInt32 AX_PICPOS_CENTER = AX_PICPOS( CENTER, CENTER ); -#undef AX_PICPOS - -const sal_Int32 AX_PICSIZE_CLIP = 0; -const sal_Int32 AX_PICSIZE_STRETCH = 1; -const sal_Int32 AX_PICSIZE_ZOOM = 3; - -const sal_Int32 AX_PICALIGN_TOPLEFT = 0; -const sal_Int32 AX_PICALIGN_TOPRIGHT = 1; -const sal_Int32 AX_PICALIGN_CENTER = 2; -const sal_Int32 AX_PICALIGN_BOTTOMLEFT = 3; -const sal_Int32 AX_PICALIGN_BOTTOMRIGHT = 4; +#define AX_PICPOS_IMPL( label, image ) ((AX_POS_##label << 16) | AX_POS_##image) +const sal_uInt32 AX_PICPOS_LEFTTOP = AX_PICPOS_IMPL( TOPRIGHT, TOPLEFT ); +const sal_uInt32 AX_PICPOS_LEFTCENTER = AX_PICPOS_IMPL( RIGHT, LEFT ); +const sal_uInt32 AX_PICPOS_LEFTBOTTOM = AX_PICPOS_IMPL( BOTTOMRIGHT, BOTTOMLEFT ); +const sal_uInt32 AX_PICPOS_RIGHTTOP = AX_PICPOS_IMPL( TOPLEFT, TOPRIGHT ); +const sal_uInt32 AX_PICPOS_RIGHTCENTER = AX_PICPOS_IMPL( LEFT, RIGHT ); +const sal_uInt32 AX_PICPOS_RIGHTBOTTOM = AX_PICPOS_IMPL( BOTTOMLEFT, BOTTOMRIGHT ); +const sal_uInt32 AX_PICPOS_ABOVELEFT = AX_PICPOS_IMPL( BOTTOMLEFT, TOPLEFT ); +const sal_uInt32 AX_PICPOS_ABOVECENTER = AX_PICPOS_IMPL( BOTTOM, TOP ); +const sal_uInt32 AX_PICPOS_ABOVERIGHT = AX_PICPOS_IMPL( BOTTOMRIGHT, TOPRIGHT ); +const sal_uInt32 AX_PICPOS_BELOWLEFT = AX_PICPOS_IMPL( TOPLEFT, BOTTOMLEFT ); +const sal_uInt32 AX_PICPOS_BELOWCENTER = AX_PICPOS_IMPL( TOP, BOTTOM ); +const sal_uInt32 AX_PICPOS_BELOWRIGHT = AX_PICPOS_IMPL( TOPRIGHT, BOTTOMRIGHT ); +const sal_uInt32 AX_PICPOS_CENTER = AX_PICPOS_IMPL( CENTER, CENTER ); +#undef AX_PICPOS_IMPL const sal_Int32 AX_DISPLAYSTYLE_TEXT = 1; const sal_Int32 AX_DISPLAYSTYLE_LISTBOX = 2; @@ -186,6 +186,25 @@ const sal_Int32 AX_ORIENTATION_HORIZONTAL = 1; const sal_Int32 AX_PROPTHUMB_ON = -1; const sal_Int32 AX_PROPTHUMB_OFF = 0; +const sal_uInt32 AX_CONTAINER_ENABLED = 0x00000004; +const sal_uInt32 AX_CONTAINER_HASDESIGNEXT = 0x00004000; +const sal_uInt32 AX_CONTAINER_NOCLASSTABLE = 0x00008000; + +const sal_uInt32 AX_CONTAINER_DEFFLAGS = 0x00000004; + +const sal_Int32 AX_CONTAINER_DEFWIDTH = 4000; +const sal_Int32 AX_CONTAINER_DEFHEIGHT = 3000; + +const sal_Int32 AX_CONTAINER_CYCLEALL = 0; +const sal_Int32 AX_CONTAINER_CYCLECURRENT = 2; + +const sal_Int32 AX_CONTAINER_SCR_NONE = 0x00; +const sal_Int32 AX_CONTAINER_SCR_HOR = 0x01; +const sal_Int32 AX_CONTAINER_SCR_VER = 0x02; +const sal_Int32 AX_CONTAINER_SCR_KEEP_HOR = 0x04; +const sal_Int32 AX_CONTAINER_SCR_KEEP_VER = 0x08; +const sal_Int32 AX_CONTAINER_SCR_SHOW_LEFT = 0x10; + // ---------------------------------------------------------------------------- const sal_Int16 API_BORDER_NONE = 0; @@ -196,27 +215,82 @@ const sal_Int16 API_STATE_UNCHECKED = 0; const sal_Int16 API_STATE_CHECKED = 1; const sal_Int16 API_STATE_DONTKNOW = 2; -// ---------------------------------------------------------------------------- +} // namespace + +// ============================================================================ -/** Specifies how a form control supports transparent background. */ -enum ApiTransparencyMode +ControlConverter::ControlConverter( const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) : + mrGraphicHelper( rGraphicHelper ), + mbDefaultColorBgr( bDefaultColorBgr ) { - API_TRANSPARENCY_NOTSUPPORTED, /// Control does not support transparency. - API_TRANSPARENCY_VOID, /// Transparency is enabled by missing fill color. - API_TRANSPARENCY_PAINTTRANSPARENT /// Transparency is enabled by the 'PaintTransparent' property. -}; +} -// ---------------------------------------------------------------------------- +ControlConverter::~ControlConverter() +{ +} + +// Generic conversion --------------------------------------------------------- + +void ControlConverter::convertSize( PropertyMap& rPropMap, const AxPairData& rSize ) const +{ + // size is given in 1/100 mm, UNO needs AppFont units + Size aAppFontSize = mrGraphicHelper.convertHmmToAppFont( Size( rSize.first, rSize.second ) ); + rPropMap.setProperty( PROP_Width, aAppFontSize.Width ); + rPropMap.setProperty( PROP_Height, aAppFontSize.Height ); +} + +void ControlConverter::convertPosition( PropertyMap& rPropMap, const AxPairData& rPos ) const +{ + // position is given in 1/100 mm, UNO needs AppFont units + Point aAppFontPos = mrGraphicHelper.convertHmmToAppFont( Point( rPos.first, rPos.second ) ); + rPropMap.setProperty( PROP_PositionX, aAppFontPos.X ); + rPropMap.setProperty( PROP_PositionY, aAppFontPos.Y ); +} + +void ControlConverter::convertColor( PropertyMap& rPropMap, sal_Int32 nPropId, sal_uInt32 nOleColor ) const +{ + rPropMap.setProperty( nPropId, OleHelper::decodeOleColor( mrGraphicHelper, nOleColor, mbDefaultColorBgr ) ); +} + +void ControlConverter::convertPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData ) const +{ + if( rPicData.hasElements() ) + { + OUString aGraphicUrl = mrGraphicHelper.importGraphicObject( rPicData ); + if( aGraphicUrl.getLength() > 0 ) + rPropMap.setProperty( PROP_ImageURL, aGraphicUrl ); + } +} + +void ControlConverter::convertOrientation( PropertyMap& rPropMap, bool bHorizontal ) const +{ + namespace AwtScrollBarOrient = ::com::sun::star::awt::ScrollBarOrientation; + sal_Int32 nScrollOrient = bHorizontal ? AwtScrollBarOrient::HORIZONTAL : AwtScrollBarOrient::VERTICAL; + rPropMap.setProperty( PROP_Orientation, nScrollOrient ); +} + +void ControlConverter::convertScrollBar( PropertyMap& rPropMap, + sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition, + sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const +{ + rPropMap.setProperty( PROP_ScrollValueMin, ::std::min( nMin, nMax ) ); + rPropMap.setProperty( PROP_ScrollValueMax, ::std::max( nMin, nMax ) ); + rPropMap.setProperty( PROP_LineIncrement, nSmallChange ); + rPropMap.setProperty( PROP_BlockIncrement, nLargeChange ); + rPropMap.setProperty( bAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue, nPosition ); +} -/** Converts the AX background formatting to UNO properties. */ -void lclConvertBackground( AxControlHelper& rHelper, PropertyMap& rPropMap, sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) +// ActiveX (Forms 2.0) specific conversion ------------------------------------ + +void ControlConverter::convertAxBackground( PropertyMap& rPropMap, + sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) const { bool bOpaque = getFlag( nFlags, AX_FLAGS_OPAQUE ); switch( eTranspMode ) { case API_TRANSPARENCY_NOTSUPPORTED: // fake transparency by using system window background if needed - rPropMap.setProperty( PROP_BackgroundColor, rHelper.convertColor( bOpaque ? nBackColor : AX_SYSCOLOR_WINDOWBACK ) ); + convertColor( rPropMap, PROP_BackgroundColor, bOpaque ? nBackColor : AX_SYSCOLOR_WINDOWBACK ); break; case API_TRANSPARENCY_PAINTTRANSPARENT: rPropMap.setProperty( PROP_PaintTransparent, !bOpaque ); @@ -224,52 +298,31 @@ void lclConvertBackground( AxControlHelper& rHelper, PropertyMap& rPropMap, sal_ case API_TRANSPARENCY_VOID: // keep transparency by leaving the (void) default property value if( bOpaque ) - rPropMap.setProperty( PROP_BackgroundColor, rHelper.convertColor( nBackColor ) ); + convertColor( rPropMap, PROP_BackgroundColor, nBackColor ); break; } } -// ---------------------------------------------------------------------------- - -/** Converts the AX border formatting to UNO properties. */ -void lclConvertBorder( AxControlHelper& rHelper, PropertyMap& rPropMap, sal_uInt32 nBorderColor, sal_Int32 nBorderStyle, sal_Int32 nSpecialEffect ) +void ControlConverter::convertAxBorder( PropertyMap& rPropMap, + sal_uInt32 nBorderColor, sal_Int32 nBorderStyle, sal_Int32 nSpecialEffect ) const { sal_Int16 nBorder = (nBorderStyle == AX_BORDERSTYLE_SINGLE) ? API_BORDER_FLAT : ((nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? API_BORDER_NONE : API_BORDER_SUNKEN); rPropMap.setProperty( PROP_Border, nBorder ); - rPropMap.setProperty( PROP_BorderColor, rHelper.convertColor( nBorderColor ) ); + convertColor( rPropMap, PROP_BorderColor, nBorderColor ); } -// ---------------------------------------------------------------------------- - -/** Converts the AX special effect to UNO properties. */ -void lclConvertVisualEffect( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, sal_Int32 nSpecialEffect ) +void ControlConverter::convertAxVisualEffect( PropertyMap& rPropMap, sal_Int32 nSpecialEffect ) const { namespace AwtVisualEffect = ::com::sun::star::awt::VisualEffect; sal_Int16 nVisualEffect = (nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? AwtVisualEffect::FLAT : AwtVisualEffect::LOOK3D; rPropMap.setProperty( PROP_VisualEffect, nVisualEffect ); } -// ---------------------------------------------------------------------------- - -/** Converts the passed picture stream to UNO properties. */ -void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const StreamDataSequence& rPicData ) -{ - if( rPicData.hasElements() ) - { - OUString aGraphicUrl = rHelper.getFilter().getGraphicHelper().importGraphicObject( rPicData ); - if( aGraphicUrl.getLength() > 0 ) - rPropMap.setProperty( PROP_ImageURL, aGraphicUrl ); - } -} - -// ---------------------------------------------------------------------------- - -/** Converts the passed picture stream and position to UNO properties. */ -void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) +void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) const { // the picture - lclConvertPicture( rHelper, rPropMap, rPicData ); + convertPicture( rPropMap, rPicData ); // picture position namespace AwtImagePos = ::com::sun::star::awt::ImagePosition; @@ -289,18 +342,16 @@ void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const S case AX_PICPOS_BELOWCENTER: nImagePos = AwtImagePos::BelowCenter; break; case AX_PICPOS_BELOWRIGHT: nImagePos = AwtImagePos::BelowRight; break; case AX_PICPOS_CENTER: nImagePos = AwtImagePos::Centered; break; - default: OSL_ENSURE( false, "lclConvertPicture - unknown picture position" ); + default: OSL_ENSURE( false, "ControlConverter::convertAxPicture - unknown picture position" ); } rPropMap.setProperty( PROP_ImagePosition, nImagePos ); } -// ---------------------------------------------------------------------------- - -/** Converts the passed picture stream and position to UNO properties. */ -void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_Int32 nPicSizeMode, sal_Int32 /*nPicAlign*/, bool /*bPicTiling*/ ) +void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, + sal_Int32 nPicSizeMode, sal_Int32 /*nPicAlign*/, bool /*bPicTiling*/ ) const { // the picture - lclConvertPicture( rHelper, rPropMap, rPicData ); + convertPicture( rPropMap, rPicData ); // picture scale mode namespace AwtScaleMode = ::com::sun::star::awt::ImageScaleMode; @@ -310,16 +361,17 @@ void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const S case AX_PICSIZE_CLIP: nScaleMode = AwtScaleMode::None; break; case AX_PICSIZE_STRETCH: nScaleMode = AwtScaleMode::Anisotropic; break; case AX_PICSIZE_ZOOM: nScaleMode = AwtScaleMode::Isotropic; break; - default: OSL_ENSURE( false, "lclConvertPicture - unknown picture size mode" ); + default: OSL_ENSURE( false, "ControlConverter::convertAxPicture - unknown picture size mode" ); } rPropMap.setProperty( PROP_ScaleMode, nScaleMode ); } -// ---------------------------------------------------------------------------- - -/** Converts the AX value for checked/unchecked/dontknow to UNO properties. */ -void lclConvertState( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, const OUString& rValue, sal_Int32 nMultiSelect, bool bSupportsTriState ) +void ControlConverter::convertAxState( PropertyMap& rPropMap, + const OUString& rValue, sal_Int32 nMultiSelect, ApiDefaultStateMode eDefStateMode, bool bAwtModel ) const { + bool bBooleanState = eDefStateMode == API_DEFAULTSTATE_BOOLEAN; + bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE; + // state sal_Int16 nState = bSupportsTriState ? API_STATE_DONTKNOW : API_STATE_UNCHECKED; if( rValue.getLength() == 1 ) switch( rValue[ 0 ] ) @@ -328,41 +380,280 @@ void lclConvertState( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, const case '1': nState = API_STATE_CHECKED; break; // any other string (also empty) means 'dontknow' } - rPropMap.setProperty( PROP_DefaultState, nState ); + sal_Int32 nPropId = bAwtModel ? PROP_State : PROP_DefaultState; + if( bBooleanState ) + rPropMap.setProperty( nPropId, nState != API_STATE_UNCHECKED ); + else + rPropMap.setProperty( nPropId, nState ); // tristate if( bSupportsTriState ) rPropMap.setProperty( PROP_TriState, nMultiSelect == AX_SELCTION_MULTI ); } -// ---------------------------------------------------------------------------- - -/** Converts the AX control orientation to UNO properties. */ -void lclConvertOrientation( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, sal_Int32 nOrientation, sal_Int32 nWidth, sal_Int32 nHeight ) +void ControlConverter::convertAxOrientation( PropertyMap& rPropMap, + const AxPairData& rSize, sal_Int32 nOrientation ) const { - namespace AwtScrollBarOrient = ::com::sun::star::awt::ScrollBarOrientation; - sal_Int32 nScrollOrient = AwtScrollBarOrient::HORIZONTAL; + bool bHorizontal = true; switch( nOrientation ) { - case AX_ORIENTATION_AUTO: if( nWidth <= nHeight) nScrollOrient = AwtScrollBarOrient::VERTICAL; break; - case AX_ORIENTATION_VERTICAL: nScrollOrient = AwtScrollBarOrient::VERTICAL; break; - case AX_ORIENTATION_HORIZONTAL: nScrollOrient = AwtScrollBarOrient::HORIZONTAL; break; - default: OSL_ENSURE( false, "lclConvertOrientation - unknown orientation" ); + case AX_ORIENTATION_AUTO: bHorizontal = rSize.first > rSize.second; break; + case AX_ORIENTATION_VERTICAL: bHorizontal = false; break; + case AX_ORIENTATION_HORIZONTAL: bHorizontal = true; break; + default: OSL_ENSURE( false, "ControlConverter::convertAxOrientation - unknown orientation" ); } - rPropMap.setProperty( PROP_Orientation, nScrollOrient ); + convertOrientation( rPropMap, bHorizontal ); } -} // namespace +// ============================================================================ + +ControlModelBase::ControlModelBase() : + maSize( 0, 0 ), + mbAwtModel( false ) +{ +} + +ControlModelBase::~ControlModelBase() +{ +} + +OUString ControlModelBase::getServiceName() const +{ + ApiControlType eCtrlType = getControlType(); + if( mbAwtModel ) switch( eCtrlType ) + { + case API_CONTROL_BUTTON: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlButtonModel" ); + case API_CONTROL_FIXEDTEXT: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlFixedTextModel" ); + case API_CONTROL_IMAGE: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlImageControlModel" ); + case API_CONTROL_CHECKBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlCheckBoxModel" ); + case API_CONTROL_RADIOBUTTON: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlRadioButtonModel" ); + case API_CONTROL_EDIT: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlEditModel" ); + case API_CONTROL_LISTBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlListBoxModel" ); + case API_CONTROL_COMBOBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlComboBoxModel" ); + case API_CONTROL_SPINBUTTON: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlSpinButtonModel" ); + case API_CONTROL_SCROLLBAR: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlScrollBarModel" ); + case API_CONTROL_PROGRESSBAR: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlProgressBarModel" ); + case API_CONTROL_GROUPBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlGroupBoxModel" ); + case API_CONTROL_DIALOG: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlDialogModel" ); + default: OSL_ENSURE( false, "ControlModelBase::getServiceName - no AWT model service supported" ); + } + else switch( eCtrlType ) + { + case API_CONTROL_BUTTON: return CREATE_OUSTRING( "com.sun.star.form.component.CommandButton" ); + case API_CONTROL_FIXEDTEXT: return CREATE_OUSTRING( "com.sun.star.form.component.FixedText" ); + case API_CONTROL_IMAGE: return CREATE_OUSTRING( "com.sun.star.form.component.DatabaseImageControl" ); + case API_CONTROL_CHECKBOX: return CREATE_OUSTRING( "com.sun.star.form.component.CheckBox" ); + case API_CONTROL_RADIOBUTTON: return CREATE_OUSTRING( "com.sun.star.form.component.RadioButton" ); + case API_CONTROL_EDIT: return CREATE_OUSTRING( "com.sun.star.form.component.TextField" ); + case API_CONTROL_LISTBOX: return CREATE_OUSTRING( "com.sun.star.form.component.ListBox" ); + case API_CONTROL_COMBOBOX: return CREATE_OUSTRING( "com.sun.star.form.component.ComboBox" ); + case API_CONTROL_SPINBUTTON: return CREATE_OUSTRING( "com.sun.star.form.component.SpinButton" ); + case API_CONTROL_SCROLLBAR: return CREATE_OUSTRING( "com.sun.star.form.component.ScrollBar" ); + case API_CONTROL_GROUPBOX: return CREATE_OUSTRING( "com.sun.star.form.component.GroupBox" ); + default: OSL_ENSURE( false, "ControlModelBase::getServiceName - no form component service supported" ); + } + return OUString(); +} + +void ControlModelBase::importProperty( sal_Int32 /*nPropId*/, const OUString& /*rValue*/ ) +{ +} + +void ControlModelBase::importPictureData( sal_Int32 /*nPropId*/, BinaryInputStream& /*rInStrm*/ ) +{ +} + +void ControlModelBase::convertProperties( PropertyMap& /*rPropMap*/, const ControlConverter& /*rConv*/ ) const +{ +} + +void ControlModelBase::convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rConv.convertSize( rPropMap, maSize ); +} + +// ============================================================================ + +ComCtlModelBase::ComCtlModelBase( sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6, + sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) : + maFontData( CREATE_OUSTRING( "Tahoma" ), 82500 ), + mnFlags( 0 ), + mnVersion( nVersion ), + mnDataPartId5( nDataPartId5 ), + mnDataPartId6( nDataPartId6 ), + mbCommonPart( bCommonPart ), + mbComplexPart( bComplexPart ) +{ +} + +bool ComCtlModelBase::importBinaryModel( BinaryInputStream& rInStrm ) +{ + // read initial size part and header of the control data part + if( importSizePart( rInStrm ) && readPartHeader( rInStrm, getDataPartId(), mnVersion ) ) + { + // if flags part exists, the first int32 of the data part contains its size + sal_uInt32 nCommonPartSize = mbCommonPart ? rInStrm.readuInt32() : 0; + // implementations must read the exact amount of data, stream must point to its end afterwards + importControlData( rInStrm ); + // read following parts + if( !rInStrm.isEof() && + (!mbCommonPart || importCommonPart( rInStrm, nCommonPartSize )) && + (!mbComplexPart || importComplexPart( rInStrm )) ) + { + return !rInStrm.isEof(); + } + } + return false; +} + +void ComCtlModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + if( mbCommonPart ) + rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, COMCTL_COMMON_ENABLED ) ); + ControlModelBase::convertProperties( rPropMap, rConv ); +} + +void ComCtlModelBase::importCommonExtraData( BinaryInputStream& /*rInStrm*/ ) +{ +} + +void ComCtlModelBase::importCommonTrailingData( BinaryInputStream& /*rInStrm*/ ) +{ +} + +sal_uInt32 ComCtlModelBase::getDataPartId() const +{ + switch( mnVersion ) + { + case 5: return mnDataPartId5; + case 6: return mnDataPartId6; + } + OSL_ENSURE( false, "ComCtlObjectBase::getDataPartId - unxpected version" ); + return SAL_MAX_UINT32; +} + +bool ComCtlModelBase::readPartHeader( BinaryInputStream& rInStrm, sal_uInt32 nExpPartId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor ) +{ + // no idea if all this is correct... + sal_uInt32 nPartId; + sal_uInt16 nMajor, nMinor; + rInStrm >> nPartId >> nMinor >> nMajor; + bool bPartId = nPartId == nExpPartId; + OSL_ENSURE( bPartId, "ComCtlObjectBase::readPartHeader - unexpected part identifier" ); + bool bVersion = ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor)); + OSL_ENSURE( bVersion, "ComCtlObjectBase::readPartHeader - unexpected part version" ); + return !rInStrm.isEof() && bPartId && bVersion; +} + +bool ComCtlModelBase::importSizePart( BinaryInputStream& rInStrm ) +{ + if( readPartHeader( rInStrm, COMCTL_ID_SIZE, 0, 8 ) ) + { + rInStrm >> maSize.first >> maSize.second; + return !rInStrm.isEof(); + } + return false; +} + +bool ComCtlModelBase::importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize ) +{ + sal_Int64 nEndPos = rInStrm.tell() + nPartSize; + if( (nPartSize >= 16) && readPartHeader( rInStrm, COMCTL_ID_COMMONDATA, 5, 0 ) ) + { + rInStrm.skip( 4 ); + rInStrm >> mnFlags; + // implementations may read less than the exact amount of data + importCommonExtraData( rInStrm ); + rInStrm.seek( nEndPos ); + // implementations must read the exact amount of data, stream must point to its end afterwards + importCommonTrailingData( rInStrm ); + return !rInStrm.isEof(); + } + return false; +} + +bool ComCtlModelBase::importComplexPart( BinaryInputStream& rInStrm ) +{ + if( readPartHeader( rInStrm, COMCTL_ID_COMPLEXDATA, 5, 1 ) ) + { + sal_uInt32 nContFlags; + rInStrm >> nContFlags; + bool bReadOk = + (!getFlag( nContFlags, COMCTL_COMPLEX_FONT ) || OleHelper::importStdFont( maFontData, rInStrm, true )) && + (!getFlag( nContFlags, COMCTL_COMPLEX_MOUSEICON ) || OleHelper::importStdPic( maMouseIcon, rInStrm, true )); + return bReadOk && !rInStrm.isEof(); + } + return false; +} + +// ============================================================================ + +ComCtlScrollBarModel::ComCtlScrollBarModel( sal_uInt16 nVersion ) : + ComCtlModelBase( SAL_MAX_UINT32, COMCTL_ID_SCROLLBAR_60, nVersion, true, true ), + mnScrollBarFlags( 0x00000011 ), + mnLargeChange( 1 ), + mnSmallChange( 1 ), + mnMin( 0 ), + mnMax( 32767 ), + mnPosition( 0 ) +{ +} + +ApiControlType ComCtlScrollBarModel::getControlType() const +{ + return API_CONTROL_SCROLLBAR; +} + +void ComCtlScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rPropMap.setProperty( PROP_Border, API_BORDER_NONE ); + rConv.convertOrientation( rPropMap, getFlag( mnScrollBarFlags, COMCTL_SCROLLBAR_HOR ) ); + rConv.convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel ); + ComCtlModelBase::convertProperties( rPropMap, rConv ); +} + +void ComCtlScrollBarModel::importControlData( BinaryInputStream& rInStrm ) +{ + rInStrm >> mnScrollBarFlags >> mnLargeChange >> mnSmallChange >> mnMin >> mnMax >> mnPosition; +} // ============================================================================ -AxControlModelBase::AxControlModelBase() : - mnWidth( 0 ), - mnHeight( 0 ) +ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion ) : + ComCtlModelBase( COMCTL_ID_PROGRESSBAR_50, COMCTL_ID_PROGRESSBAR_60, nVersion, true, true ), + mfMin( 0.0 ), + mfMax( 100.0 ), + mnVertical( 0 ), + mnSmooth( 0 ) { } -AxControlModelBase::~AxControlModelBase() +ApiControlType ComCtlProgressBarModel::getControlType() const +{ + return API_CONTROL_PROGRESSBAR; +} + +void ComCtlProgressBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + sal_uInt16 nBorder = getFlag( mnFlags, COMCTL_COMMON_3DBORDER ) ? API_BORDER_SUNKEN : + (getFlag( mnFlags, COMCTL_COMMON_FLATBORDER ) ? API_BORDER_FLAT : API_BORDER_NONE); + rPropMap.setProperty( PROP_Border, nBorder ); + rPropMap.setProperty( PROP_ProgressValueMin, getLimitedValue< sal_Int32, double >( ::std::min( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) ); + rPropMap.setProperty( PROP_ProgressValueMax, getLimitedValue< sal_Int32, double >( ::std::max( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) ); + // ComCtl model does not provide current value? + ComCtlModelBase::convertProperties( rPropMap, rConv ); +} + +void ComCtlProgressBarModel::importControlData( BinaryInputStream& rInStrm ) +{ + rInStrm >> mfMin >> mfMax; + if( mnVersion == 6 ) + rInStrm >> mnVertical >> mnSmooth; +} + +// ============================================================================ + +AxControlModelBase::AxControlModelBase() { } @@ -377,33 +668,18 @@ void AxControlModelBase::importProperty( sal_Int32 nPropId, const OUString& rVal OSL_ENSURE( nSepPos >= 0, "AxControlModelBase::importProperty - missing separator in 'Size' property" ); if( nSepPos >= 0 ) { - mnWidth = rValue.copy( 0, nSepPos ).toInt32(); - mnHeight = rValue.copy( nSepPos + 1 ).toInt32(); + maSize.first = rValue.copy( 0, nSepPos ).toInt32(); + maSize.second = rValue.copy( nSepPos + 1 ).toInt32(); } } break; } } -void AxControlModelBase::importBinaryModel( BinaryInputStream& /*rInStrm*/ ) -{ -} - -void AxControlModelBase::importPictureData( sal_Int32 /*nPropId*/, BinaryInputStream& /*rInStrm*/ ) -{ -} - -void AxControlModelBase::convertProperties( AxControlHelper& /*rHelper*/, PropertyMap& /*rPropMap*/ ) const -{ -} - // ============================================================================ -AxFontDataModel::AxFontDataModel() : - mnFontEffects( 0 ), - mnFontHeight( 160 ), - mnFontCharSet( 1 ), - mnHorAlign( AX_FONTALIGN_LEFT ) +AxFontDataModel::AxFontDataModel( bool bSupportsAlign ) : + mbSupportsAlign( bSupportsAlign ) { } @@ -411,70 +687,59 @@ void AxFontDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue { switch( nPropId ) { - case XML_FontName: maFontName = rValue; break; - case XML_FontEffects: mnFontEffects = AttributeList::decodeUnsigned( rValue ); break; - case XML_FontHeight: mnFontHeight = AttributeList::decodeInteger( rValue ); break; - case XML_FontCharSet: mnFontCharSet = AttributeList::decodeInteger( rValue ); break; - case XML_ParagraphAlign: mnHorAlign = AttributeList::decodeInteger( rValue ); break; + case XML_FontName: maFontData.maFontName = rValue; break; + case XML_FontEffects: maFontData.mnFontEffects = AttributeList::decodeUnsigned( rValue ); break; + case XML_FontHeight: maFontData.mnFontHeight = AttributeList::decodeInteger( rValue ); break; + case XML_FontCharSet: maFontData.mnFontCharSet = AttributeList::decodeInteger( rValue ); break; + case XML_ParagraphAlign: maFontData.mnHorAlign = AttributeList::decodeInteger( rValue ); break; default: AxControlModelBase::importProperty( nPropId, rValue ); } } -void AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm ) { - AxBinaryPropertyReader aReader( rInStrm ); - aReader.readStringProperty( maFontName ); - aReader.readIntProperty< sal_uInt32 >( mnFontEffects ); - aReader.readIntProperty< sal_Int32 >( mnFontHeight ); - aReader.skipIntProperty< sal_Int32 >(); // font offset - aReader.readIntProperty< sal_uInt8 >( mnFontCharSet ); - aReader.skipIntProperty< sal_uInt8 >(); // font pitch/family - aReader.readIntProperty< sal_uInt8 >( mnHorAlign ); - aReader.skipIntProperty< sal_uInt16 >(); // font weight - aReader.finalizeImport(); + return maFontData.importBinaryModel( rInStrm ); } -void AxFontDataModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { namespace cssa = ::com::sun::star::awt; // font name - if( maFontName.getLength() > 0 ) - rPropMap.setProperty( PROP_FontName, maFontName ); + if( maFontData.maFontName.getLength() > 0 ) + rPropMap.setProperty( PROP_FontName, maFontData.maFontName ); // font effects - rPropMap.setProperty( PROP_FontWeight, getFlagValue( mnFontEffects, AX_FONT_BOLD, cssa::FontWeight::BOLD, cssa::FontWeight::NORMAL ) ); - rPropMap.setProperty( PROP_FontSlant, getFlagValue< sal_Int16 >( mnFontEffects, AX_FONT_ITALIC, cssa::FontSlant_ITALIC, cssa::FontSlant_NONE ) ); - rPropMap.setProperty( PROP_FontUnderline, getFlagValue( mnFontEffects, AX_FONT_UNDERLINE, cssa::FontUnderline::SINGLE, cssa::FontUnderline::NONE ) ); - rPropMap.setProperty( PROP_FontStrikeout, getFlagValue( mnFontEffects, AX_FONT_STRIKEOUT, cssa::FontStrikeout::SINGLE, cssa::FontStrikeout::NONE ) ); - - /* font height in points. MSO uses weird font sizes: - 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135, - 8pt->165, 9pt->180, 10pt->195, 11pt->225, ... */ - sal_Int16 nHeight = getLimitedValue< sal_Int16, sal_Int32 >( (mnFontHeight + 10) / 20, 1, SAL_MAX_INT16 ); - rPropMap.setProperty( PROP_FontHeight, nHeight ); + rPropMap.setProperty( PROP_FontWeight, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_BOLD, cssa::FontWeight::BOLD, cssa::FontWeight::NORMAL ) ); + rPropMap.setProperty( PROP_FontSlant, getFlagValue< sal_Int16 >( maFontData.mnFontEffects, AX_FONTDATA_ITALIC, cssa::FontSlant_ITALIC, cssa::FontSlant_NONE ) ); + rPropMap.setProperty( PROP_FontUnderline, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, cssa::FontUnderline::SINGLE, cssa::FontUnderline::NONE ) ); + rPropMap.setProperty( PROP_FontStrikeout, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, cssa::FontStrikeout::SINGLE, cssa::FontStrikeout::NONE ) ); + rPropMap.setProperty( PROP_FontHeight, maFontData.getHeightPoints() ); // font character set rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW; - if( (0 <= mnFontCharSet) && (mnFontCharSet <= SAL_MAX_UINT8) ) - eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( mnFontCharSet ) ); + if( (0 <= maFontData.mnFontCharSet) && (maFontData.mnFontCharSet <= SAL_MAX_UINT8) ) + eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maFontData.mnFontCharSet ) ); if( eFontEnc != RTL_TEXTENCODING_DONTKNOW ) rPropMap.setProperty( PROP_FontCharset, static_cast< sal_Int16 >( eFontEnc ) ); // text alignment - sal_Int32 nAlign = cssa::TextAlign::LEFT; - switch( mnHorAlign ) + if( mbSupportsAlign ) { - case AX_FONTALIGN_LEFT: nAlign = cssa::TextAlign::LEFT; break; - case AX_FONTALIGN_RIGHT: nAlign = cssa::TextAlign::RIGHT; break; - case AX_FONTALIGN_CENTER: nAlign = cssa::TextAlign::CENTER; break; - default: OSL_ENSURE( false, "AxFontDataModel::convertProperties - unknown text alignment" ); + sal_Int32 nAlign = cssa::TextAlign::LEFT; + switch( maFontData.mnHorAlign ) + { + case AX_FONTDATA_LEFT: nAlign = cssa::TextAlign::LEFT; break; + case AX_FONTDATA_RIGHT: nAlign = cssa::TextAlign::RIGHT; break; + case AX_FONTDATA_CENTER: nAlign = cssa::TextAlign::CENTER; break; + default: OSL_ENSURE( false, "AxFontDataModel::convertProperties - unknown text alignment" ); + } + // form controls expect short value + rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) ); } - // form controls expect short value - rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) ); // process base class properties - AxControlModelBase::convertProperties( rHelper, rPropMap ); + AxControlModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -511,7 +776,7 @@ void AxCommandButtonModel::importPictureData( sal_Int32 nPropId, BinaryInputStre } } -void AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm ); aReader.readIntProperty< sal_uInt32 >( mnTextColor ); @@ -519,32 +784,31 @@ void AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.readIntProperty< sal_uInt32 >( mnFlags ); aReader.readStringProperty( maCaption ); aReader.readIntProperty< sal_uInt32 >( mnPicturePos ); - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer aReader.readPictureProperty( maPictureData ); aReader.skipIntProperty< sal_uInt16 >(); // accelerator aReader.readBoolProperty( mbFocusOnClick, true ); // binary flag means "do not take focus" aReader.skipPictureProperty(); // mouse icon - if( aReader.finalizeImport() ) - AxFontDataModel::importBinaryModel( rInStrm ); + return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm ); } -OUString AxCommandButtonModel::getServiceName() const +ApiControlType AxCommandButtonModel::getControlType() const { - return CREATE_OUSTRING( "com.sun.star.form.component.CommandButton" ); + return API_CONTROL_BUTTON; } -void AxCommandButtonModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxCommandButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); - rPropMap.setProperty( PROP_TextColor, rHelper.convertColor( mnTextColor ) ); rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) ); rPropMap.setProperty( PROP_FocusOnClick, mbFocusOnClick ); rPropMap.setProperty( PROP_VerticalAlign, ::com::sun::star::style::VerticalAlignment_MIDDLE ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); - lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); - AxFontDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); + rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos ); + AxFontDataModel::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -574,7 +838,7 @@ void AxLabelModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) } } -void AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm ); aReader.readIntProperty< sal_uInt32 >( mnTextColor ); @@ -582,7 +846,7 @@ void AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.readIntProperty< sal_uInt32 >( mnFlags ); aReader.readStringProperty( maCaption ); aReader.skipIntProperty< sal_uInt32 >(); // picture position - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer aReader.readIntProperty< sal_uInt32 >( mnBorderColor ); aReader.readIntProperty< sal_uInt16 >( mnBorderStyle ); @@ -590,25 +854,24 @@ void AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.skipPictureProperty(); // picture aReader.skipIntProperty< sal_uInt16 >(); // accelerator aReader.skipPictureProperty(); // mouse icon - if( aReader.finalizeImport() ) - AxFontDataModel::importBinaryModel( rInStrm ); + return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm ); } -OUString AxLabelModel::getServiceName() const +ApiControlType AxLabelModel::getControlType() const { - return CREATE_OUSTRING( "com.sun.star.form.component.FixedText" ); + return API_CONTROL_FIXEDTEXT; } -void AxLabelModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxLabelModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); - rPropMap.setProperty( PROP_TextColor, rHelper.convertColor( mnTextColor ) ); rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) ); rPropMap.setProperty( PROP_VerticalAlign, ::com::sun::star::style::VerticalAlignment_TOP ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertBorder( rHelper, rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); - AxFontDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxFontDataModel::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -650,7 +913,7 @@ void AxImageModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInS } } -void AxImageModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxImageModel::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm ); aReader.skipUndefinedProperty(); @@ -662,32 +925,32 @@ void AxImageModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode ); aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect ); - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.readPictureProperty( maPictureData ); aReader.readIntProperty< sal_uInt8 >( mnPicAlign ); aReader.readBoolProperty( mbPicTiling ); aReader.readIntProperty< sal_uInt32 >( mnFlags ); aReader.skipPictureProperty(); // mouse icon - aReader.finalizeImport(); + return aReader.finalizeImport(); } -OUString AxImageModel::getServiceName() const +ApiControlType AxImageModel::getControlType() const { - return CREATE_OUSTRING( "com.sun.star.form.component.DatabaseImageControl" ); + return API_CONTROL_IMAGE; } -void AxImageModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxImageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertBorder( rHelper, rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); - lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicSizeMode, mnPicAlign, mbPicTiling ); - AxControlModelBase::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + rConv.convertAxPicture( rPropMap, maPictureData, mnPicSizeMode, mnPicAlign, mbPicTiling ); + AxControlModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ -AxMorphDataModel::AxMorphDataModel() : +AxMorphDataModelBase::AxMorphDataModelBase() : mnTextColor( AX_SYSCOLOR_WINDOWTEXT ), mnBackColor( AX_SYSCOLOR_WINDOWBACK ), mnFlags( AX_MORPHDATA_DEFFLAGS ), @@ -706,7 +969,7 @@ AxMorphDataModel::AxMorphDataModel() : { } -void AxMorphDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) +void AxMorphDataModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue ) { switch( nPropId ) { @@ -732,7 +995,7 @@ void AxMorphDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue } } -void AxMorphDataModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) +void AxMorphDataModelBase::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) { switch( nPropId ) { @@ -741,7 +1004,7 @@ void AxMorphDataModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& } } -void AxMorphDataModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm, true ); aReader.readIntProperty< sal_uInt32 >( mnFlags ); @@ -752,7 +1015,7 @@ void AxMorphDataModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.readIntProperty< sal_uInt8 >( mnScrollBars ); aReader.readIntProperty< sal_uInt8 >( mnDisplayStyle ); aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.readIntProperty< sal_uInt16 >( mnPasswordChar ); aReader.skipIntProperty< sal_uInt32 >(); // list width aReader.skipIntProperty< sal_uInt16 >(); // bound column @@ -777,15 +1040,14 @@ void AxMorphDataModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.skipUndefinedProperty(); aReader.skipBoolProperty(); aReader.readStringProperty( maGroupName ); - if( aReader.finalizeImport() ) - AxFontDataModel::importBinaryModel( rInStrm ); + return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm ); } -void AxMorphDataModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { - rPropMap.setProperty( PROP_TextColor, rHelper.convertColor( mnTextColor ) ); rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); - AxFontDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor ); + AxFontDataModel::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -794,21 +1056,21 @@ AxToggleButtonModel::AxToggleButtonModel() { } -OUString AxToggleButtonModel::getServiceName() const +ApiControlType AxToggleButtonModel::getControlType() const { - OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE, "AxToggleButtonModel::getServiceName - invalid control type" ); - return CREATE_OUSTRING( "com.sun.star.form.component.CommandButton" ); + OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE, "AxToggleButtonModel::getControlType - invalid control type" ); + return API_CONTROL_BUTTON; } -void AxToggleButtonModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxToggleButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) ); rPropMap.setProperty( PROP_VerticalAlign, ::com::sun::star::style::VerticalAlignment_MIDDLE ); rPropMap.setProperty( PROP_Toggle, true ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); - lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); + rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -817,22 +1079,22 @@ AxCheckBoxModel::AxCheckBoxModel() { } -OUString AxCheckBoxModel::getServiceName() const +ApiControlType AxCheckBoxModel::getControlType() const { - OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX, "AxCheckBoxModel::getServiceName - invalid control type" ); - return CREATE_OUSTRING( "com.sun.star.form.component.CheckBox" ); + OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX, "AxCheckBoxModel::getControlType - invalid control type" ); + return API_CONTROL_CHECKBOX; } -void AxCheckBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxCheckBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) ); rPropMap.setProperty( PROP_VerticalAlign, ::com::sun::star::style::VerticalAlignment_MIDDLE ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertVisualEffect( rHelper, rPropMap, mnSpecialEffect ); - lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); - lclConvertState( rHelper, rPropMap, maValue, mnMultiSelect, true ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxVisualEffect( rPropMap, mnSpecialEffect ); + rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos ); + rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE, mbAwtModel ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -841,22 +1103,22 @@ AxOptionButtonModel::AxOptionButtonModel() { } -OUString AxOptionButtonModel::getServiceName() const +ApiControlType AxOptionButtonModel::getControlType() const { - OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON, "AxOptionButtonModel::getServiceName - invalid control type" ); - return CREATE_OUSTRING( "com.sun.star.form.component.RadioButton" ); + OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON, "AxOptionButtonModel::getControlType - invalid control type" ); + return API_CONTROL_RADIOBUTTON; } -void AxOptionButtonModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxOptionButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Label, maCaption ); rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) ); rPropMap.setProperty( PROP_VerticalAlign, ::com::sun::star::style::VerticalAlignment_MIDDLE ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertVisualEffect( rHelper, rPropMap, mnSpecialEffect ); - lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); - lclConvertState( rHelper, rPropMap, maValue, mnMultiSelect, false ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxVisualEffect( rPropMap, mnSpecialEffect ); + rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos ); + rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_SHORT, mbAwtModel ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -865,25 +1127,25 @@ AxTextBoxModel::AxTextBoxModel() { } -OUString AxTextBoxModel::getServiceName() const +ApiControlType AxTextBoxModel::getControlType() const { - OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxTextBoxModel::getServiceName - invalid control type" ); - return CREATE_OUSTRING( "com.sun.star.form.component.TextField" ); + OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxTextBoxModel::getControlType - invalid control type" ); + return API_CONTROL_EDIT; } -void AxTextBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxTextBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_MULTILINE ) ); rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) ); - rPropMap.setProperty( PROP_DefaultText, maValue ); + rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue ); rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) ); if( (0 < mnPasswordChar) && (mnPasswordChar <= SAL_MAX_INT16) ) rPropMap.setProperty( PROP_EchoChar, static_cast< sal_Int16 >( mnPasswordChar ) ); rPropMap.setProperty( PROP_HScroll, getFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL ) ); rPropMap.setProperty( PROP_VScroll, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertBorder( rHelper, rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -892,20 +1154,20 @@ AxListBoxModel::AxListBoxModel() { } -OUString AxListBoxModel::getServiceName() const +ApiControlType AxListBoxModel::getControlType() const { - OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX, "AxListBoxModel::getServiceName - invalid control type" ); - return CREATE_OUSTRING( "com.sun.star.form.component.ListBox" ); + OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX, "AxListBoxModel::getControlType - invalid control type" ); + return API_CONTROL_LISTBOX; } -void AxListBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxListBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { bool bMultiSelect = (mnMultiSelect == AX_SELCTION_MULTI) || (mnMultiSelect == AX_SELCTION_EXTENDED); rPropMap.setProperty( PROP_MultiSelection, bMultiSelect ); rPropMap.setProperty( PROP_Dropdown, false ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertBorder( rHelper, rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -914,18 +1176,18 @@ AxComboBoxModel::AxComboBoxModel() { } -OUString AxComboBoxModel::getServiceName() const +ApiControlType AxComboBoxModel::getControlType() const { - OSL_ENSURE( (mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX) || (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN), "AxComboBoxModel::getServiceName - invalid control type" ); - return (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN) ? CREATE_OUSTRING( "com.sun.star.form.component.ListBox" ) : CREATE_OUSTRING( "com.sun.star.form.component.ComboBox" ); + OSL_ENSURE( (mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX) || (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN), "AxComboBoxModel::getControlType - invalid control type" ); + return (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN) ? API_CONTROL_LISTBOX : API_CONTROL_COMBOBOX; } -void AxComboBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxComboBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { if( mnDisplayStyle != AX_DISPLAYSTYLE_DROPDOWN ) { rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) ); - rPropMap.setProperty( PROP_DefaultText, maValue ); + rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue ); rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) ); bool bAutoComplete = (mnMatchEntry == AX_MATCHENTRY_FIRSTLETTER) || (mnMatchEntry == AX_MATCHENTRY_COMPLETE); rPropMap.setProperty( PROP_Autocomplete, bAutoComplete ); @@ -933,9 +1195,9 @@ void AxComboBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& bool bShowDropdown = (mnShowDropButton == AX_SHOWDROPBUTTON_FOCUS) || (mnShowDropButton == AX_SHOWDROPBUTTON_ALWAYS); rPropMap.setProperty( PROP_Dropdown, bShowDropdown ); rPropMap.setProperty( PROP_LineCount, getLimitedValue< sal_Int16, sal_Int32 >( mnListRows, 1, SAL_MAX_INT16 ) ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); - lclConvertBorder( rHelper, rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); - AxMorphDataModel::convertProperties( rHelper, rPropMap ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); + rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect ); + AxMorphDataModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -953,9 +1215,9 @@ AxSpinButtonModel::AxSpinButtonModel() : { } -OUString AxSpinButtonModel::getServiceName() const +ApiControlType AxSpinButtonModel::getControlType() const { - return CREATE_OUSTRING( "com.sun.star.form.component.SpinButton" ); + return API_CONTROL_SPINBUTTON; } void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) @@ -975,13 +1237,13 @@ void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValu } } -void AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm ); aReader.readIntProperty< sal_uInt32 >( mnArrowColor ); aReader.readIntProperty< sal_uInt32 >( mnBackColor ); aReader.readIntProperty< sal_uInt32 >( mnFlags ); - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.skipIntProperty< sal_uInt32 >(); // unused aReader.readIntProperty< sal_Int32 >( mnMin ); aReader.readIntProperty< sal_Int32 >( mnMax ); @@ -993,25 +1255,25 @@ void AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.readIntProperty< sal_Int32 >( mnDelay ); aReader.skipPictureProperty(); // mouse icon aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer - aReader.finalizeImport(); + return aReader.finalizeImport(); } -void AxSpinButtonModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxSpinButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { sal_Int32 nMin = ::std::min( mnMin, mnMax ); sal_Int32 nMax = ::std::max( mnMin, mnMax ); - rPropMap.setProperty( PROP_SymbolColor, rHelper.convertColor( mnArrowColor ) ); rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); rPropMap.setProperty( PROP_SpinValueMin, nMin ); rPropMap.setProperty( PROP_SpinValueMax, nMax ); rPropMap.setProperty( PROP_SpinIncrement, mnSmallChange ); - rPropMap.setProperty( PROP_DefaultSpinValue, mnPosition ); + rPropMap.setProperty( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue, mnPosition ); rPropMap.setProperty( PROP_Repeat, true ); rPropMap.setProperty( PROP_RepeatDelay, mnDelay ); rPropMap.setProperty( PROP_Border, API_BORDER_NONE ); - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); - lclConvertOrientation( rHelper, rPropMap, mnOrientation, mnWidth, mnHeight ); - AxControlModelBase::convertProperties( rHelper, rPropMap ); + rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); + rConv.convertAxOrientation( rPropMap, maSize, mnOrientation ); + AxControlModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ @@ -1031,9 +1293,9 @@ AxScrollBarModel::AxScrollBarModel() : { } -OUString AxScrollBarModel::getServiceName() const +ApiControlType AxScrollBarModel::getControlType() const { - return CREATE_OUSTRING( "com.sun.star.form.component.ScrollBar" ); + return API_CONTROL_SCROLLBAR; } void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) @@ -1055,13 +1317,13 @@ void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue } } -void AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm ) +bool AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm ) { AxBinaryPropertyReader aReader( rInStrm ); aReader.readIntProperty< sal_uInt32 >( mnArrowColor ); aReader.readIntProperty< sal_uInt32 >( mnBackColor ); aReader.readIntProperty< sal_uInt32 >( mnFlags ); - aReader.readPairProperty( mnWidth, mnHeight ); + aReader.readPairProperty( maSize ); aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer aReader.readIntProperty< sal_Int32 >( mnMin ); aReader.readIntProperty< sal_Int32 >( mnMax ); @@ -1075,114 +1337,292 @@ void AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm ) aReader.readIntProperty< sal_Int16 >( mnPropThumb ); aReader.readIntProperty< sal_Int32 >( mnDelay ); aReader.skipPictureProperty(); // mouse icon - aReader.finalizeImport(); + return aReader.finalizeImport(); } -void AxScrollBarModel::convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const +void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { - sal_Int32 nMin = ::std::min( mnMin, mnMax ); - sal_Int32 nMax = ::std::max( mnMin, mnMax ); - rPropMap.setProperty( PROP_SymbolColor, rHelper.convertColor( mnArrowColor ) ); rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) ); - rPropMap.setProperty( PROP_ScrollValueMin, nMin ); - rPropMap.setProperty( PROP_ScrollValueMax, nMax ); - rPropMap.setProperty( PROP_LineIncrement, mnSmallChange ); - rPropMap.setProperty( PROP_BlockIncrement, mnLargeChange ); - rPropMap.setProperty( PROP_DefaultScrollValue, mnPosition ); rPropMap.setProperty( PROP_RepeatDelay, mnDelay ); rPropMap.setProperty( PROP_Border, API_BORDER_NONE ); - if( (mnPropThumb == AX_PROPTHUMB_ON) && (nMin < nMax) && (mnLargeChange > 0) ) + if( (mnPropThumb == AX_PROPTHUMB_ON) && (mnMin != mnMax) && (mnLargeChange > 0) ) { - double fInterval = nMax - nMin; // prevent integer overflow (fInterval+mnLargeChange may become 0 when int is used) + // use double to prevent integer overflow in division (fInterval+mnLargeChange may become 0 when performed as int) + double fInterval = fabs( static_cast< double >( mnMax - mnMin ) ); sal_Int32 nThumbLen = getLimitedValue< sal_Int32, double >( (fInterval * mnLargeChange) / (fInterval + mnLargeChange), 1, SAL_MAX_INT32 ); rPropMap.setProperty( PROP_VisibleSize, nThumbLen ); } - lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); - lclConvertOrientation( rHelper, rPropMap, mnOrientation, mnWidth, mnHeight ); - AxControlModelBase::convertProperties( rHelper, rPropMap ); + rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor ); + rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); + rConv.convertAxOrientation( rPropMap, maSize, mnOrientation ); + rConv.convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel ); + AxControlModelBase::convertProperties( rPropMap, rConv ); +} + +// ============================================================================ + +AxContainerModelBase::AxContainerModelBase() : + AxFontDataModel( false ), // no support for Align property + maLogicalSize( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ), + maScrollPos( 0, 0 ), + mnBackColor( AX_SYSCOLOR_BUTTONFACE ), + mnTextColor( AX_SYSCOLOR_BUTTONTEXT ), + mnFlags( AX_CONTAINER_DEFFLAGS ), + mnBorderColor( AX_SYSCOLOR_BUTTONTEXT ), + mnBorderStyle( AX_BORDERSTYLE_NONE ), + mnScrollBars( AX_CONTAINER_SCR_NONE ), + mnCycleType( AX_CONTAINER_CYCLEALL ), + mnSpecialEffect( AX_SPECIALEFFECT_FLAT ), + mnPicAlign( AX_PICALIGN_CENTER ), + mnPicSizeMode( AX_PICSIZE_CLIP ), + mbPicTiling( false ) +{ + setAwtModelMode(); + // different default size for frame + maSize = AxPairData( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ); +} + +void AxContainerModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue ) +{ + if( nPropId == XML_Caption ) + maCaption = rValue; +} + +bool AxContainerModelBase::importBinaryModel( BinaryInputStream& rInStrm ) +{ + AxBinaryPropertyReader aReader( rInStrm ); + aReader.skipUndefinedProperty(); + aReader.readIntProperty< sal_uInt32 >( mnBackColor ); + aReader.readIntProperty< sal_uInt32 >( mnTextColor ); + aReader.skipIntProperty< sal_uInt32 >(); // next availbale control ID + aReader.skipUndefinedProperty(); + aReader.skipUndefinedProperty(); + aReader.readIntProperty< sal_uInt32 >( mnFlags ); + aReader.readIntProperty< sal_uInt8 >( mnBorderStyle ); + aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer + aReader.readIntProperty< sal_uInt8 >( mnScrollBars ); + aReader.readPairProperty( maSize ); + aReader.readPairProperty( maLogicalSize ); + aReader.readPairProperty( maScrollPos ); + aReader.skipIntProperty< sal_uInt32 >(); // number of control groups + aReader.skipUndefinedProperty(); + aReader.skipPictureProperty(); // mouse icon + aReader.readIntProperty< sal_uInt8 >( mnCycleType ); + aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect ); + aReader.readIntProperty< sal_uInt32 >( mnBorderColor ); + aReader.readStringProperty( maCaption ); + aReader.readFontProperty( maFontData ); + aReader.readPictureProperty( maPictureData ); + aReader.skipIntProperty< sal_Int32 >(); // zoom + aReader.readIntProperty< sal_uInt8 >( mnPicAlign ); + aReader.readBoolProperty( mbPicTiling ); + aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode ); + aReader.skipIntProperty< sal_uInt32 >(); // shape cookie + aReader.skipIntProperty< sal_uInt32 >(); // draw buffer size + return aReader.finalizeImport(); +} + +bool AxContainerModelBase::importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable ) +{ + bool bValid = true; + orClassTable.clear(); + if( !getFlag( mnFlags, AX_CONTAINER_NOCLASSTABLE ) ) + { + sal_uInt16 nCount = rInStrm.readuInt16(); + for( sal_uInt16 nIndex = 0; bValid && (nIndex < nCount); ++nIndex ) + { + orClassTable.push_back( OUString() ); + AxBinaryPropertyReader aReader( rInStrm ); + aReader.readGuidProperty( orClassTable.back() ); + aReader.skipGuidProperty(); // source interface GUID + aReader.skipUndefinedProperty(); + aReader.skipGuidProperty(); // default interface GUID + aReader.skipIntProperty< sal_uInt32 >(); // class table and var flags + aReader.skipIntProperty< sal_uInt32 >(); // method count + aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for linked cell access + aReader.skipIntProperty< sal_uInt16 >(); // get function index for linked cell access + aReader.skipIntProperty< sal_uInt16 >(); // put function index for linked cell access + aReader.skipIntProperty< sal_uInt16 >(); // linked cell access property type + aReader.skipIntProperty< sal_uInt16 >(); // get function index of value + aReader.skipIntProperty< sal_uInt16 >(); // put function index of value + aReader.skipIntProperty< sal_uInt16 >(); // value type + aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for source range access + aReader.skipIntProperty< sal_uInt16 >(); // get function index for source range access + bValid = aReader.finalizeImport(); + } + } + return bValid; +} + +// ============================================================================ + +AxFrameModel::AxFrameModel() +{ +} + +ApiControlType AxFrameModel::getControlType() const +{ + return API_CONTROL_GROUPBOX; +} + +void AxFrameModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rPropMap.setProperty( PROP_Label, maCaption ); + rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) ); + AxContainerModelBase::convertProperties( rPropMap, rConv ); +} + +// ============================================================================ + +AxUserFormModel::AxUserFormModel() +{ +} + +ApiControlType AxUserFormModel::getControlType() const +{ + return API_CONTROL_DIALOG; +} + +void AxUserFormModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rPropMap.setProperty( PROP_Title, maCaption ); + rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor ); + AxContainerModelBase::convertProperties( rPropMap, rConv ); } // ============================================================================ -AxControl::AxControl( const OUString& rName ) : +EmbeddedControl::EmbeddedControl( const OUString& rName ) : maName( rName ) { } -AxControl::~AxControl() +EmbeddedControl::~EmbeddedControl() { } -AxControlModelBase* AxControl::createModel( const OUString& rClassId ) +ControlModelRef EmbeddedControl::createModel( const OUString& rClassId ) { - // TODO: move into a factory - maClassId = rClassId.toAsciiUpperCase(); - if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{D7053240-CE69-11CD-A777-00DD01143C57}" ) ) ) // Forms.CommandButton.1 + OUString aClassId = rClassId.toAsciiUpperCase(); + if( aClassId.equalsAscii( AX_GUID_COMMANDBUTTON ) ) mxModel.reset( new AxCommandButtonModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{978C9E23-D4B0-11CE-BF2D-00AA003F40D0}" ) ) ) // Forms.Label.1 + else if( aClassId.equalsAscii( AX_GUID_LABEL ) ) mxModel.reset( new AxLabelModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{4C599241-6926-101B-9992-00000B65C6F9}" ) ) ) // Forms.Image.1 + else if( aClassId.equalsAscii( AX_GUID_IMAGE ) ) mxModel.reset( new AxImageModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D60-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.ToggleButton.1 + else if( aClassId.equalsAscii( AX_GUID_TOGGLEBUTTON ) ) mxModel.reset( new AxToggleButtonModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D40-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.CheckBox.1 + else if( aClassId.equalsAscii( AX_GUID_CHECKBOX ) ) mxModel.reset( new AxCheckBoxModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D50-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.OptionButton.1 + else if( aClassId.equalsAscii( AX_GUID_OPTIONBUTTON ) ) mxModel.reset( new AxOptionButtonModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D10-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.TextBox.1 + else if( aClassId.equalsAscii( AX_GUID_TEXTBOX ) ) mxModel.reset( new AxTextBoxModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D20-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.ListBox.1 + else if( aClassId.equalsAscii( AX_GUID_LISTBOX ) ) mxModel.reset( new AxListBoxModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{8BD21D30-EC42-11CE-9E0D-00AA006002F3}" ) ) ) // Forms.ComboBox.1 + else if( aClassId.equalsAscii( AX_GUID_COMBOBOX ) ) mxModel.reset( new AxComboBoxModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{79176FB0-B7F2-11CE-97EF-00AA006D2776}" ) ) ) // Forms.SpinButton.1 + else if( aClassId.equalsAscii( AX_GUID_SPINBUTTON ) ) mxModel.reset( new AxSpinButtonModel ); - else if( maClassId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "{DFD181E0-5E2F-11CE-A449-00AA004A803D}" ) ) ) // Forms.ScrollBar.1 + else if( aClassId.equalsAscii( AX_GUID_SCROLLBAR ) ) mxModel.reset( new AxScrollBarModel ); + else if( aClassId.equalsAscii( AX_GUID_FRAME ) ) + mxModel.reset( new AxFrameModel ); + else if( aClassId.equalsAscii( COMCTL_GUID_SCROLLBAR_60 ) ) + mxModel.reset( new ComCtlScrollBarModel( 6 ) ); else mxModel.reset(); - return mxModel.get(); + // embedded controls are form component instances + if( mxModel.get() ) + mxModel->setFormComponentMode(); + + return mxModel; } -void AxControl::importBinaryModel( BinaryInputStream& rInStrm ) +OUString EmbeddedControl::getServiceName() const { - if( AxControlModelBase* pModel = createModel( OleHelper::importGuid( rInStrm ) ) ) - pModel->importBinaryModel( rInStrm ); + return mxModel.get() ? mxModel->getServiceName() : OUString(); } -Reference< XControlModel > AxControl::convertAndInsert( AxControlHelper& rHelper ) const +bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) const { - Reference< XControlModel > xCtrlModel; - if( mxModel.get() ) try + if( mxModel.get() && rxCtrlModel.is() && (maName.getLength() > 0) ) { - Reference< XIndexContainer > xFormIC( rHelper.getControlForm(), UNO_QUERY_THROW ); + PropertyMap aPropMap; + aPropMap.setProperty( PROP_Name, maName ); + mxModel->convertProperties( aPropMap, rConv ); + PropertySet aPropSet( rxCtrlModel ); + aPropSet.setProperties( aPropMap ); + return true; + } + return false; +} + +// ============================================================================ - // document model creates the form control model - xCtrlModel.set( rHelper.getFilter().getModelFactory()->createInstance( mxModel->getServiceName() ), UNO_QUERY_THROW ); - Reference< XFormComponent > xFormComp( xCtrlModel, UNO_QUERY_THROW ); +EmbeddedForm::EmbeddedForm( const Reference< XMultiServiceFactory >& rxModelFactory, + const Reference< XDrawPage >& rxDrawPage, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) : + ControlConverter( rGraphicHelper, bDefaultColorBgr ), + mxModelFactory( rxModelFactory ), + mxFormsSupp( rxDrawPage, UNO_QUERY ) +{ + OSL_ENSURE( mxModelFactory.is(), "EmbeddedForm::EmbeddedForm - missing service factory" ); +} + +Reference< XControlModel > EmbeddedForm::convertAndInsert( const EmbeddedControl& rControl ) +{ + if( mxModelFactory.is() && rControl.hasModel() ) try + { + // create the UNO control model + OUString aServiceName = rControl.getServiceName(); + Reference< XFormComponent > xFormComp( mxModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW ); + Reference< XControlModel > xCtrlModel( xFormComp, UNO_QUERY_THROW ); - // insert control model into the passed form + // insert the control into the form + Reference< XIndexContainer > xFormIC( createForm(), UNO_SET_THROW ); sal_Int32 nNewIndex = xFormIC->getCount(); xFormIC->insertByIndex( nNewIndex, Any( xFormComp ) ); - // convert all control properties - PropertyMap aPropMap; - aPropMap.setProperty( PROP_Name, maName ); - mxModel->convertProperties( rHelper, aPropMap ); - - PropertySet aPropSet( xCtrlModel ); - aPropSet.setProperties( aPropMap ); + // convert the control properties + if( rControl.convertProperties( xCtrlModel, *this ) ) + return xCtrlModel; } catch( Exception& ) { - xCtrlModel.clear(); // on error: forget the created form control model } - return xCtrlModel; + return Reference< XControlModel >(); +} + +Reference< XIndexContainer > EmbeddedForm::createForm() +{ + if( mxFormsSupp.is() ) + { + try + { + Reference< XNameContainer > xFormsNC( mxFormsSupp->getForms(), UNO_SET_THROW ); + OUString aFormName = CREATE_OUSTRING( "Standard" ); + if( xFormsNC->hasByName( aFormName ) ) + { + mxFormIC.set( xFormsNC->getByName( aFormName ), UNO_QUERY_THROW ); + } + else if( mxModelFactory.is() ) + { + Reference< XForm > xForm( mxModelFactory->createInstance( CREATE_OUSTRING( "com.sun.star.form.component.Form" ) ), UNO_QUERY_THROW ); + xFormsNC->insertByName( aFormName, Any( xForm ) ); + mxFormIC.set( xForm, UNO_QUERY_THROW ); + } + } + catch( Exception& ) + { + } + // always clear the forms supplier to not try to create the form again + mxFormsSupp.clear(); + } + return mxFormIC; } // ============================================================================ } // namespace ole } // namespace oox - diff --git a/oox/source/ole/axcontrolfragment.cxx b/oox/source/ole/axcontrolfragment.cxx index e641ec40d71b..ecd782da2cb0 100644 --- a/oox/source/ole/axcontrolfragment.cxx +++ b/oox/source/ole/axcontrolfragment.cxx @@ -30,8 +30,12 @@ #include "oox/helper/binaryoutputstream.hxx" #include "oox/core/xmlfilterbase.hxx" #include "oox/ole/axcontrol.hxx" +#include "oox/ole/olehelper.hxx" +#include "oox/ole/olestorage.hxx" using ::rtl::OUString; +using ::com::sun::star::io::XInputStream; +using ::com::sun::star::uno::Reference; using ::oox::core::ContextHandler2; using ::oox::core::ContextHandlerRef; using ::oox::core::FragmentHandler2; @@ -42,7 +46,7 @@ namespace ole { // ============================================================================ -AxControlPropertyContext::AxControlPropertyContext( FragmentHandler2& rFragment, AxControlModelBase& rModel ) : +AxControlPropertyContext::AxControlPropertyContext( FragmentHandler2& rFragment, ControlModelBase& rModel ) : ContextHandler2( rFragment ), mrModel( rModel ), mnPropId( XML_TOKEN_INVALID ) @@ -87,7 +91,7 @@ ContextHandlerRef AxControlPropertyContext::onCreateContext( sal_Int32 nElement, // ============================================================================ -AxControlFragment::AxControlFragment( XmlFilterBase& rFilter, const OUString& rFragmentPath, AxControl& rControl ) : +AxControlFragment::AxControlFragment( XmlFilterBase& rFilter, const OUString& rFragmentPath, EmbeddedControl& rControl ) : FragmentHandler2( rFilter, rFragmentPath, true ), mrControl( rControl ) { @@ -101,7 +105,7 @@ ContextHandlerRef AxControlFragment::onCreateContext( sal_Int32 nElement, const switch( rAttribs.getToken( AX_TOKEN( persistence ), XML_TOKEN_INVALID ) ) { case XML_persistPropertyBag: - if( AxControlModelBase* pModel = mrControl.createModel( aClassId ) ) + if( ControlModelBase* pModel = mrControl.createModel( aClassId ).get() ) return new AxControlPropertyContext( *this, *pModel ); break; @@ -113,10 +117,30 @@ ContextHandlerRef AxControlFragment::onCreateContext( sal_Int32 nElement, const BinaryXInputStream aInStrm( getFilter().openInputStream( aFragmentPath ), true ); if( !aInStrm.isEof() ) { - mrControl.importBinaryModel( aInStrm ); // binary stream contains a copy of the class ID, must be equal to attribute value - OSL_ENSURE( !mrControl.getModel() || aClassId.equalsIgnoreAsciiCase( mrControl.getClassId() ), + OUString aStrmClassId = OleHelper::importGuid( aInStrm ); + OSL_ENSURE( aClassId.equalsIgnoreAsciiCase( aStrmClassId ), "AxControlFragment::importBinaryControl - form control class ID mismatch" ); + if( ControlModelBase* pModel = mrControl.createModel( aStrmClassId ).get() ) + pModel->importBinaryModel( aInStrm ); + } + } + } + break; + + case XML_persistStorage: + { + OUString aFragmentPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); + if( aFragmentPath.getLength() > 0 ) + { + Reference< XInputStream > xStrgStrm = getFilter().openInputStream( aFragmentPath ); + if( xStrgStrm.is() ) + { + OleStorage aStorage( getFilter().getGlobalFactory(), xStrgStrm, false ); + BinaryXInputStream aInStrm( aStorage.openInputStream( CREATE_OUSTRING( "f" ) ), true ); + if( !aInStrm.isEof() ) + if( AxContainerModelBase* pModel = dynamic_cast< AxContainerModelBase* >( mrControl.createModel( aClassId ).get() ) ) + pModel->importBinaryModel( aInStrm ); } } } @@ -130,4 +154,3 @@ ContextHandlerRef AxControlFragment::onCreateContext( sal_Int32 nElement, const } // namespace ole } // namespace oox - diff --git a/oox/source/ole/axcontrolhelper.cxx b/oox/source/ole/axcontrolhelper.cxx deleted file mode 100644 index 1ffb4343aaf5..000000000000 --- a/oox/source/ole/axcontrolhelper.cxx +++ /dev/null @@ -1,175 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "oox/ole/axcontrolhelper.hxx" -#include -#include -#include -#include "tokens.hxx" -#include "oox/helper/containerhelper.hxx" -#include "oox/core/filterbase.hxx" -#include "oox/drawingml/color.hxx" - -using ::rtl::OUString; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::uno::UNO_SET_THROW; -using ::com::sun::star::container::XNameContainer; -using ::com::sun::star::graphic::XGraphic; -using ::com::sun::star::drawing::XDrawPage; -using ::com::sun::star::form::XForm; -using ::com::sun::star::form::XFormsSupplier; -using ::oox::core::FilterBase; - -namespace oox { -namespace ole { - -// ============================================================================ - -namespace { - -const sal_uInt32 AX_COLORTYPE_MASK = 0xFF000000; -const sal_uInt32 AX_COLORTYPE_CLIENT = 0x00000000; -const sal_uInt32 AX_COLORTYPE_PALETTE = 0x01000000; -const sal_uInt32 AX_COLORTYPE_BGR = 0x02000000; -const sal_uInt32 AX_COLORTYPE_SYSCOLOR = 0x80000000; - -const sal_uInt32 AX_PALETTECOLOR_MASK = 0x0000FFFF; -const sal_uInt32 AX_BGRCOLOR_MASK = 0x00FFFFFF; -const sal_uInt32 AX_SYSTEMCOLOR_MASK = 0x0000FFFF; - -// ---------------------------------------------------------------------------- - -/** Returns the UNO RGB color from the passed encoded OLE BGR color. */ -inline sal_Int32 lclDecodeBgrColor( sal_uInt32 nAxColor ) -{ - return static_cast< sal_Int32 >( ((nAxColor & 0x0000FF) << 16) | (nAxColor & 0x00FF00) | ((nAxColor & 0xFF0000) >> 16) ); -} - -} // namespace - -// ============================================================================ - -AxControlHelper::AxControlHelper( const FilterBase& rFilter, AxDefaultColorMode eColorMode ) : - mrFilter( rFilter ), - meColorMode( eColorMode ), - mbHasFormQuerried( false ) -{ -} - -AxControlHelper::~AxControlHelper() -{ -} - -Reference< XForm > AxControlHelper::getControlForm() const -{ - if( !mbHasFormQuerried ) - { - mbHasFormQuerried = true; - mxForm = createControlForm(); // virtual call - } - return mxForm; -} - -sal_Int32 AxControlHelper::convertColor( sal_uInt32 nAxColor ) const -{ - static const sal_Int32 spnSystemColors[] = - { - XML_scrollBar, XML_background, XML_activeCaption, XML_inactiveCaption, - XML_menu, XML_window, XML_windowFrame, XML_menuText, - XML_windowText, XML_captionText, XML_activeBorder, XML_inactiveBorder, - XML_appWorkspace, XML_highlight, XML_highlightText, XML_btnFace, - XML_btnShadow, XML_grayText, XML_btnText, XML_inactiveCaptionText, - XML_btnHighlight, XML_3dDkShadow, XML_3dLight, XML_infoText, - XML_infoBk - }; - - switch( nAxColor & AX_COLORTYPE_MASK ) - { - case AX_COLORTYPE_CLIENT: - switch( meColorMode ) - { - case AX_DEFAULTCOLORMODE_BGR: return lclDecodeBgrColor( nAxColor ); - case AX_DEFAULTCOLORMODE_PALETTE: return mrFilter.getPaletteColor( nAxColor & AX_PALETTECOLOR_MASK ); - } - break; - - case AX_COLORTYPE_PALETTE: - return mrFilter.getPaletteColor( nAxColor & AX_PALETTECOLOR_MASK ); - - case AX_COLORTYPE_BGR: - return lclDecodeBgrColor( nAxColor ); - - case AX_COLORTYPE_SYSCOLOR: - return mrFilter.getSystemColor( STATIC_ARRAY_SELECT( spnSystemColors, nAxColor & AX_SYSTEMCOLOR_MASK, XML_TOKEN_INVALID ), API_RGB_WHITE ); - } - OSL_ENSURE( false, "AxControlHelper::convertColor - unknown color type" ); - return 0; -} - -// ============================================================================ - -AxEmbeddedControlHelper::AxEmbeddedControlHelper( const FilterBase& rFilter, - const Reference< XDrawPage >& rxDrawPage, AxDefaultColorMode eColorMode ) : - AxControlHelper( rFilter, eColorMode ), - mxDrawPage( rxDrawPage ) -{ -} - -Reference< XForm > AxEmbeddedControlHelper::createControlForm() const -{ - Reference< XForm > xForm; - try - { - Reference< XFormsSupplier > xFormsSupplier( mxDrawPage, UNO_QUERY_THROW ); - Reference< XNameContainer > xFormsNC( xFormsSupplier->getForms(), UNO_SET_THROW ); - OUString aFormName = CREATE_OUSTRING( "Standard" ); - if( xFormsNC->hasByName( aFormName ) ) - { - xFormsNC->getByName( aFormName ) >>= xForm; - } - else - { - Reference< XForm > xNewForm( getFilter().getModelFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.form.component.Form" ) ), UNO_QUERY_THROW ); - xFormsNC->insertByName( aFormName, Any( xNewForm ) ); - // return the form if insertion did not fail - xForm = xNewForm; - } - } - catch( Exception& ) - { - } - return xForm; -} - -// ============================================================================ - -} // namespace ole -} // namespace oox - diff --git a/oox/source/ole/makefile.mk b/oox/source/ole/makefile.mk index 5fe0c08dbd6f..4e01392d4a57 100644 --- a/oox/source/ole/makefile.mk +++ b/oox/source/ole/makefile.mk @@ -44,10 +44,14 @@ SLOFILES = \ $(SLO)$/axbinaryreader.obj \ $(SLO)$/axcontrol.obj \ $(SLO)$/axcontrolfragment.obj \ - $(SLO)$/axcontrolhelper.obj \ $(SLO)$/olehelper.obj \ $(SLO)$/oleobjecthelper.obj \ - $(SLO)$/vbainputstream.obj + $(SLO)$/olestorage.obj \ + $(SLO)$/vbacontrol.obj \ + $(SLO)$/vbahelper.obj \ + $(SLO)$/vbainputstream.obj \ + $(SLO)$/vbamodule.obj \ + $(SLO)$/vbaproject.obj # --- Targets ------------------------------------------------------- diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index f26fb9d0cec3..68ae8c90802e 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -27,7 +27,9 @@ #include "oox/ole/olehelper.hxx" #include +#include "tokens.hxx" #include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/graphichelper.hxx" using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -39,9 +41,24 @@ namespace ole { namespace { -const sal_Char* const OLE_GUID_STDFONT = "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"; -const sal_Char* const OLE_GUID_STDPIC = "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"; -const sal_Char* const OLE_GUID_STDHLINK = "{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}"; +const sal_uInt32 OLE_COLORTYPE_MASK = 0xFF000000; +const sal_uInt32 OLE_COLORTYPE_CLIENT = 0x00000000; +const sal_uInt32 OLE_COLORTYPE_PALETTE = 0x01000000; +const sal_uInt32 OLE_COLORTYPE_BGR = 0x02000000; +const sal_uInt32 OLE_COLORTYPE_SYSCOLOR = 0x80000000; + +const sal_uInt32 OLE_PALETTECOLOR_MASK = 0x0000FFFF; +const sal_uInt32 OLE_BGRCOLOR_MASK = 0x00FFFFFF; +const sal_uInt32 OLE_SYSTEMCOLOR_MASK = 0x0000FFFF; + +/** Returns the UNO RGB color from the passed encoded OLE BGR color. */ +inline sal_Int32 lclDecodeBgrColor( sal_uInt32 nOleColor ) +{ + return static_cast< sal_Int32 >( ((nOleColor & 0x0000FF) << 16) | (nOleColor & 0x00FF00) | ((nOleColor & 0xFF0000) >> 16) ); +} + +// ---------------------------------------------------------------------------- + const sal_Char* const OLE_GUID_URLMONIKER = "{79EAC9E0-BAF9-11CE-8C82-00AA004BA90B}"; const sal_Char* const OLE_GUID_FILEMONIKER = "{00000303-0000-0000-C000-000000000046}"; @@ -69,14 +86,15 @@ void lclAppendHex( OUStringBuffer& orBuffer, Type nValue ) orBuffer.setCharAt( nCharIdx, spcHexChars[ nValue & 0xF ] ); } -OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc, bool bUnicode ) +OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, bool bUnicode ) { OUString aRet; sal_Int32 nChars = rInStrm.readInt32(); if( nChars > 0 ) { sal_Int32 nReadChars = getLimitedValue< sal_Int32, sal_Int32 >( nChars, 0, SAL_MAX_UINT16 ); - aRet = bUnicode ? rInStrm.readUnicodeArray( nReadChars, true ) : rInStrm.readCharArrayUC( nReadChars, eTextEnc, true ); + // byte strings are always in ANSI (Windows 1252) encoding + aRet = bUnicode ? rInStrm.readUnicodeArray( nReadChars, true ) : rInStrm.readCharArrayUC( nReadChars, RTL_TEXTENCODING_MS_1252, true ); // strings are NUL terminated, remove trailing NUL and possible other garbage sal_Int32 nNulPos = aRet.indexOf( '\0' ); if( nNulPos >= 0 ) @@ -91,6 +109,59 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe // ============================================================================ +StdFontInfo::StdFontInfo() : + mnHeight( 0 ), + mnWeight( OLE_STDFONT_NORMAL ), + mnCharSet( WINDOWS_CHARSET_ANSI ), + mnFlags( 0 ) +{ +} + +StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, + sal_uInt16 nWeight, sal_uInt16 nCharSet, sal_uInt8 nFlags ) : + maName( rName ), + mnHeight( nHeight ), + mnWeight( nWeight ), + mnCharSet( nCharSet ), + mnFlags( nFlags ) +{ +} + +// ============================================================================ + +/*static*/ sal_Int32 OleHelper::decodeOleColor( + const GraphicHelper& rGraphicHelper, sal_uInt32 nOleColor, bool bDefaultColorBgr ) +{ + static const sal_Int32 spnSystemColors[] = + { + XML_scrollBar, XML_background, XML_activeCaption, XML_inactiveCaption, + XML_menu, XML_window, XML_windowFrame, XML_menuText, + XML_windowText, XML_captionText, XML_activeBorder, XML_inactiveBorder, + XML_appWorkspace, XML_highlight, XML_highlightText, XML_btnFace, + XML_btnShadow, XML_grayText, XML_btnText, XML_inactiveCaptionText, + XML_btnHighlight, XML_3dDkShadow, XML_3dLight, XML_infoText, + XML_infoBk + }; + + switch( nOleColor & OLE_COLORTYPE_MASK ) + { + case OLE_COLORTYPE_CLIENT: + return bDefaultColorBgr ? lclDecodeBgrColor( nOleColor ) : rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK ); + break; + + case OLE_COLORTYPE_PALETTE: + return rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK ); + + case OLE_COLORTYPE_BGR: + return lclDecodeBgrColor( nOleColor ); + + case OLE_COLORTYPE_SYSCOLOR: + return rGraphicHelper.getSystemColor( STATIC_ARRAY_SELECT( spnSystemColors, nOleColor & OLE_SYSTEMCOLOR_MASK, XML_TOKEN_INVALID ), API_RGB_WHITE ); + } + OSL_ENSURE( false, "OleHelper::decodeOleColor - unknown color type" ); + return API_RGB_BLACK; +} + /*static*/ OUString OleHelper::importGuid( BinaryInputStream& rInStrm ) { OUStringBuffer aBuffer; @@ -110,6 +181,24 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe return aBuffer.makeStringAndClear(); } +/*static*/ bool OleHelper::importStdFont( StdFontInfo& orFontInfo, BinaryInputStream& rInStrm, bool bWithGuid ) +{ + if( bWithGuid ) + { + bool bIsStdFont = importGuid( rInStrm ).equalsAscii( OLE_GUID_STDFONT ); + OSL_ENSURE( bIsStdFont, "OleHelper::importStdFont - unexpected header GUID, expected StdFont" ); + if( !bIsStdFont ) + return false; + } + + sal_uInt8 nVersion, nNameLen; + rInStrm >> nVersion >> orFontInfo.mnCharSet >> orFontInfo.mnFlags >> orFontInfo.mnWeight >> orFontInfo.mnHeight >> nNameLen; + // according to spec the name is ASCII + orFontInfo.maName = rInStrm.readCharArrayUC( nNameLen, RTL_TEXTENCODING_ASCII_US ); + OSL_ENSURE( nVersion <= 1, "OleHelper::importStdFont - wrong version" ); + return !rInStrm.isEof() && (nVersion <= 1); +} + /*static*/ bool OleHelper::importStdPic( StreamDataSequence& orGraphicData, BinaryInputStream& rInStrm, bool bWithGuid ) { if( bWithGuid ) @@ -127,7 +216,7 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe return !rInStrm.isEof() && (nStdPicId == OLE_STDPIC_ID) && (nBytes > 0) && (rInStrm.readData( orGraphicData, nBytes ) == nBytes); } -/*static*/ bool OleHelper::importStdHlink( StdHlinkInfo& orHlinkInfo, BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc, bool bWithGuid ) +/*static*/ bool OleHelper::importStdHlink( StdHlinkInfo& orHlinkInfo, BinaryInputStream& rInStrm, bool bWithGuid ) { if( bWithGuid ) { @@ -145,10 +234,10 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe // display string if( getFlag( nFlags, OLE_STDHLINK_HASDISPLAY ) ) - orHlinkInfo.maDisplay = lclReadStdHlinkString( rInStrm, eTextEnc, true ); + orHlinkInfo.maDisplay = lclReadStdHlinkString( rInStrm, true ); // frame string if( getFlag( nFlags, OLE_STDHLINK_HASFRAME ) ) - orHlinkInfo.maFrame = lclReadStdHlinkString( rInStrm, eTextEnc, true ); + orHlinkInfo.maFrame = lclReadStdHlinkString( rInStrm, true ); // target if( getFlag( nFlags, OLE_STDHLINK_HASTARGET ) ) @@ -156,7 +245,7 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe if( getFlag( nFlags, OLE_STDHLINK_ASSTRING ) ) { OSL_ENSURE( getFlag( nFlags, OLE_STDHLINK_ABSOLUTE ), "OleHelper::importStdHlink - link not absolute" ); - orHlinkInfo.maTarget = lclReadStdHlinkString( rInStrm, eTextEnc, true ); + orHlinkInfo.maTarget = lclReadStdHlinkString( rInStrm, true ); } else // hyperlink moniker { @@ -167,7 +256,7 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe sal_Int16 nUpLevels; rInStrm >> nUpLevels; OSL_ENSURE( (nUpLevels == 0) || !getFlag( nFlags, OLE_STDHLINK_ABSOLUTE ), "OleHelper::importStdHlink - absolute filename with upcount" ); - orHlinkInfo.maTarget = lclReadStdHlinkString( rInStrm, eTextEnc, false ); + orHlinkInfo.maTarget = lclReadStdHlinkString( rInStrm, false ); rInStrm.skip( 24 ); sal_Int32 nBytes = rInStrm.readInt32(); if( nBytes > 0 ) @@ -200,9 +289,9 @@ OUString lclReadStdHlinkString( BinaryInputStream& rInStrm, rtl_TextEncoding eTe // target location if( getFlag( nFlags, OLE_STDHLINK_HASLOCATION ) ) - orHlinkInfo.maLocation = lclReadStdHlinkString( rInStrm, eTextEnc, true ); + orHlinkInfo.maLocation = lclReadStdHlinkString( rInStrm, true ); - return true; + return !rInStrm.isEof(); } // ============================================================================ diff --git a/oox/source/ole/olestorage.cxx b/oox/source/ole/olestorage.cxx new file mode 100755 index 000000000000..39ecbb84a062 --- /dev/null +++ b/oox/source/ole/olestorage.cxx @@ -0,0 +1,420 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/olestorage.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "oox/helper/helper.hxx" +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/binaryoutputstream.hxx" + +using ::rtl::OUString; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::embed::XStorage; +using ::com::sun::star::embed::XTransactedObject; +using ::com::sun::star::io::BufferSizeExceededException; +using ::com::sun::star::io::IOException; +using ::com::sun::star::io::NotConnectedException; +using ::com::sun::star::io::XInputStream; +using ::com::sun::star::io::XOutputStream; +using ::com::sun::star::io::XSeekable; +using ::com::sun::star::io::XStream; +using ::com::sun::star::lang::IllegalArgumentException; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; + +namespace oox { +namespace ole { + +// ============================================================================ + +namespace { + +typedef ::cppu::WeakImplHelper2< XSeekable, XOutputStream > OleOutputStreamBase; + +/** Implementation of an OLE storage output stream that inserts itself into the + storage when it is closed. + */ +class OleOutputStream : public OleOutputStreamBase +{ +public: + explicit OleOutputStream( + const Reference< XMultiServiceFactory >& rxFactory, + const Reference< XNameContainer >& rxStorage, + const OUString& rElementName ); + virtual ~OleOutputStream(); + + virtual void SAL_CALL seek( sal_Int64 nPos ) throw( IllegalArgumentException, IOException, RuntimeException ); + virtual sal_Int64 SAL_CALL getPosition() throw( IOException, RuntimeException ); + virtual sal_Int64 SAL_CALL getLength() throw( IOException, RuntimeException ); + + virtual void SAL_CALL writeBytes( const Sequence< sal_Int8 >& rData ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ); + virtual void SAL_CALL flush() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ); + virtual void SAL_CALL closeOutput() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ); + +private: + void ensureSeekable() const throw( IOException ); + void ensureConnected() const throw( NotConnectedException ); + +private: + Reference< XNameContainer > mxStorage; + Reference< XStream > mxTempFile; + Reference< XOutputStream > mxOutStrm; + Reference< XSeekable > mxSeekable; + OUString maElementName; +}; + +// ---------------------------------------------------------------------------- + +OleOutputStream::OleOutputStream( const Reference< XMultiServiceFactory >& rxFactory, + const Reference< XNameContainer >& rxStorage, const OUString& rElementName ) : + mxStorage( rxStorage ), + maElementName( rElementName ) +{ + try + { + mxTempFile.set( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TempFile" ) ), UNO_QUERY_THROW ); + mxOutStrm = mxTempFile->getOutputStream(); + mxSeekable.set( mxOutStrm, UNO_QUERY ); + } + catch( Exception& ) + { + } +} + +OleOutputStream::~OleOutputStream() +{ +} + +void SAL_CALL OleOutputStream::seek( sal_Int64 nPos ) throw( IllegalArgumentException, IOException, RuntimeException ) +{ + ensureSeekable(); + mxSeekable->seek( nPos ); +} + +sal_Int64 SAL_CALL OleOutputStream::getPosition() throw( IOException, RuntimeException ) +{ + ensureSeekable(); + return mxSeekable->getPosition(); +} + +sal_Int64 SAL_CALL OleOutputStream::getLength() throw( IOException, RuntimeException ) +{ + ensureSeekable(); + return mxSeekable->getLength(); +} + +void SAL_CALL OleOutputStream::writeBytes( const Sequence< sal_Int8 >& rData ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ) +{ + ensureConnected(); + mxOutStrm->writeBytes( rData ); +} + +void SAL_CALL OleOutputStream::flush() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ) +{ + ensureConnected(); + mxOutStrm->flush(); +} + +void SAL_CALL OleOutputStream::closeOutput() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException ) +{ + ensureConnected(); + ensureSeekable(); + // remember the class members + Reference< XOutputStream > xOutStrm = mxOutStrm; + Reference< XSeekable > xSeekable = mxSeekable; + // reset all class members + mxOutStrm.clear(); + mxSeekable.clear(); + // close stream (and let it throw something if needed) + xOutStrm->closeOutput(); + // on success, insert the stream into the OLE storage (must be seeked back before) + xSeekable->seek( 0 ); + if( !ContainerHelper::insertByName( mxStorage, maElementName, Any( mxTempFile ) ) ) + throw IOException(); +} + +void OleOutputStream::ensureSeekable() const throw( IOException ) +{ + if( !mxSeekable.is() ) + throw IOException(); +} + +void OleOutputStream::ensureConnected() const throw( NotConnectedException ) +{ + if( !mxOutStrm.is() ) + throw NotConnectedException(); +} + +} // namespace + +// ============================================================================ + +OleStorage::OleStorage( + const Reference< XMultiServiceFactory >& rxFactory, + const Reference< XInputStream >& rxInStream, + bool bBaseStreamAccess ) : + StorageBase( rxInStream, bBaseStreamAccess ), + mxFactory( rxFactory ), + mpParentStorage( 0 ) +{ + OSL_ENSURE( mxFactory.is(), "OleStorage::OleStorage - missing service factory" ); + initStorage( rxInStream ); +} + +OleStorage::OleStorage( + const Reference< XMultiServiceFactory >& rxFactory, + const Reference< XStream >& rxOutStream, + bool bBaseStreamAccess ) : + StorageBase( rxOutStream, bBaseStreamAccess ), + mxFactory( rxFactory ), + mpParentStorage( 0 ) +{ + OSL_ENSURE( mxFactory.is(), "OleStorage::OleStorage - missing service factory" ); + initStorage( rxOutStream ); +} + +OleStorage::OleStorage( + const OleStorage& rParentStorage, + const Reference< XNameContainer >& rxStorage, + const OUString& rElementName, + bool bReadOnly ) : + StorageBase( rParentStorage, rElementName, bReadOnly ), + mxFactory( rParentStorage.mxFactory ), + mxStorage( rxStorage ), + mpParentStorage( &rParentStorage ) +{ + OSL_ENSURE( mxStorage.is(), "OleStorage::OleStorage - missing substorage elements" ); +} + +OleStorage::OleStorage( + const OleStorage& rParentStorage, + const Reference< XStream >& rxOutStream, + const OUString& rElementName ) : + StorageBase( rParentStorage, rElementName, false ), + mxFactory( rParentStorage.mxFactory ), + mpParentStorage( &rParentStorage ) +{ + initStorage( rxOutStream ); +} + +OleStorage::~OleStorage() +{ +} + +// ---------------------------------------------------------------------------- + +void OleStorage::initStorage( const Reference< XInputStream >& rxInStream ) +{ + // if stream is not seekable, create temporary copy + Reference< XInputStream > xInStrm = rxInStream; + if( !Reference< XSeekable >( xInStrm, UNO_QUERY ).is() ) try + { + Reference< XStream > xTempFile( mxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TempFile" ) ), UNO_QUERY_THROW ); + { + Reference< XOutputStream > xOutStrm( xTempFile->getOutputStream(), UNO_SET_THROW ); + BinaryXOutputStream aOutStrm( xOutStrm, true ); // true = close output stream on destruction of aOutStrm + BinaryXInputStream aInStrm( xInStrm, false ); // false = do not close intput stream on destruction of aInStrm + aInStrm.copyToStream( aOutStrm ); + } // scope closes output stream of tempfile + xInStrm = xTempFile->getInputStream(); + } + catch( Exception& ) + { + OSL_ENSURE( false, "OleStorage::initStorage - cannot create temporary copy of input stream" ); + } + + // create base storage object + if( xInStrm.is() ) try + { + Sequence< Any > aArgs( 2 ); + aArgs[ 0 ] <<= xInStrm; + aArgs[ 1 ] <<= true; // true = do not create a copy of the input stream + mxStorage.set( mxFactory->createInstanceWithArguments( + CREATE_OUSTRING( "com.sun.star.embed.OLESimpleStorage" ), aArgs ), UNO_QUERY_THROW ); + } + catch( Exception& ) + { + } +} + +void OleStorage::initStorage( const Reference< XStream >& rxOutStream ) +{ + // create base storage object + if( rxOutStream.is() ) try + { + Sequence< Any > aArgs( 2 ); + aArgs[ 0 ] <<= rxOutStream; + aArgs[ 1 ] <<= true; // true = do not create a copy of the stream + mxStorage.set( mxFactory->createInstanceWithArguments( + CREATE_OUSTRING( "com.sun.star.embed.OLESimpleStorage" ), aArgs ), UNO_QUERY_THROW ); + } + catch( Exception& ) + { + } +} + +// StorageBase interface ------------------------------------------------------ + +bool OleStorage::implIsStorage() const +{ + if( mxStorage.is() ) try + { + /* If this is not an OLE storage, hasElements() of the OLESimpleStorage + implementation throws an exception. But we do not return the result + of hasElements(), because an empty storage is a valid storage too. */ + mxStorage->hasElements(); + return true; + } + catch( Exception& ) + { + } + return false; +} + +Reference< XStorage > OleStorage::implGetXStorage() const +{ + OSL_ENSURE( false, "OleStorage::getXStorage - not implemented" ); + return Reference< XStorage >(); +} + +void OleStorage::implGetElementNames( ::std::vector< OUString >& orElementNames ) const +{ + Sequence< OUString > aNames; + if( mxStorage.is() ) try + { + aNames = mxStorage->getElementNames(); + if( aNames.getLength() > 0 ) + orElementNames.insert( orElementNames.end(), aNames.getConstArray(), aNames.getConstArray() + aNames.getLength() ); + } + catch( Exception& ) + { + } +} + +StorageRef OleStorage::implOpenSubStorage( const OUString& rElementName, bool bCreateMissing ) +{ + StorageRef xSubStorage; + if( mxStorage.is() && (rElementName.getLength() > 0) ) + { + try + { + Reference< XNameContainer > xSubElements( mxStorage->getByName( rElementName ), UNO_QUERY_THROW ); + xSubStorage.reset( new OleStorage( *this, xSubElements, rElementName, true ) ); + } + catch( Exception& ) + { + } + + /* The OLESimpleStorage API implementation seems to be buggy in the + area of writable inplace substorage (sometimes it overwrites other + unrelated streams with zero bytes). We go the save way and create a + new OLE storage based on a temporary file. All operations are + performed on this clean storage. On committing, the storage will be + completely re-inserted into the parent storage. */ + if( !isReadOnly() && (bCreateMissing || xSubStorage.get()) ) try + { + // create new storage based on a temp file + Reference< XStream > xTempFile( mxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TempFile" ) ), UNO_QUERY_THROW ); + StorageRef xTempStorage( new OleStorage( *this, xTempFile, rElementName ) ); + // copy existing substorage into temp storage + if( xSubStorage.get() ) + xSubStorage->copyStorageToStorage( *xTempStorage ); + // return the temp storage to caller + xSubStorage = xTempStorage; + } + catch( Exception& ) + { + } + } + return xSubStorage; +} + +Reference< XInputStream > OleStorage::implOpenInputStream( const OUString& rElementName ) +{ + Reference< XInputStream > xInStream; + if( mxStorage.is() ) try + { + xInStream.set( mxStorage->getByName( rElementName ), UNO_QUERY ); + } + catch( Exception& ) + { + } + return xInStream; +} + +Reference< XOutputStream > OleStorage::implOpenOutputStream( const OUString& rElementName ) +{ + Reference< XOutputStream > xOutStream; + if( mxStorage.is() && (rElementName.getLength() > 0) ) + xOutStream.set( new OleOutputStream( mxFactory, mxStorage, rElementName ) ); + return xOutStream; +} + +void OleStorage::implCommit() const +{ + try + { + // commit this storage (finalizes the file this storage is based on) + Reference< XTransactedObject >( mxStorage, UNO_QUERY_THROW )->commit(); + // re-insert this storage into the parent storage + if( mpParentStorage ) + { + if( mpParentStorage->mxStorage->hasByName( getName() ) ) + { + // replaceByName() does not work (#i109539#) + mpParentStorage->mxStorage->removeByName( getName() ); + Reference< XTransactedObject >( mpParentStorage->mxStorage, UNO_QUERY_THROW )->commit(); + } + mpParentStorage->mxStorage->insertByName( getName(), Any( mxStorage ) ); + // this requires another commit(), which will be performed by the parent storage + } + } + catch( Exception& ) + { + } +} + +// ============================================================================ + +} // namespace ole +} // namespace oox diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx new file mode 100755 index 000000000000..2674c30d9a73 --- /dev/null +++ b/oox/source/ole/vbacontrol.cxx @@ -0,0 +1,811 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/vbacontrol.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "properties.hxx" +#include "tokens.hxx" +#include "oox/helper/attributelist.hxx" +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/propertymap.hxx" +#include "oox/helper/propertyset.hxx" +#include "oox/helper/storagebase.hxx" +#include "oox/helper/textinputstream.hxx" +#include "oox/ole/vbahelper.hxx" + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::awt::XControlModel; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::io::XInputStreamProvider; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::uno::XComponentContext; + +namespace oox { +namespace ole { + +// ============================================================================ + +namespace { + +const sal_uInt16 VBA_SITE_CLASSIDINDEX = 0x8000; +const sal_uInt16 VBA_SITE_INDEXMASK = 0x7FFF; +const sal_uInt16 VBA_SITE_FORM = 7; +const sal_uInt16 VBA_SITE_IMAGE = 12; +const sal_uInt16 VBA_SITE_FRAME = 14; +const sal_uInt16 VBA_SITE_SPINBUTTON = 16; +const sal_uInt16 VBA_SITE_COMMANDBUTTON = 17; +const sal_uInt16 VBA_SITE_TABSTRIP = 18; +const sal_uInt16 VBA_SITE_LABEL = 21; +const sal_uInt16 VBA_SITE_TEXTBOX = 23; +const sal_uInt16 VBA_SITE_LISTBOX = 24; +const sal_uInt16 VBA_SITE_COMBOBOX = 25; +const sal_uInt16 VBA_SITE_CHECKBOX = 26; +const sal_uInt16 VBA_SITE_OPTIONBUTTON = 27; +const sal_uInt16 VBA_SITE_TOGGLEBUTTON = 28; +const sal_uInt16 VBA_SITE_SCROLLBAR = 47; +const sal_uInt16 VBA_SITE_MULTIPAGE = 57; +const sal_uInt16 VBA_SITE_UNKNOWN = 0x7FFF; + +const sal_uInt32 VBA_SITE_TABSTOP = 0x00000001; +const sal_uInt32 VBA_SITE_VISIBLE = 0x00000002; +const sal_uInt32 VBA_SITE_DEFAULTBUTTON = 0x00000004; +const sal_uInt32 VBA_SITE_CANCELBUTTON = 0x00000008; +const sal_uInt32 VBA_SITE_OSTREAM = 0x00000010; +const sal_uInt32 VBA_SITE_DEFFLAGS = 0x00000033; + +const sal_uInt8 VBA_SITEINFO_COUNT = 0x80; +const sal_uInt8 VBA_SITEINFO_MASK = 0x7F; + +// ---------------------------------------------------------------------------- + +/** Collects names of all controls in a user form or container control. Allows + to generate unused names for dummy controls separating option groups. + */ +class VbaControlNamesSet +{ +public: + explicit VbaControlNamesSet(); + + /** Inserts the name of the passed control. */ + void insertName( const VbaFormControl& rControl ); + /** Returns a name that is not contained in this set. */ + OUString generateDummyName(); + +private: + typedef ::std::set< OUString > OUStringSet; + OUStringSet maCtrlNames; + const OUString maDummyBaseName; + sal_Int32 mnIndex; +}; + +VbaControlNamesSet::VbaControlNamesSet() : + maDummyBaseName( CREATE_OUSTRING( "DummyGroupSep" ) ), + mnIndex( 0 ) +{ +} + +void VbaControlNamesSet::insertName( const VbaFormControl& rControl ) +{ + OUString aName = rControl.getControlName(); + if( aName.getLength() > 0 ) + maCtrlNames.insert( aName ); +} + +OUString VbaControlNamesSet::generateDummyName() +{ + OUString aCtrlName; + do + { + aCtrlName = OUStringBuffer( maDummyBaseName ).append( ++mnIndex ).makeStringAndClear(); + } + while( maCtrlNames.count( aCtrlName ) > 0 ); + maCtrlNames.insert( aCtrlName ); + return aCtrlName; +} + +// ---------------------------------------------------------------------------- + +/** Functor that inserts the name of a control into a VbaControlNamesSet. */ +struct VbaControlNameInserter +{ +public: + VbaControlNamesSet& mrCtrlNames; + inline explicit VbaControlNameInserter( VbaControlNamesSet& rCtrlNames ) : mrCtrlNames( rCtrlNames ) {} + inline void operator()( const VbaFormControl& rControl ) { mrCtrlNames.insertName( rControl ); } +}; + +// ---------------------------------------------------------------------------- + +/** A dummy invisible form control (fixed label without text) that is used to + separate two groups of option buttons. + */ +class VbaDummyFormControl : public VbaFormControl +{ +public: + explicit VbaDummyFormControl( const OUString& rName ); +}; + +VbaDummyFormControl::VbaDummyFormControl( const OUString& rName ) +{ + mxSiteModel.reset( new VbaSiteModel ); + mxSiteModel->importProperty( XML_Name, rName ); + mxSiteModel->importProperty( XML_VariousPropertyBits, OUString( sal_Unicode( '0' ) ) ); + + mxCtrlModel.reset( new AxLabelModel ); + mxCtrlModel->setAwtModelMode(); + mxCtrlModel->importProperty( XML_Size, CREATE_OUSTRING( "10;10" ) ); +} + +} // namespace + +// ============================================================================ + +VbaSiteModel::VbaSiteModel() : + maPos( 0, 0 ), + mnId( 0 ), + mnHelpContextId( 0 ), + mnFlags( VBA_SITE_DEFFLAGS ), + mnStreamLen( 0 ), + mnTabIndex( -1 ), + mnClassIdOrCache( VBA_SITE_UNKNOWN ), + mnGroupId( 0 ) +{ +} + +VbaSiteModel::~VbaSiteModel() +{ +} + +void VbaSiteModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) +{ + switch( nPropId ) + { + case XML_Name: maName = rValue; break; + case XML_Tag: maTag = rValue; break; + case XML_VariousPropertyBits: mnFlags = AttributeList::decodeUnsigned( rValue ); break; + } +} + +bool VbaSiteModel::importBinaryModel( BinaryInputStream& rInStrm ) +{ + AxBinaryPropertyReader aReader( rInStrm ); + aReader.readStringProperty( maName ); + aReader.readStringProperty( maTag ); + aReader.readIntProperty< sal_Int32 >( mnId ); + aReader.readIntProperty< sal_Int32 >( mnHelpContextId ); + aReader.readIntProperty< sal_uInt32 >( mnFlags ); + aReader.readIntProperty< sal_uInt32 >( mnStreamLen ); + aReader.readIntProperty< sal_Int16 >( mnTabIndex ); + aReader.readIntProperty< sal_uInt16 >( mnClassIdOrCache ); + aReader.readPairProperty( maPos ); + aReader.readIntProperty< sal_uInt16 >( mnGroupId ); + aReader.skipUndefinedProperty(); + aReader.readStringProperty( maToolTip ); + aReader.skipStringProperty(); // license key + aReader.readStringProperty( maLinkedCell ); + aReader.readStringProperty( maSourceRange ); + return aReader.finalizeImport(); +} + +void VbaSiteModel::moveRelative( const AxPairData& rDistance ) +{ + maPos.first += rDistance.first; + maPos.second += rDistance.second; +} + +bool VbaSiteModel::isContainer() const +{ + return !getFlag( mnFlags, VBA_SITE_OSTREAM ); +} + +sal_uInt32 VbaSiteModel::getStreamLength() const +{ + return isContainer() ? 0 : mnStreamLen; +} + +OUString VbaSiteModel::getSubStorageName() const +{ + if( mnId >= 0 ) + { + OUStringBuffer aBuffer; + aBuffer.append( sal_Unicode( 'i' ) ); + if( mnId < 10 ) + aBuffer.append( sal_Unicode( '0' ) ); + aBuffer.append( mnId ); + return aBuffer.makeStringAndClear(); + } + return OUString(); +} + +ControlModelRef VbaSiteModel::createControlModel( const AxClassTable& rClassTable ) const +{ + ControlModelRef xCtrlModel; + + sal_Int32 nTypeIndex = static_cast< sal_Int32 >( mnClassIdOrCache & VBA_SITE_INDEXMASK ); + if( !getFlag( mnClassIdOrCache, VBA_SITE_CLASSIDINDEX ) ) + { + switch( nTypeIndex ) + { + case VBA_SITE_COMMANDBUTTON: xCtrlModel.reset( new AxCommandButtonModel ); break; + case VBA_SITE_LABEL: xCtrlModel.reset( new AxLabelModel ); break; + case VBA_SITE_IMAGE: xCtrlModel.reset( new AxImageModel ); break; + case VBA_SITE_TOGGLEBUTTON: xCtrlModel.reset( new AxToggleButtonModel ); break; + case VBA_SITE_CHECKBOX: xCtrlModel.reset( new AxCheckBoxModel ); break; + case VBA_SITE_OPTIONBUTTON: xCtrlModel.reset( new AxOptionButtonModel ); break; + case VBA_SITE_TEXTBOX: xCtrlModel.reset( new AxTextBoxModel ); break; + case VBA_SITE_LISTBOX: xCtrlModel.reset( new AxListBoxModel ); break; + case VBA_SITE_COMBOBOX: xCtrlModel.reset( new AxComboBoxModel ); break; + case VBA_SITE_SPINBUTTON: /*xCtrlModel.reset( new AxSpinButtonModel );*/ break; // not supported (?) + case VBA_SITE_SCROLLBAR: xCtrlModel.reset( new AxScrollBarModel ); break; + case VBA_SITE_TABSTRIP: break; // not supported + case VBA_SITE_FRAME: xCtrlModel.reset( new AxFrameModel ); break; + case VBA_SITE_MULTIPAGE: break; // not supported + case VBA_SITE_FORM: break; // not supported + default: OSL_ENSURE( false, "VbaSiteModel::createControlModel - unknown type index" ); + } + } + else + { + const OUString* pGuid = ContainerHelper::getVectorElement( rClassTable, nTypeIndex ); + OSL_ENSURE( pGuid, "VbaSiteModel::createControlModel - invalid class table index" ); + if( pGuid ) + { + if( pGuid->equalsAscii( COMCTL_GUID_SCROLLBAR_60 ) ) + xCtrlModel.reset( new ComCtlScrollBarModel( 6 ) ); + else if( pGuid->equalsAscii( COMCTL_GUID_PROGRESSBAR_50 ) ) + xCtrlModel.reset( new ComCtlProgressBarModel( 5 ) ); + else if( pGuid->equalsAscii( COMCTL_GUID_PROGRESSBAR_60 ) ) + xCtrlModel.reset( new ComCtlProgressBarModel( 6 ) ); + } + } + + if( xCtrlModel.get() ) + { + // user form controls are AWT models + xCtrlModel->setAwtModelMode(); + + // check that container model matches container flag in site data + bool bModelIsContainer = dynamic_cast< const AxContainerModelBase* >( xCtrlModel.get() ) != 0; + bool bTypeMatch = bModelIsContainer == isContainer(); + OSL_ENSURE( bTypeMatch, "VbaSiteModel::createControlModel - container type does not match container flag" ); + if( !bTypeMatch ) + xCtrlModel.reset(); + } + return xCtrlModel; +} + +void VbaSiteModel::convertProperties( PropertyMap& rPropMap, + const ControlConverter& rConv, ApiControlType eCtrlType, sal_Int32 nCtrlIndex ) const +{ + rPropMap.setProperty( PROP_Name, maName ); + rPropMap.setProperty( PROP_Tag, maTag ); + + if( eCtrlType != API_CONTROL_DIALOG ) + { + rPropMap.setProperty( PROP_HelpText, maToolTip ); + rPropMap.setProperty( PROP_EnableVisible, getFlag( mnFlags, VBA_SITE_VISIBLE ) ); + // we need to set the passed control index to make option button groups work + if( (0 <= nCtrlIndex) && (nCtrlIndex <= SAL_MAX_INT16) ) + rPropMap.setProperty( PROP_TabIndex, static_cast< sal_Int16 >( nCtrlIndex ) ); + // progress bar and group box support TabIndex, but not Tabstop... + if( (eCtrlType != API_CONTROL_PROGRESSBAR) && (eCtrlType != API_CONTROL_GROUPBOX) ) + rPropMap.setProperty( PROP_Tabstop, getFlag( mnFlags, VBA_SITE_TABSTOP ) ); + rConv.convertPosition( rPropMap, maPos ); + } +} + +// ============================================================================ + +VbaFormControl::VbaFormControl() +{ +} + +VbaFormControl::~VbaFormControl() +{ +} + +void VbaFormControl::importModelOrStorage( BinaryInputStream& rInStrm, StorageBase& rStrg, const AxClassTable& rClassTable ) +{ + if( mxSiteModel.get() ) + { + if( mxSiteModel->isContainer() ) + { + StorageRef xSubStrg = rStrg.openSubStorage( mxSiteModel->getSubStorageName(), false ); + OSL_ENSURE( xSubStrg.get(), "VbaFormControl::importModelOrStorage - cannot find storage for embedded control" ); + if( xSubStrg.get() ) + importStorage( *xSubStrg, rClassTable ); + } + else if( !rInStrm.isEof() ) + { + sal_Int64 nNextStrmPos = rInStrm.tell() + mxSiteModel->getStreamLength(); + importControlModel( rInStrm, rClassTable ); + rInStrm.seek( nNextStrmPos ); + } + } +} + +OUString VbaFormControl::getControlName() const +{ + return mxSiteModel.get() ? mxSiteModel->getName() : OUString(); +} + +void VbaFormControl::createAndConvert( sal_Int32 nCtrlIndex, + const Reference< XNameContainer >& rxParentNC, const ControlConverter& rConv ) const +{ + if( rxParentNC.is() && mxSiteModel.get() && mxCtrlModel.get() ) try + { + // create the control model + OUString aServiceName = mxCtrlModel->getServiceName(); + Reference< XMultiServiceFactory > xModelFactory( rxParentNC, UNO_QUERY_THROW ); + Reference< XControlModel > xCtrlModel( xModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW ); + + // convert all properties and embedded controls + if( convertProperties( xCtrlModel, rConv, nCtrlIndex ) ) + { + // insert into parent container + const OUString& rCtrlName = mxSiteModel->getName(); + OSL_ENSURE( !rxParentNC->hasByName( rCtrlName ), "VbaFormControl::createAndConvert - multiple controls with equal name" ); + ContainerHelper::insertByName( rxParentNC, rCtrlName, Any( xCtrlModel ) ); + } + } + catch( Exception& ) + { + } +} + +// protected ------------------------------------------------------------------ + +void VbaFormControl::importControlModel( BinaryInputStream& rInStrm, const AxClassTable& rClassTable ) +{ + createControlModel( rClassTable ); + if( mxCtrlModel.get() ) + mxCtrlModel->importBinaryModel( rInStrm ); +} + +void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rClassTable ) +{ + createControlModel( rClassTable ); + AxContainerModelBase* pContainerModel = dynamic_cast< AxContainerModelBase* >( mxCtrlModel.get() ); + OSL_ENSURE( pContainerModel, "VbaFormControl::importStorage - missing container control model" ); + if( pContainerModel ) + { + /* Open the 'f' stream containing the model of this control and a list + of site models for all child controls. */ + BinaryXInputStream aFStrm( rStrg.openInputStream( CREATE_OUSTRING( "f" ) ), true ); + OSL_ENSURE( !aFStrm.isEof(), "VbaFormControl::importStorage - missing 'f' stream" ); + + /* Read the properties of this container control and the class table + (into the maClassTable vector) containing a list of GUIDs for + exotic embedded controls. */ + if( !aFStrm.isEof() && pContainerModel->importBinaryModel( aFStrm ) && pContainerModel->importClassTable( aFStrm, maClassTable ) ) + { + /* Read the site models of all embedded controls (this fills the + maControls vector). Ignore failure of importSiteModels() but + try to import as much controls as possible. */ + importEmbeddedSiteModels( aFStrm ); + + /* Open the 'o' stream containing models of embedded simple + controls. Stream may be empty or missing, if this control + contains no controls or only container controls. */ + BinaryXInputStream aOStrm( rStrg.openInputStream( CREATE_OUSTRING( "o" ) ), true ); + + /* Iterate over all embedded controls, import model from 'o' + stream (for embedded simple controls) or from the substorage + (for embedded container controls). */ + maControls.forEachMem( &VbaFormControl::importModelOrStorage, + ::boost::ref( aOStrm ), ::boost::ref( rStrg ), ::boost::cref( maClassTable ) ); + + /* Reorder the controls (sorts all option buttons of an option + group together), and move all children of all embedded frames + (group boxes) to this control (UNO group boxes cannot contain + other controls). */ + finalizeEmbeddedControls(); + } + } +} + +bool VbaFormControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, + const ControlConverter& rConv, sal_Int32 nCtrlIndex ) const +{ + if( rxCtrlModel.is() && mxSiteModel.get() && mxCtrlModel.get() ) + { + const OUString& rCtrlName = mxSiteModel->getName(); + OSL_ENSURE( rCtrlName.getLength() > 0, "VbaFormControl::convertProperties - control without name" ); + if( rCtrlName.getLength() > 0 ) + { + // convert all properties + PropertyMap aPropMap; + mxSiteModel->convertProperties( aPropMap, rConv, mxCtrlModel->getControlType(), nCtrlIndex ); + mxCtrlModel->convertProperties( aPropMap, rConv ); + mxCtrlModel->convertSize( aPropMap, rConv ); + PropertySet aPropSet( rxCtrlModel ); + aPropSet.setProperties( aPropMap ); + + // create and convert all embedded controls + if( !maControls.empty() ) try + { + Reference< XNameContainer > xCtrlModelNC( rxCtrlModel, UNO_QUERY_THROW ); + /* Call conversion for all controls. Pass vector index as new + tab order to make option button groups work correctly. */ + maControls.forEachMemWithIndex( &VbaFormControl::createAndConvert, + ::boost::cref( xCtrlModelNC ), ::boost::cref( rConv ) ); + } + catch( Exception& ) + { + OSL_ENSURE( false, "VbaFormControl::convertProperties - cannot get control container interface" ); + } + + return true; + } + } + return false; +} + +// private -------------------------------------------------------------------- + +void VbaFormControl::createControlModel( const AxClassTable& rClassTable ) +{ + // derived classes may have created their own control model + if( !mxCtrlModel && mxSiteModel.get() ) + mxCtrlModel = mxSiteModel->createControlModel( rClassTable ); +} + +bool VbaFormControl::importSiteModel( BinaryInputStream& rInStrm ) +{ + mxSiteModel.reset( new VbaSiteModel ); + return mxSiteModel->importBinaryModel( rInStrm ); +} + +bool VbaFormControl::importEmbeddedSiteModels( BinaryInputStream& rInStrm ) +{ + sal_uInt64 nAnchorPos = rInStrm.tell(); + sal_uInt32 nSiteCount, nSiteDataSize; + rInStrm >> nSiteCount >> nSiteDataSize; + sal_Int64 nSiteEndPos = rInStrm.tell() + nSiteDataSize; + + // skip the site info structure + sal_uInt32 nSiteIndex = 0; + while( !rInStrm.isEof() && (nSiteIndex < nSiteCount) ) + { + rInStrm.skip( 1 ); // site depth + sal_uInt8 nTypeCount = rInStrm.readuInt8(); // 'type-or-count' byte + if( getFlag( nTypeCount, VBA_SITEINFO_COUNT ) ) + { + /* Count flag is set: the 'type-or-count' byte contains the number + of controls in the lower bits, the type specifier follows in + the next byte. The type specifier should always be 1 according + to the specification. */ + rInStrm.skip( 1 ); + nSiteIndex += (nTypeCount & VBA_SITEINFO_MASK); + } + else + { + /* Count flag is not set: the 'type-or-count' byte contains the + type specifier of *one* control in the lower bits (this type + should be 1, see above). */ + ++nSiteIndex; + } + } + // align the stream to 32bit, relative to start of entire site info + rInStrm.align( 4, nAnchorPos ); + + // import the site models for all embedded controls + maControls.clear(); + bool bValid = !rInStrm.isEof(); + for( nSiteIndex = 0; bValid && (nSiteIndex < nSiteCount); ++nSiteIndex ) + { + VbaFormControlRef xControl( new VbaFormControl ); + maControls.push_back( xControl ); + bValid = xControl->importSiteModel( rInStrm ); + } + + rInStrm.seek( nSiteEndPos ); + return bValid; +} + +void VbaFormControl::finalizeEmbeddedControls() +{ + /* This function performs two tasks: + + 1) Reorder the controls appropriately (sort all option buttons of an + option group together to make grouping work). + 2) Move all children of all embedded frames (group boxes) to this + control (UNO group boxes cannot contain other controls). + */ + + // first, sort all controls by original tab index + ::std::sort( maControls.begin(), maControls.end(), &compareByTabIndex ); + + /* Collect the programmatical names of all embedded controls (needed to be + able to set unused names to new dummy controls created below). Also + collect the names of all children of embedded frames (group boxes). + Luckily, names of controls must be unique in the entire form, not just + in the current container. */ + VbaControlNamesSet aControlNames; + VbaControlNameInserter aInserter( aControlNames ); + maControls.forEach( aInserter ); + for( VbaFormControlVector::iterator aIt = maControls.begin(), aEnd = maControls.end(); aIt != aEnd; ++aIt ) + if( (*aIt)->mxCtrlModel.get() && ((*aIt)->mxCtrlModel->getControlType() == API_CONTROL_GROUPBOX) ) + (*aIt)->maControls.forEach( aInserter ); + + /* Reprocess the sorted list and collect all option button controls that + are part of the same option group (determined by group name). All + controls will be stored in a vector of vectors, that collects every + option button group in one vector element, and other controls between + these option groups (or leading or trailing controls) in other vector + elements. If an option button group follows another group, a dummy + separator control has to be inserted. */ + typedef RefVector< VbaFormControlVector > VbaFormControlVectorVector; + VbaFormControlVectorVector aControlGroups; + + typedef RefMap< OUString, VbaFormControlVector > VbaFormControlVectorMap; + VbaFormControlVectorMap aOptionGroups; + + typedef VbaFormControlVectorMap::mapped_type VbaFormControlVectorRef; + bool bLastWasOptionButton = false; + for( VbaFormControlVector::iterator aIt = maControls.begin(), aEnd = maControls.end(); aIt != aEnd; ++aIt ) + { + VbaFormControlRef xControl = *aIt; + const ControlModelBase* pCtrlModel = xControl->mxCtrlModel.get(); + + if( const AxOptionButtonModel* pOptButtonModel = dynamic_cast< const AxOptionButtonModel* >( pCtrlModel ) ) + { + // check if a new option group needs to be created + const OUString& rGroupName = pOptButtonModel->getGroupName(); + VbaFormControlVectorRef& rxOptionGroup = aOptionGroups[ rGroupName ]; + if( !rxOptionGroup ) + { + /* If last control was an option button too, we have two + option groups following each other, so a dummy separator + control is needed. */ + if( bLastWasOptionButton ) + { + VbaFormControlVectorRef xDummyGroup( new VbaFormControlVector ); + aControlGroups.push_back( xDummyGroup ); + OUString aName = aControlNames.generateDummyName(); + VbaFormControlRef xDummyControl( new VbaDummyFormControl( aName ) ); + xDummyGroup->push_back( xDummyControl ); + } + rxOptionGroup.reset( new VbaFormControlVector ); + aControlGroups.push_back( rxOptionGroup ); + } + /* Append the option button to the control group (which is now + referred by the vector aControlGroups and by the map + aOptionGroups). */ + rxOptionGroup->push_back( xControl ); + bLastWasOptionButton = true; + } + else + { + // open a new control group, if the last group is an option group + if( bLastWasOptionButton || aControlGroups.empty() ) + { + VbaFormControlVectorRef xControlGroup( new VbaFormControlVector ); + aControlGroups.push_back( xControlGroup ); + } + // append the control to the last control group + VbaFormControlVector& rLastGroup = *aControlGroups.back(); + rLastGroup.push_back( xControl ); + bLastWasOptionButton = false; + + // if control is a group box, move all its children to this control + if( pCtrlModel && (pCtrlModel->getControlType() == API_CONTROL_GROUPBOX) ) + { + /* Move all embedded controls of the group box relative to the + position of the group box. */ + xControl->moveEmbeddedToAbsoluteParent(); + /* Insert all children of the group box into the last control + group (following the group box). */ + rLastGroup.insert( rLastGroup.end(), xControl->maControls.begin(), xControl->maControls.end() ); + xControl->maControls.clear(); + // check if last control of the group box is an option button + bLastWasOptionButton = dynamic_cast< const AxOptionButtonModel* >( rLastGroup.back()->mxCtrlModel.get() ) != 0; + } + } + } + + // flatten the vector of vectors of form controls to a single vector + maControls.clear(); + for( VbaFormControlVectorVector::iterator aIt = aControlGroups.begin(), aEnd = aControlGroups.end(); aIt != aEnd; ++aIt ) + maControls.insert( maControls.end(), (*aIt)->begin(), (*aIt)->end() ); +} + +void VbaFormControl::moveRelative( const AxPairData& rDistance ) +{ + if( mxSiteModel.get() ) + mxSiteModel->moveRelative( rDistance ); +} + +void VbaFormControl::moveEmbeddedToAbsoluteParent() +{ + if( mxSiteModel.get() && !maControls.empty() ) + { + // distance to move is equal to position of this control in its parent + AxPairData aDistance = mxSiteModel->getPosition(); + + /* For group boxes: add half of the font height to Y position (VBA + positions relative to frame border line, not to 'top' of frame). */ + const AxFontDataModel* pFontModel = dynamic_cast< const AxFontDataModel* >( mxCtrlModel.get() ); + if( pFontModel && (pFontModel->getControlType() == API_CONTROL_GROUPBOX) ) + { + // convert points to 1/100 mm (1 pt = 1/72 inch = 2.54/72 cm = 2540/72 1/100 mm) + sal_Int32 nFontHeight = static_cast< sal_Int32 >( pFontModel->getFontHeight() * 2540 / 72 ); + aDistance.second += nFontHeight / 2; + } + + // move the embedded controls + maControls.forEachMem( &VbaFormControl::moveRelative, ::boost::cref( aDistance ) ); + } +} + +/*static*/ bool VbaFormControl::compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight ) +{ + // sort controls without model to the end + sal_Int32 nLeftTabIndex = rxLeft->mxSiteModel.get() ? rxLeft->mxSiteModel->getTabIndex() : SAL_MAX_INT32; + sal_Int32 nRightTabIndex = rxRight->mxSiteModel.get() ? rxRight->mxSiteModel->getTabIndex() : SAL_MAX_INT32; + return nLeftTabIndex < nRightTabIndex; +} + +// ============================================================================ + +namespace { + +OUString lclGetQuotedString( const OUString& rCodeLine ) +{ + OUStringBuffer aBuffer; + sal_Int32 nLen = rCodeLine.getLength(); + if( (nLen > 0) && (rCodeLine[ 0 ] == '"') ) + { + bool bExitLoop = false; + for( sal_Int32 nIndex = 1; !bExitLoop && (nIndex < nLen); ++nIndex ) + { + sal_Unicode cChar = rCodeLine[ nIndex ]; + // exit on closing quote char (but check on double quote chars) + bExitLoop = (cChar == '"') && ((nIndex + 1 == nLen) || (rCodeLine[ nIndex + 1 ] != '"')); + if( !bExitLoop ) + { + aBuffer.append( cChar ); + // skip second quote char + if( cChar == '"' ) + ++nIndex; + } + } + } + return aBuffer.makeStringAndClear(); +} + +} // namespace + +// ---------------------------------------------------------------------------- + +VbaUserForm::VbaUserForm( const Reference< XMultiServiceFactory >& rxGlobalFactory, + const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) : + ControlConverter( rGraphicHelper, bDefaultColorBgr ), + mxGlobalFactory( rxGlobalFactory ) +{ + OSL_ENSURE( mxGlobalFactory.is(), "VbaUserForm::VbaUserForm - missing service factory" ); +} + +void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib, + StorageBase& rVbaFormStrg, const OUString& rModuleName, rtl_TextEncoding eTextEnc ) +{ + OSL_ENSURE( rxDialogLib.is(), "VbaUserForm::importForm - missing dialog library" ); + if( !mxGlobalFactory.is() || !rxDialogLib.is() ) + return; + + // check that the '03VBFrame' stream exists, this is required for forms + BinaryXInputStream aInStrm( rVbaFormStrg.openInputStream( CREATE_OUSTRING( "\003VBFrame" ) ), true ); + OSL_ENSURE( !aInStrm.isEof(), "VbaUserForm::importForm - missing \\003VBFrame stream" ); + if( aInStrm.isEof() ) + return; + + // scan for the line 'Begin {GUID} ' + TextInputStream aFrameTextStrm( aInStrm, eTextEnc ); + const OUString aBegin = CREATE_OUSTRING( "Begin" ); + OUString aLine; + bool bBeginFound = false; + while( !bBeginFound && !aFrameTextStrm.isEof() ) + { + aLine = aFrameTextStrm.readLine().trim(); + bBeginFound = VbaHelper::eatKeyword( aLine, aBegin ); + } + // check for the specific GUID that represents VBA forms + if( !bBeginFound || !VbaHelper::eatKeyword( aLine, CREATE_OUSTRING( "{C62A69F0-16DC-11CE-9E98-00AA00574A4F}" ) ) ) + return; + + // remaining line is the form name + OUString aFormName = aLine.trim(); + OSL_ENSURE( aFormName.getLength() > 0, "VbaUserForm::importForm - missing form name" ); + OSL_ENSURE( rModuleName.equalsIgnoreAsciiCase( aFormName ), "VbaUserForm::importFrameStream - form and module name mismatch" ); + if( aFormName.getLength() == 0 ) + aFormName = rModuleName; + if( aFormName.getLength() == 0 ) + return; + mxSiteModel.reset( new VbaSiteModel ); + mxSiteModel->importProperty( XML_Name, aFormName ); + + // read the form properties (caption is contained in this '03VBFrame' stream, not in the 'f' stream) + mxCtrlModel.reset( new AxUserFormModel ); + OUString aKey, aValue; + bool bExitLoop = false; + while( !bExitLoop && !aFrameTextStrm.isEof() ) + { + aLine = aFrameTextStrm.readLine().trim(); + bExitLoop = aLine.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "End" ) ); + if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) ) + { + if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Caption" ) ) ) + mxCtrlModel->importProperty( XML_Caption, lclGetQuotedString( aValue ) ); + else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Tag" ) ) ) + mxSiteModel->importProperty( XML_Tag, lclGetQuotedString( aValue ) ); + } + } + + // use generic container control functionality to import the embedded controls + importStorage( rVbaFormStrg, AxClassTable() ); + + try + { + // create the dialog model + OUString aServiceName = mxCtrlModel->getServiceName(); + Reference< XControlModel > xDialogModel( mxGlobalFactory->createInstance( aServiceName ), UNO_QUERY_THROW ); + Reference< XNameContainer > xDialogNC( xDialogModel, UNO_QUERY_THROW ); + + // convert properties and embedded controls + if( convertProperties( xDialogModel, *this, 0 ) ) + { + // export the dialog to XML and insert it into the dialog library + PropertySet aFactoryProps( mxGlobalFactory ); + Reference< XComponentContext > xCompContext( aFactoryProps.getAnyProperty( PROP_DefaultContext ), UNO_QUERY_THROW ); + Reference< XInputStreamProvider > xDialogSource( ::xmlscript::exportDialogModel( xDialogNC, xCompContext ), UNO_SET_THROW ); + OSL_ENSURE( !rxDialogLib->hasByName( aFormName ), "VbaUserForm::importForm - multiple dialogs with equal name" ); + ContainerHelper::insertByName( rxDialogLib, aFormName, Any( xDialogSource ) ); + } + } + catch( Exception& ) + { + } +} + +// ============================================================================ + +} // namespace ole +} // namespace oox diff --git a/oox/source/ole/vbahelper.cxx b/oox/source/ole/vbahelper.cxx new file mode 100755 index 000000000000..7293e357e746 --- /dev/null +++ b/oox/source/ole/vbahelper.cxx @@ -0,0 +1,248 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/vbahelper.hxx" +#include +#include +#include +#include +#include +#include "oox/helper/binaryinputstream.hxx" + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::container::XNameReplace; +using ::com::sun::star::document::XEventsSupplier; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_SET_THROW; + +namespace oox { +namespace ole { + +// ============================================================================ + +/*static*/ OUString VbaHelper::getBasicScriptUrl( + const OUString& rLibraryName, const OUString& rModuleName, const OUString& rMacroName ) +{ + OSL_ENSURE( rLibraryName.getLength() > 0, "VbaHelper::getBasicScriptUrl - library name is empty" ); + OSL_ENSURE( rModuleName.getLength() > 0, "VbaHelper::getBasicScriptUrl - module name is empty" ); + OSL_ENSURE( rMacroName.getLength() > 0, "VbaHelper::getBasicScriptUrl - macro name is empty" ); + const sal_Unicode cDot = '.'; + return OUStringBuffer(). + appendAscii( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.script:" ) ). + append( rLibraryName ).append( cDot ).append( rModuleName ).append( cDot ).append( rMacroName ). + appendAscii( RTL_CONSTASCII_STRINGPARAM( "?language=Basic&location=document" ) ). + makeStringAndClear(); +} + +/*static*/ bool VbaHelper::readDirRecord( sal_uInt16& rnRecId, StreamDataSequence& rRecData, BinaryInputStream& rInStrm ) +{ + // read the record header + sal_Int32 nRecSize; + rInStrm >> rnRecId >> nRecSize; + // for no obvious reason, PROJECTVERSION record contains size field of 4, but is 6 bytes long + if( rnRecId == VBA_ID_PROJECTVERSION ) + { + OSL_ENSURE( nRecSize == 4, "VbaHelper::readDirRecord - unexpected record size for PROJECTVERSION" ); + nRecSize = 6; + } + // read the record contents into the passed sequence + return !rInStrm.isEof() && (rInStrm.readData( rRecData, nRecSize ) == nRecSize); +} + +/*static*/ bool VbaHelper::extractKeyValue( OUString& rKey, OUString& rValue, const OUString& rKeyValue ) +{ + sal_Int32 nEqSignPos = rKeyValue.indexOf( '=' ); + if( nEqSignPos > 0 ) + { + rKey = rKeyValue.copy( 0, nEqSignPos ).trim(); + rValue = rKeyValue.copy( nEqSignPos + 1 ).trim(); + return (rKey.getLength() > 0) && (rValue.getLength() > 0); + } + return false; +} + +/*static*/ bool VbaHelper::eatWhitespace( OUString& rCodeLine ) +{ + sal_Int32 nIndex = 0; + while( (nIndex < rCodeLine.getLength()) && ((rCodeLine[ nIndex ] == ' ') || (rCodeLine[ nIndex ] == '\t')) ) + ++nIndex; + if( nIndex > 0 ) + { + rCodeLine = rCodeLine.copy( nIndex ); + return true; + } + return false; +} + +/*static*/ bool VbaHelper::eatKeyword( OUString& rCodeLine, const OUString& rKeyword ) +{ + if( rCodeLine.matchIgnoreAsciiCase( rKeyword ) ) + { + rCodeLine = rCodeLine.copy( rKeyword.getLength() ); + // success, if code line ends after keyword, or if whitespace follows + return (rCodeLine.getLength() == 0) || eatWhitespace( rCodeLine ); + } + return false; +} + +/*static*/ OUString VbaHelper::getSourceCode( const Reference< XNameContainer >& rxBasicLib, const OUString& rModuleName ) +{ + OUString aSourceCode; + if( rxBasicLib.is() ) try + { + rxBasicLib->getByName( rModuleName ) >>= aSourceCode; + } + catch( Exception& ) + { + } + return aSourceCode; +} + +namespace { + +bool lclGetLine( OUString& rCodeLine, sal_Int32& rnIndex, const OUString& rSourceCode ) +{ + if( rnIndex < rSourceCode.getLength() ) + { + sal_Int32 nPosLF = rSourceCode.indexOf( '\n', rnIndex ); + if( nPosLF >= rnIndex ) + { + rCodeLine = rSourceCode.copy( rnIndex, nPosLF - rnIndex ).trim(); + rnIndex = nPosLF + 1; + return true; + } + } + return false; +} + +} // namespace + +/*static*/ bool VbaHelper::hasMacro( const OUString& rSourceCode, const OUString& rMacroName ) +{ + // scan all text lines for '[Public|Private] [Static] Sub (...)' + const OUString aPublic = CREATE_OUSTRING( "Public" ); + const OUString aPrivate = CREATE_OUSTRING( "Private" ); + const OUString aStatic = CREATE_OUSTRING( "Static" ); + const OUString aSub = CREATE_OUSTRING( "Sub" ); + + OUString aCodeLine; + sal_Int32 nIndex = 0; + while( lclGetLine( aCodeLine, nIndex, rSourceCode ) ) + { + // eat optional 'Private' or 'Public', but do not accept both keywords in a row (therefore the ||) + eatKeyword( aCodeLine, aPublic ) || eatKeyword( aCodeLine, aPrivate ); + // eat optional 'Static' + eatKeyword( aCodeLine, aStatic ); + // eat 'Sub' keyword, check if macro name follows + if( eatKeyword( aCodeLine, aSub ) && aCodeLine.matchIgnoreAsciiCase( rMacroName ) ) + { + // eat macro name and following whitespace + aCodeLine = aCodeLine.copy( rMacroName.getLength() ); + eatWhitespace( aCodeLine ); + // opening bracket must follow the macro name + if( (aCodeLine.getLength() >= 2) && (aCodeLine[ 0 ] == '(') ) + return true; + } + } + return false; +} + +/*static*/ bool VbaHelper::hasMacro( const Reference< XNameContainer >& rxBasicLib, + const OUString& rModuleName, const OUString& rMacroName ) +{ + return hasMacro( getSourceCode( rxBasicLib, rModuleName ), rMacroName ); +} + +/*static*/ bool VbaHelper::insertMacro( const Reference< XNameContainer >& rxBasicLib, const OUString& rModuleName, + const OUString& rMacroName, const OUString& rMacroArgs, const OUString& rMacroType, const OUString& rMacroCode ) +{ + if( rxBasicLib.is() ) try + { + // receive module source code and check that the specified macro does not exist + OUString aSourceCode = getSourceCode( rxBasicLib, rModuleName ); + if( !hasMacro( aSourceCode, rMacroName ) ) + { + bool bFunction = rMacroType.getLength() > 0; + const sal_Char* pcSubFunc = bFunction ? "Function" : "Sub"; + OUStringBuffer aBuffer( aSourceCode ); + // generate the source code for the new macro + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\nPrivate " ) ). + appendAscii( pcSubFunc ).append( sal_Unicode( ' ' ) ). + append( rMacroName ).append( sal_Unicode( '(' ) ); + if( rMacroArgs.getLength() > 0 ) + aBuffer.append( sal_Unicode( ' ' ) ).append( rMacroArgs ).append( sal_Unicode( ' ' ) ); + aBuffer.append( sal_Unicode( ')' ) ); + if( bFunction ) + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " As " ) ).append( rMacroType ); + aBuffer.append( sal_Unicode( '\n' ) ); + // replace all $MACRO placeholders with macro name + if( rMacroCode.getLength() > 0 ) + { + OUString aMacroCode = ::comphelper::string::searchAndReplaceAsciiL( rMacroCode, RTL_CONSTASCII_STRINGPARAM( "$MACRO" ), rMacroName ); + aBuffer.append( aMacroCode ).append( sal_Unicode( '\n' ) ); + } + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End " ) ).appendAscii( pcSubFunc ).append( sal_Unicode( '\n' ) ); + rxBasicLib->replaceByName( rModuleName, Any( aBuffer.makeStringAndClear() ) ); + return true; + } + } + catch( Exception& ) + { + } + return false; +} + +/*static*/ bool VbaHelper::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, + const OUString& rEventName, const OUString& rLibraryName, const OUString& rModuleName, const OUString& rMacroName ) +{ + if( rxEventsSupp.is() ) try + { + Reference< XNameReplace > xEvents( rxEventsSupp->getEvents(), UNO_SET_THROW ); + Sequence< PropertyValue > aEvent( 2 ); + aEvent[ 0 ].Name = CREATE_OUSTRING( "EventType" ); + aEvent[ 0 ].Value <<= CREATE_OUSTRING( "Script" ); + aEvent[ 1 ].Name = CREATE_OUSTRING( "Script" ); + aEvent[ 1 ].Value <<= getBasicScriptUrl( rLibraryName, rModuleName, rMacroName ); + xEvents->replaceByName( rEventName, Any( aEvent ) ); + return true; + } + catch( Exception& ) + { + } + return false; +} + +// ============================================================================ + +} // namespace ole +} // namespace oox diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx new file mode 100755 index 000000000000..b5319672d538 --- /dev/null +++ b/oox/source/ole/vbamodule.cxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/vbamodule.hxx" +#include +#include +#include +#include +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/storagebase.hxx" +#include "oox/helper/textinputstream.hxx" +#include "oox/ole/vbahelper.hxx" +#include "oox/ole/vbainputstream.hxx" + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::container::XNameAccess; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::script::ModuleInfo; +using ::com::sun::star::script::XVBAModuleInfo; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; + +namespace ApiModuleType = ::com::sun::star::script::ModuleType; + +namespace oox { +namespace ole { + +// ============================================================================ + +VbaModule::VbaModule( const Reference< XModel >& rxDocModel, const OUString& rName, rtl_TextEncoding eTextEnc, bool bExecutable ) : + mxDocModel( rxDocModel ), + maName( rName ), + meTextEnc( eTextEnc ), + mnType( ApiModuleType::Unknown ), + mnOffset( SAL_MAX_UINT32 ), + mbReadOnly( false ), + mbPrivate( false ), + mbExecutable( bExecutable ) +{ +} + +void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) +{ + sal_uInt16 nRecId = 0; + StreamDataSequence aRecData; + while( VbaHelper::readDirRecord( nRecId, aRecData, rDirStrm ) && (nRecId != VBA_ID_MODULEEND) ) + { + SequenceInputStream aRecStrm( aRecData ); + sal_Int32 nRecSize = aRecData.getLength(); + switch( nRecId ) + { +#define OOX_ENSURE_RECORDSIZE( cond ) OSL_ENSURE( cond, "VbaModule::importDirRecords - invalid record size" ) + case VBA_ID_MODULENAME: + OSL_ENSURE( false, "VbaModule::importDirRecords - unexpected MODULENAME record" ); + maName = aRecStrm.readCharArrayUC( nRecSize, meTextEnc ); + break; + case VBA_ID_MODULENAMEUNICODE: + break; + case VBA_ID_MODULESTREAMNAME: + maStreamName = aRecStrm.readCharArrayUC( nRecSize, meTextEnc ); + break; + case VBA_ID_MODULESTREAMNAMEUNICODE: + break; + case VBA_ID_MODULEDOCSTRING: + maDocString = aRecStrm.readCharArrayUC( nRecSize, meTextEnc ); + break; + case VBA_ID_MODULEDOCSTRINGUNICODE: + break; + case VBA_ID_MODULEOFFSET: + OOX_ENSURE_RECORDSIZE( nRecSize == 4 ); + aRecStrm >> mnOffset; + break; + case VBA_ID_MODULEHELPCONTEXT: + OOX_ENSURE_RECORDSIZE( nRecSize == 4 ); + break; + case VBA_ID_MODULECOOKIE: + OOX_ENSURE_RECORDSIZE( nRecSize == 2 ); + break; + case VBA_ID_MODULETYPEPROCEDURAL: + OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); + OSL_ENSURE( mnType == ApiModuleType::Unknown, "VbaModule::importDirRecords - multiple module type records" ); + mnType = ApiModuleType::Normal; + break; + case VBA_ID_MODULETYPEDOCUMENT: + OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); + OSL_ENSURE( mnType == ApiModuleType::Unknown, "VbaModule::importDirRecords - multiple module type records" ); + mnType = ApiModuleType::Document; + break; + case VBA_ID_MODULEREADONLY: + OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); + mbReadOnly = true; + break; + case VBA_ID_MODULEPRIVATE: + OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); + mbPrivate = true; + break; + default: + OSL_ENSURE( false, "VbaModule::importDirRecords - unknown module record" ); +#undef OOX_ENSURE_RECORDSIZE + } + } + OSL_ENSURE( maName.getLength() > 0, "VbaModule::importDirRecords - missing module name" ); + OSL_ENSURE( maStreamName.getLength() > 0, "VbaModule::importDirRecords - missing module stream name" ); + OSL_ENSURE( mnType != ApiModuleType::Unknown, "VbaModule::importDirRecords - missing module type" ); + OSL_ENSURE( mnOffset < SAL_MAX_UINT32, "VbaModule::importDirRecords - missing module stream offset" ); +} + +void VbaModule::importSourceCode( StorageBase& rVbaStrg, + const Reference< XNameContainer >& rxBasicLib, const Reference< XNameAccess >& rxDocObjectNA ) const +{ + if( (maName.getLength() == 0) || (maStreamName.getLength() == 0) || (mnOffset == SAL_MAX_UINT32) ) + return; + + BinaryXInputStream aInStrm( rVbaStrg.openInputStream( maStreamName ), true ); + OSL_ENSURE( !aInStrm.isEof(), "VbaModule::importSourceCode - cannot open module stream" ); + // skip the 'performance cache' stored before the actual source code + aInStrm.seek( mnOffset ); + // if stream is still valid, load the source code + if( aInStrm.isEof() ) + return; + + // prepare the Basic module + ModuleInfo aModuleInfo; + aModuleInfo.ModuleType = mnType; + OUStringBuffer aSourceCode; + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem Attribute VBA_ModuleType=" ) ); + switch( mnType ) + { + case ApiModuleType::Normal: + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAModule" ) ); + break; + case ApiModuleType::Class: + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAClassModule" ) ); + break; + case ApiModuleType::Form: + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAFormModule" ) ); + // hack from old filter, document Basic should know the XModel, but it doesn't + aModuleInfo.ModuleObject.set( mxDocModel, UNO_QUERY ); + break; + case ApiModuleType::Document: + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBADocumentModule" ) ); + // get the VBA object associated to the document module + if( rxDocObjectNA.is() ) try + { + aModuleInfo.ModuleObject.set( rxDocObjectNA->getByName( maName ), UNO_QUERY ); + } + catch( Exception& ) + { + } + break; + default: + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAUnknown" ) ); + } + aSourceCode.append( sal_Unicode( '\n' ) ); + if( mbExecutable ) + { + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option VBASupport 1\n" ) ); + if( mnType == ApiModuleType::Class ) + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option ClassModule\n" ) ); + } + else + { + // add a subroutine named after the module itself + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Sub " ) ). + append( maName.replace( ' ', '_' ) ).append( sal_Unicode( '\n' ) ); + } + + // decompression starts at current stream position of aInStrm + VbaInputStream aVbaStrm( aInStrm ); + // load the source code line-by-line, with some more processing + TextInputStream aVbaTextStrm( aVbaStrm, meTextEnc ); + while( !aVbaTextStrm.isEof() ) + { + OUString aCodeLine = aVbaTextStrm.readLine(); + // skip all 'Attribute' statements + if( !aCodeLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "Attribute " ) ) ) + { + if( !mbExecutable ) + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem " ) ); + aSourceCode.append( aCodeLine ).append( sal_Unicode( '\n' ) ); + } + } + + // close the subroutine named after the module + if( !mbExecutable ) + aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End Sub\n" ) ); + + // insert the module into the passed Basic library + try + { + rxBasicLib->insertByName( maName, Any( aSourceCode.makeStringAndClear() ) ); + } + catch( Exception& ) + { + OSL_ENSURE( false, "VbaModule::importSourceCode - cannot insert module into library" ); + } + + // insert extended module info + try + { + Reference< XVBAModuleInfo > xVBAModuleInfo( rxBasicLib, UNO_QUERY_THROW ); + xVBAModuleInfo->insertModuleInfo( maName, aModuleInfo ); + } + catch( Exception& ) + { + } +} + +// ============================================================================ + +} // namespace ole +} // namespace oox diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx new file mode 100755 index 000000000000..92a556d8b885 --- /dev/null +++ b/oox/source/ole/vbaproject.cxx @@ -0,0 +1,519 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/vbaproject.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "properties.hxx" +#include "tokens.hxx" +#include "oox/helper/binaryinputstream.hxx" +#include "oox/helper/containerhelper.hxx" +#include "oox/helper/propertyset.hxx" +#include "oox/helper/textinputstream.hxx" +#include "oox/ole/olestorage.hxx" +#include "oox/ole/vbacontrol.hxx" +#include "oox/ole/vbahelper.hxx" +#include "oox/ole/vbainputstream.hxx" +#include "oox/ole/vbamodule.hxx" + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::container::XNameAccess; +using ::com::sun::star::container::XNameContainer; +using ::com::sun::star::document::XEventsSupplier; +using ::com::sun::star::document::XStorageBasedDocument; +using ::com::sun::star::embed::XStorage; +using ::com::sun::star::embed::XTransactedObject; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::io::XStream; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::script::XLibraryContainer; +using ::com::sun::star::script::XVBACompat; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::uno::XInterface; +using ::comphelper::ConfigurationHelper; + +namespace ApiModuleType = ::com::sun::star::script::ModuleType; + +namespace oox { +namespace ole { + +// ============================================================================ + +namespace { + +bool lclReadConfigItem( const Reference< XInterface >& rxConfigAccess, const OUString& rItemName ) +{ + // some applications do not support all configuration items, assume 'false' in this case + try + { + Any aItem = ConfigurationHelper::readRelativeKey( rxConfigAccess, CREATE_OUSTRING( "Filter/Import/VBA" ), rItemName ); + return aItem.has< bool >() && aItem.get< bool >(); + } + catch( Exception& ) + { + } + return false; +} + +} // namespace + +// ---------------------------------------------------------------------------- + +VbaFilterConfig::VbaFilterConfig( const Reference< XMultiServiceFactory >& rxGlobalFactory, const OUString& rConfigCompName ) +{ + OSL_ENSURE( rxGlobalFactory.is(), "VbaFilterConfig::VbaFilterConfig - missing service factory" ); + try + { + OSL_ENSURE( rConfigCompName.getLength() > 0, "VbaFilterConfig::VbaFilterConfig - invalid configuration component name" ); + OUString aConfigPackage = CREATE_OUSTRING( "org.openoffice.Office." ) + rConfigCompName; + mxConfigAccess = ConfigurationHelper::openConfig( rxGlobalFactory, aConfigPackage, ConfigurationHelper::E_READONLY ); + } + catch( Exception& ) + { + } + OSL_ENSURE( mxConfigAccess.is(), "VbaFilterConfig::VbaFilterConfig - cannot open configuration" ); +} + +VbaFilterConfig::~VbaFilterConfig() +{ +} + +bool VbaFilterConfig::isImportVba() const +{ + return lclReadConfigItem( mxConfigAccess, CREATE_OUSTRING( "Load" ) ); +} + +bool VbaFilterConfig::isImportVbaExecutable() const +{ + return lclReadConfigItem( mxConfigAccess, CREATE_OUSTRING( "Executable" ) ); +} + +bool VbaFilterConfig::isExportVba() const +{ + return lclReadConfigItem( mxConfigAccess, CREATE_OUSTRING( "Save" ) ); +} + +// ============================================================================ + +VbaProject::VbaProject( const Reference< XMultiServiceFactory >& rxGlobalFactory, + const Reference< XModel >& rxDocModel, const OUString& rConfigCompName ) : + VbaFilterConfig( rxGlobalFactory, rConfigCompName ), + mxGlobalFactory( rxGlobalFactory ), + mxDocModel( rxDocModel ), + maLibName( CREATE_OUSTRING( "Standard" ) ) +{ + OSL_ENSURE( mxDocModel.is(), "VbaProject::VbaProject - missing document model" ); + mxBasicLib = openLibrary( PROP_BasicLibraries, false ); + mxDialogLib = openLibrary( PROP_DialogLibraries, false ); +} + +VbaProject::~VbaProject() +{ +} + +void VbaProject::importVbaProject( StorageBase& rVbaPrjStrg, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) +{ + if( rVbaPrjStrg.isStorage() ) + { + // load the code modules and forms + if( isImportVba() ) + importVba( rVbaPrjStrg, rGraphicHelper, bDefaultColorBgr ); + // copy entire storage into model + if( isExportVba() ) + copyStorage( rVbaPrjStrg ); + } +} + +bool VbaProject::hasModules() const +{ + return mxBasicLib.is() && mxBasicLib->hasElements(); +} + +bool VbaProject::hasModule( const OUString& rModuleName ) const +{ + return mxBasicLib.is() && mxBasicLib->hasByName( rModuleName ); +} + +bool VbaProject::hasDialogs() const +{ + return mxDialogLib.is() && mxDialogLib->hasElements(); +} + +bool VbaProject::hasDialog( const OUString& rDialogName ) const +{ + return mxDialogLib.is() && mxDialogLib->hasByName( rDialogName ); +} + +// Insert VBA code modules and VBA macros into modules ------------------------ + +bool VbaProject::insertMacro( const OUString& rModuleName, + const OUString& rMacroName, const OUString& rMacroArgs, + const OUString& rMacroType, const OUString& rMacroCode ) +{ + return + // do nothing if macros are imported as comments + isImportVbaExecutable() && + // try to insert the macro (will check that the macro does not exist yet) + VbaHelper::insertMacro( mxBasicLib, rModuleName, rMacroName, rMacroArgs, rMacroType, rMacroCode ); +} + +// Attach VBA macros to generic or document events ---------------------------- + +bool VbaProject::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, + const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName ) +{ + return + // do not attach if macros are imported as comments + isImportVbaExecutable() && + // check that the specified macro exists in the module + VbaHelper::hasMacro( mxBasicLib, rModuleName, rMacroName ) && + // attach the macro to the events supplier + VbaHelper::attachMacroToEvent( rxEventsSupp, rEventName, maLibName, rModuleName, rMacroName ); +} + +bool VbaProject::attachMacroToDocumentEvent( const OUString& rEventName, + const OUString& rModuleName, const OUString& rMacroName ) +{ + Reference< XEventsSupplier > xEventsSupp( mxDocModel, UNO_QUERY ); + return attachMacroToEvent( xEventsSupp, rEventName, rModuleName, rMacroName ); +} + +bool VbaProject::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, + const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName, + const OUString& rProxyArgs, const OUString& rProxyType, const OUString& rProxyCode ) +{ + // receive module source code, and check that the specified macro exists in the module + OUString aSourceCode = VbaHelper::getSourceCode( mxBasicLib, rModuleName ); + if( isImportVbaExecutable() && VbaHelper::hasMacro( aSourceCode, rMacroName ) ) + { + // create the name of the proxy macro, and the macro source code + OUString aProxyName = OUStringBuffer( rMacroName ).append( sal_Unicode( '_' ) ). + append( rEventName ).appendAscii( "_Proxy" ).makeStringAndClear(); + // replace $MACRO and $PROXY placeholders in proxy source code + OUString aProxyCode = ::comphelper::string::searchAndReplaceAsciiL( rProxyCode, RTL_CONSTASCII_STRINGPARAM( "$MACRO" ), rMacroName ); + aProxyCode = ::comphelper::string::searchAndReplaceAsciiL( aProxyCode, RTL_CONSTASCII_STRINGPARAM( "$PROXY" ), aProxyName ); + // insert the new macro into the code module and attach it to the event + return + VbaHelper::insertMacro( mxBasicLib, rModuleName, aProxyName, rProxyArgs, rProxyType, aProxyCode ) && + VbaHelper::attachMacroToEvent( rxEventsSupp, rEventName, maLibName, rModuleName, aProxyName ); + } + return false; +} + +bool VbaProject::attachMacroToDocumentEvent( + const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName, + const OUString& rProxyArgs, const OUString& rProxyType, const OUString& rProxyCode ) +{ + Reference< XEventsSupplier > xEventsSupp( mxDocModel, UNO_QUERY ); + return attachMacroToEvent( xEventsSupp, rEventName, rModuleName, rMacroName, rProxyArgs, rProxyType, rProxyCode ); +} + +// private -------------------------------------------------------------------- + +Reference< XLibraryContainer > VbaProject::getLibraryContainer( sal_Int32 nPropId ) +{ + PropertySet aDocProp( mxDocModel ); + Reference< XLibraryContainer > xLibContainer( aDocProp.getAnyProperty( nPropId ), UNO_QUERY ); + return xLibContainer; +} + +Reference< XNameContainer > VbaProject::openLibrary( sal_Int32 nPropId, bool bCreateMissing ) +{ + Reference< XNameContainer > xLibrary; + try + { + Reference< XLibraryContainer > xLibContainer( getLibraryContainer( nPropId ), UNO_SET_THROW ); + if( bCreateMissing && !xLibContainer->hasByName( maLibName ) ) + xLibContainer->createLibrary( maLibName ); + xLibrary.set( xLibContainer->getByName( maLibName ), UNO_QUERY_THROW ); + } + catch( Exception& ) + { + } + OSL_ENSURE( !bCreateMissing || xLibrary.is(), "VbaProject::openLibrary - cannot create library" ); + return xLibrary; +} + +Reference< XNameContainer > VbaProject::createBasicLibrary() +{ + if( !mxBasicLib.is() ) + mxBasicLib = openLibrary( PROP_BasicLibraries, true ); + return mxBasicLib; +} + +Reference< XNameContainer > VbaProject::createDialogLibrary() +{ + if( !mxDialogLib.is() ) + mxDialogLib = openLibrary( PROP_DialogLibraries, true ); + return mxDialogLib; +} + +void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) +{ + StorageRef xVbaStrg = rVbaPrjStrg.openSubStorage( CREATE_OUSTRING( "VBA" ), false ); + OSL_ENSURE( xVbaStrg.get(), "VbaProject::importVba - cannot open 'VBA' substorage" ); + if( !xVbaStrg ) + return; + + /* Read the 'VBA/dir' stream which contains general settings of the VBA + project such as the text encoding used throughout several streams, and + a list of all code modules. + */ + BinaryXInputStream aInStrm( xVbaStrg->openInputStream( CREATE_OUSTRING( "dir" ) ), true ); + // VbaInputStream implements decompression + VbaInputStream aDirStrm( aInStrm ); + OSL_ENSURE( !aDirStrm.isEof(), "VbaProject::importVba - cannot open 'dir' stream" ); + if( aDirStrm.isEof() ) + return; + + // read all records of the directory + rtl_TextEncoding eTextEnc = RTL_TEXTENCODING_MS_1252; + sal_uInt16 nModuleCount = 0; + bool bExecutable = isImportVbaExecutable(); + + typedef RefMap< OUString, VbaModule > VbaModuleMap; + VbaModuleMap aModules, aModulesByStrm; + + sal_uInt16 nRecId = 0; + StreamDataSequence aRecData; + while( VbaHelper::readDirRecord( nRecId, aRecData, aDirStrm ) && (nRecId != VBA_ID_PROJECTEND) ) + { + // create record stream object from imported record data + SequenceInputStream aRecStrm( aRecData ); + sal_Int32 nRecSize = aRecData.getLength(); + switch( nRecId ) + { +#define OOX_ENSURE_RECORDSIZE( cond ) OSL_ENSURE( cond, "VbaProject::importVba - invalid record size" ) + case VBA_ID_PROJECTCODEPAGE: + { + OOX_ENSURE_RECORDSIZE( nRecSize == 2 ); + OSL_ENSURE( aModules.empty(), "VbaProject::importVba - unexpected PROJECTCODEPAGE record" ); + rtl_TextEncoding eNewTextEnc = rtl_getTextEncodingFromWindowsCodePage( aRecStrm.readuInt16() ); + OSL_ENSURE( eNewTextEnc != RTL_TEXTENCODING_DONTKNOW, "VbaProject::importVba - unknown text encoding" ); + if( eNewTextEnc != RTL_TEXTENCODING_DONTKNOW ) + eTextEnc = eNewTextEnc; + } + break; + case VBA_ID_PROJECTMODULES: + OOX_ENSURE_RECORDSIZE( nRecSize == 2 ); + OSL_ENSURE( aModules.empty(), "VbaProject::importVba - unexpected PROJECTMODULES record" ); + aRecStrm >> nModuleCount; + break; + case VBA_ID_MODULENAME: + { + OUString aName = aRecStrm.readCharArrayUC( nRecSize, eTextEnc ); + OSL_ENSURE( aName.getLength() > 0, "VbaProject::importVba - invalid module name" ); + OSL_ENSURE( !aModules.has( aName ), "VbaProject::importVba - multiple modules with the same name" ); + VbaModuleMap::mapped_type& rxModule = aModules[ aName ]; + rxModule.reset( new VbaModule( mxDocModel, aName, eTextEnc, bExecutable ) ); + // read all remaining records until the MODULEEND record + rxModule->importDirRecords( aDirStrm ); + OSL_ENSURE( !aModulesByStrm.has( rxModule->getStreamName() ), "VbaProject::importVba - multiple modules with the same stream name" ); + aModulesByStrm[ rxModule->getStreamName() ] = rxModule; + } + break; +#undef OOX_ENSURE_RECORDSIZE + } + } + OSL_ENSURE( nModuleCount == aModules.size(), "VbaProject::importVba - invalid module count" ); + + /* The directory does not contain the real type of the modules, it + distinguishes only between 'procedural' and 'document' (the latter + includes class and form modules). Now, the exact type of all modules + will be read from the 'PROJECT' stream. It consists of text lines in + 'key=value' format which list the code modules by type. + + - The line 'document=/&HXXXXXXXX' declares document + modules. These are attached to the Word document (usually called + 'ThisDocument'), the Excel workbook (usually called + 'ThisWorkbook'), or single Excel worksheets or chartsheets (usually + called 'SheetX' or 'ChartX', X being a decimal number). Of course, + users may rename all these modules. The slash character separates + an automation server version number (hexadecimal 'XXXXXXXX') from + the module name. + - The line 'Module=' declares common procedural code + modules. + - The line 'Class=' declares a class module. + - The line 'BaseClass=' declares a code module attached + to a user form with the same name. + */ + BinaryXInputStream aPrjStrm( rVbaPrjStrg.openInputStream( CREATE_OUSTRING( "PROJECT" ) ), true ); + OSL_ENSURE( !aPrjStrm.isEof(), "VbaProject::importVba - cannot open 'PROJECT' stream" ); + // do not exit if this stream does not exist, but proceed to load the modules below + if( !aPrjStrm.isEof() ) + { + TextInputStream aPrjTextStrm( aPrjStrm, eTextEnc ); + OUString aKey, aValue; + bool bExitLoop = false; + while( !bExitLoop && !aPrjTextStrm.isEof() ) + { + // read a text line from the stream + OUString aLine = aPrjTextStrm.readLine().trim(); + sal_Int32 nLineLen = aLine.getLength(); + // exit if a subsection starts (section name is given in brackets) + bExitLoop = (nLineLen >= 2) && (aLine[ 0 ] == '[') && (aLine[ nLineLen - 1 ] == ']'); + if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) ) + { + sal_Int32 nType = ApiModuleType::Unknown; + if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Document" ) ) ) + { + nType = ApiModuleType::Document; + // strip automation server version from module names + sal_Int32 nSlashPos = aValue.indexOf( '/' ); + if( nSlashPos >= 0 ) + aValue = aValue.copy( 0, nSlashPos ); + } + else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Module" ) ) ) + nType = ApiModuleType::Normal; + else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Class" ) ) ) + nType = ApiModuleType::Class; + else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "BaseClass" ) ) ) + nType = ApiModuleType::Form; + + if( (nType != ApiModuleType::Unknown) && (aValue.getLength() > 0) ) + { + OSL_ENSURE( aModules.has( aValue ), "VbaProject::importVba - module not found" ); + if( VbaModule* pModule = aModules.get( aValue ).get() ) + pModule->setType( nType ); + } + } + } + } + + /* Now it is time to load the source code. All modules will be inserted + into the Basic library of the document specified by the 'maLibName' + member. Do not create the Basic library, if there are no modules + specified. */ + if( !aModules.empty() ) try + { + // get the basic library + Reference< XNameContainer > xBasicLib( createBasicLibrary(), UNO_SET_THROW ); + + // set library container to VBA compatibility mode + try + { + Reference< XVBACompat >( getLibraryContainer( PROP_BasicLibraries ), UNO_QUERY_THROW )->setVBACompatModeOn( sal_True ); + } + catch( Exception& ) + { + } + + // try to get access to document objects related to code modules + Reference< XNameAccess > xDocObjectNA; + try + { + Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW ); + xDocObjectNA.set( xModelFactory->createInstance( CREATE_OUSTRING( "ooo.vba.VBAObjectModuleObjectProvider" ) ), UNO_QUERY ); + } + catch( Exception& ) + { + // not all documents support this + } + + // call Basic source code import for each module, boost::[c]ref enforces pass-by-ref + if( xBasicLib.is() ) + aModules.forEachMem( &VbaModule::importSourceCode, + ::boost::ref( *xVbaStrg ), ::boost::cref( xBasicLib ), ::boost::cref( xDocObjectNA ) ); + } + catch( Exception& ) + { + } + + /* Load the forms. The file format specification requires that a module + must exist for every form. We are a bit more tolerant and scan the + project storage for all form substorages. This may 'repair' broken VBA + storages that misses to mention a module for an existing form. */ + ::std::vector< OUString > aElements; + rVbaPrjStrg.getElementNames( aElements ); + for( ::std::vector< OUString >::iterator aIt = aElements.begin(), aEnd = aElements.end(); aIt != aEnd; ++aIt ) + { + // try to open the element as storage + if( !aIt->equals( CREATE_OUSTRING( "VBA" ) ) ) + { + StorageRef xSubStrg = rVbaPrjStrg.openSubStorage( *aIt, false ); + if( xSubStrg.get() ) try + { + // resolve module name from storage name (which equals the module stream name) + VbaModule* pModule = aModulesByStrm.get( *aIt ).get(); + OSL_ENSURE( pModule && (pModule->getType() == ApiModuleType::Form), + "VbaProject::importVba - form substorage without form module" ); + OUString aModuleName; + if( pModule ) + aModuleName = pModule->getName(); + + // create and import the form + Reference< XNameContainer > xDialogLib( createDialogLibrary(), UNO_SET_THROW ); + VbaUserForm aForm( mxGlobalFactory, rGraphicHelper, bDefaultColorBgr ); + aForm.importForm( xDialogLib, *xSubStrg, aModuleName, eTextEnc ); + } + catch( Exception& ) + { + } + } + } +} + +void VbaProject::copyStorage( StorageBase& rVbaPrjStrg ) +{ + try + { + Reference< XStorageBasedDocument > xStorageBasedDoc( mxDocModel, UNO_QUERY_THROW ); + Reference< XStorage > xDocStorage( xStorageBasedDoc->getDocumentStorage(), UNO_QUERY_THROW ); + { + using namespace ::com::sun::star::embed::ElementModes; + Reference< XStream > xDocStream( xDocStorage->openStreamElement( CREATE_OUSTRING( "_MS_VBA_Macros" ), SEEKABLE | WRITE | TRUNCATE ), UNO_SET_THROW ); + OleStorage aDestStorage( mxGlobalFactory, xDocStream, false ); + rVbaPrjStrg.copyStorageToStorage( aDestStorage ); + aDestStorage.commit(); + } + Reference< XTransactedObject >( xDocStorage, UNO_QUERY_THROW )->commit(); + } + catch( Exception& ) + { + } +} + +// ============================================================================ + +} // namespace ole +} // namespace oox diff --git a/oox/source/ppt/animvariantcontext.cxx b/oox/source/ppt/animvariantcontext.cxx index ea639c8c6f5c..e2eca9a36dca 100644 --- a/oox/source/ppt/animvariantcontext.cxx +++ b/oox/source/ppt/animvariantcontext.cxx @@ -65,7 +65,7 @@ namespace oox { namespace ppt { { if( ( aElement == mnElement ) && maColor.isUsed() ) { - maValue = makeAny( maColor.getColor( getFilter() ) ); + maValue = makeAny( maColor.getColor( getFilter().getGraphicHelper() ) ); } } diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx index 79341081f1d0..578d469395db 100644 --- a/oox/source/ppt/pptimport.cxx +++ b/oox/source/ppt/pptimport.cxx @@ -29,6 +29,7 @@ #include "oox/drawingml/chart/chartconverter.hxx" #include "oox/dump/pptxdumper.hxx" #include "oox/drawingml/table/tablestylelistfragmenthandler.hxx" +#include "oox/helper/graphichelper.hxx" using ::rtl::OUString; using namespace ::com::sun::star; @@ -150,6 +151,35 @@ const oox::drawingml::table::TableStyleListPtr PowerPointImport::getTableStyles( return *mxChartConv; } +namespace { + +class PptGraphicHelper : public GraphicHelper +{ +public: + explicit PptGraphicHelper( const PowerPointImport& rFilter ); + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; +private: + const PowerPointImport& mrFilter; +}; + +PptGraphicHelper::PptGraphicHelper( const PowerPointImport& rFilter ) : + GraphicHelper( rFilter.getGlobalFactory() ), + mrFilter( rFilter ) +{ +} + +sal_Int32 PptGraphicHelper::getSchemeColor( sal_Int32 nToken ) const +{ + return mrFilter.getSchemeColor( nToken ); +} + +} // namespace + +GraphicHelper* PowerPointImport::implCreateGraphicHelper() const +{ + return new PptGraphicHelper( *this ); +} + OUString PowerPointImport::implGetImplementationName() const { return PowerPointImport_getImplementationName(); diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index c91a1bd1fd79..7c2c4ccfd06d 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -177,7 +177,7 @@ void SlidePersist::createBackground( const XmlFilterBase& rFilterBase ) uno::Reference< beans::XPropertySet > xPagePropSet( mxPage, uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySet > xPropertySet( aPropMap.makePropertySet() ); PropertySet aPropSet( xPropertySet ); - mpBackgroundPropertiesPtr->pushToPropSet( aPropSet, rFilterBase, rFilterBase.getModelObjectHelper() ); + mpBackgroundPropertiesPtr->pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), rFilterBase.getGraphicHelper() ); xPagePropSet->setPropertyValue( sBackground, Any( xPropertySet ) ); } catch( Exception ) diff --git a/oox/source/ppt/timenodelistcontext.cxx b/oox/source/ppt/timenodelistcontext.cxx index 3edca28aecac..7e40e3be4db4 100644 --- a/oox/source/ppt/timenodelistcontext.cxx +++ b/oox/source/ppt/timenodelistcontext.cxx @@ -504,19 +504,13 @@ namespace oox { namespace ppt { NodePropertyMap & pProps(mpNode->getNodeProperties()); pProps[ NP_DIRECTION ] = makeAny( mnDir == XML_cw ); pProps[ NP_COLORINTERPOLATION ] = makeAny( mnColorSpace == XML_hsl ? AnimationColorSpace::HSL : AnimationColorSpace::RGB ); + const GraphicHelper& rGraphicHelper = getFilter().getGraphicHelper(); if( maToClr.isUsed() ) - { - mpNode->setTo( Any( maToClr.getColor( getFilter() ) ) ); - } + mpNode->setTo( Any( maToClr.getColor( rGraphicHelper ) ) ); if( maFromClr.isUsed() ) - { - mpNode->setFrom( Any( maFromClr.getColor( getFilter() ) ) ); - } + mpNode->setFrom( Any( maFromClr.getColor( rGraphicHelper ) ) ); if( mbHasByColor ) - { mpNode->setBy( Any ( m_byColor.get() ) ); - } - } } diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 0ecd40ee6595..655bd40d6e1f 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -15,6 +15,7 @@ Autocomplete BackGraphicLocation BackGraphicURL BackgroundColor +BasicLibraries BlackDay BlockIncrement Border @@ -72,6 +73,7 @@ CharUnderlineHasColor CharWeight CharWeightAsian CharWeightComplex +CodeName Color ColumnGrand ColumnLabelRanges @@ -97,16 +99,19 @@ D3DScenePerspective D3DSceneShadeMode DDELinks DatabaseRanges +DefaultContext DefaultScrollValue DefaultSpinValue DefaultState DefaultText DiagonalBLTR DiagonalTLBR +DialogLibraries DisplayLabels DrillDownOnDoubleClick Dropdown EchoChar +EnableVisible Enabled EndPosition ErrorAlertStyle @@ -173,6 +178,7 @@ HeaderIsDynamicHeight HeaderIsOn HeaderIsShared Height +HelpText HideInactiveSelection HoriJustify HorizontalSplitMode @@ -279,6 +285,8 @@ PositionBottom PositionLeft PositionRight PositionTop +PositionX +PositionY PositiveError Prefix PrintAnnotations @@ -287,6 +295,8 @@ PrintDownFirst PrintGrid PrintHeaders Printable +ProgressValueMax +ProgressValueMin Protected Reference ReferenceDevice @@ -312,6 +322,7 @@ ScaleMode ScaleToPages ScaleToPagesX ScaleToPagesY +ScrollValue ScrollValueMax ScrollValueMin SelectedPage @@ -343,6 +354,7 @@ Sound SoundOn Speed SpinIncrement +SpinValue SpinValueMax SpinValueMin StackCharacters @@ -350,16 +362,21 @@ StackingDirection StartPosition StartWith StartingAngle +State Subtotals Suffix SwapXAndYAxis Symbol SymbolColor +TabIndex TableBorder TableLayout TableSelected Tables +Tabstop +Tag TargetFrame +Text TextAutoGrowHeight TextBreak TextColor @@ -371,6 +388,7 @@ TextRotation TextUpperDistance TextWordWrap TextWritingMode +Title Toggle TokenIndex TopBorder diff --git a/oox/source/vml/vmldrawing.cxx b/oox/source/vml/vmldrawing.cxx index 9c1bb761532a..9a5f4451ec04 100644 --- a/oox/source/vml/vmldrawing.cxx +++ b/oox/source/vml/vmldrawing.cxx @@ -29,7 +29,7 @@ #include #include "tokens.hxx" #include "oox/core/xmlfilterbase.hxx" -#include "oox/ole/axcontrolhelper.hxx" +#include "oox/ole/axcontrol.hxx" #include "oox/vml/vmlshape.hxx" #include "oox/vml/vmlshapecontainer.hxx" @@ -97,15 +97,12 @@ Drawing::~Drawing() { } -::oox::ole::AxControlHelper& Drawing::getControlHelper() const +::oox::ole::EmbeddedForm& Drawing::getControlForm() const { - // create the helper object on demand - if( !mxCtrlHelper.get() ) - { - mxCtrlHelper.reset( createControlHelper() ); - OSL_ENSURE( mxCtrlHelper.get(), "Drawing::getControlHelper - cannot create form controls helper" ); - } - return *mxCtrlHelper; + if( !mxCtrlForm.get() ) + mxCtrlForm.reset( new ::oox::ole::EmbeddedForm( + mrFilter.getModelFactory(), mxDrawPage, mrFilter.getGraphicHelper() ) ); + return *mxCtrlForm; } void Drawing::registerOleObject( const OleObjectInfo& rOleObject ) @@ -158,11 +155,6 @@ void Drawing::convertControlClientData( const Reference< XControlModel >& /*rxCt { } -::oox::ole::AxControlHelper* Drawing::createControlHelper() const -{ - return new ::oox::ole::AxEmbeddedControlHelper( mrFilter, mxDrawPage ); -} - // ============================================================================ } // namespace vml diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index be3f3dd19e8c..6baea708c8a2 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -29,8 +29,8 @@ #include #include "tokens.hxx" #include "oox/token/tokenmap.hxx" +#include "oox/helper/graphichelper.hxx" #include "oox/helper/propertymap.hxx" -#include "oox/core/filterbase.hxx" #include "oox/drawingml/color.hxx" #include "oox/drawingml/drawingmltypes.hxx" #include "oox/drawingml/fillproperties.hxx" @@ -39,7 +39,6 @@ using ::rtl::OStringBuffer; using ::rtl::OUString; using ::com::sun::star::geometry::IntegerRectangle2D; -using ::oox::core::FilterBase; using ::oox::drawingml::Color; using ::oox::drawingml::FillProperties; using ::oox::drawingml::LineArrowProperties; @@ -106,7 +105,7 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r return fDefValue; } -/*static*/ sal_Int32 ConversionHelper::decodeMeasureToEmu( const FilterBase& rFilter, +/*static*/ sal_Int32 ConversionHelper::decodeMeasureToEmu( const GraphicHelper& rGraphicHelper, const OUString& rValue, sal_Int32 nRefValue, bool bPixelX, bool bDefaultAsPixel ) { // default for missing values is 0 @@ -150,7 +149,9 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r else if( (cChar1 == 'p') && (cChar2 == 'c') ) // 1 pica = 1/6 inch = 152,400 EMU fValue *= 152400.0; else if( (cChar1 == 'p') && (cChar2 == 'x') ) // 1 pixel, dependent on output device, factor 360 to convert 1/100mm to EMU - fValue = bPixelX ? rFilter.convertScreenPixelX( 360.0 * fValue ) : rFilter.convertScreenPixelY( 360.0 * fValue ); + fValue = bPixelX ? + rGraphicHelper.convertScreenPixelXToHmm( 360.0 * fValue ) : + rGraphicHelper.convertScreenPixelYToHmm( 360.0 * fValue ); } else if( (aUnit.getLength() == 1) && (aUnit[ 0 ] == '%') ) { @@ -164,10 +165,10 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r return static_cast< sal_Int32 >( fValue + 0.5 ); } -/*static*/ sal_Int32 ConversionHelper::decodeMeasureToHmm( const FilterBase& rFilter, +/*static*/ sal_Int32 ConversionHelper::decodeMeasureToHmm( const GraphicHelper& rGraphicHelper, const OUString& rValue, sal_Int32 nRefValue, bool bPixelX, bool bDefaultAsPixel ) { - return (decodeMeasureToEmu( rFilter, rValue, nRefValue, bPixelX, bDefaultAsPixel ) + 180) / 360; + return (decodeMeasureToEmu( rGraphicHelper, rValue, nRefValue, bPixelX, bDefaultAsPixel ) + 180) / 360; } // ============================================================================ @@ -195,7 +196,7 @@ namespace { specifies the color to be used to resolve the color modifiers used in one-color gradients. */ -void lclGetColor( Color& orDmlColor, const FilterBase& rFilter, +void lclGetColor( Color& orDmlColor, const GraphicHelper& rGraphicHelper, const OptValue< OUString >& roVmlColor, const OptValue< double >& roVmlOpacity, sal_Int32 nDefaultRgb, sal_Int32 nPrimaryRgb = API_RGB_TRANSPARENT ) { @@ -239,7 +240,7 @@ void lclGetColor( Color& orDmlColor, const FilterBase& rFilter, sal_Int32 nColorToken = StaticTokenMap::get().getTokenFromUnicode( aColorName ); sal_Int32 nRgbValue = Color::getVmlPresetColor( nColorToken, API_RGB_TRANSPARENT ); if( nRgbValue == API_RGB_TRANSPARENT ) - nRgbValue = rFilter.getSystemColor( nColorToken, API_RGB_TRANSPARENT ); + nRgbValue = rGraphicHelper.getSystemColor( nColorToken, API_RGB_TRANSPARENT ); if( nRgbValue != API_RGB_TRANSPARENT ) { orDmlColor.setSrgbClr( nRgbValue ); @@ -284,9 +285,9 @@ void lclGetColor( Color& orDmlColor, const FilterBase& rFilter, orDmlColor.setSrgbClr( nDefaultRgb ); } -sal_Int32 lclGetEmu( const FilterBase& rFilter, const OptValue< OUString >& roValue, sal_Int32 nDefValue ) +sal_Int32 lclGetEmu( const GraphicHelper& rGraphicHelper, const OptValue< OUString >& roValue, sal_Int32 nDefValue ) { - return roValue.has() ? ConversionHelper::decodeMeasureToEmu( rFilter, roValue.get(), 0, false, false ) : nDefValue; + return roValue.has() ? ConversionHelper::decodeMeasureToEmu( rGraphicHelper, roValue.get(), 0, false, false ) : nDefValue; } void lclGetDmlLineDash( OptValue< sal_Int32 >& oroPresetDash, LineProperties::DashStopVector& orCustomDash, const OptValue< OUString >& roDashStyle ) @@ -428,7 +429,8 @@ void StrokeModel::assignUsed( const StrokeModel& rSource ) moJoinStyle.assignIfUsed( rSource.moJoinStyle ); } -void StrokeModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter ) const +void StrokeModel::pushToPropMap( PropertyMap& rPropMap, + ModelObjectHelper& rModelObjectHelper, const GraphicHelper& rGraphicHelper ) const { /* Convert VML line formatting to DrawingML line formatting and let the DrawingML code do the hard work. */ @@ -439,8 +441,8 @@ void StrokeModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilte aLineProps.maLineFill.moFillType = XML_solidFill; lclConvertArrow( aLineProps.maStartArrow, maStartArrow ); lclConvertArrow( aLineProps.maEndArrow, maEndArrow ); - lclGetColor( aLineProps.maLineFill.maFillColor, rFilter, moColor, moOpacity, API_RGB_BLACK ); - aLineProps.moLineWidth = lclGetEmu( rFilter, moWeight, 1 ); + lclGetColor( aLineProps.maLineFill.maFillColor, rGraphicHelper, moColor, moOpacity, API_RGB_BLACK ); + aLineProps.moLineWidth = lclGetEmu( rGraphicHelper, moWeight, 1 ); lclGetDmlLineDash( aLineProps.moPresetDash, aLineProps.maCustomDash, moDashStyle ); aLineProps.moLineCompound = lclGetDmlLineCompound( moLineStyle ); aLineProps.moLineCap = lclGetDmlLineCap( moEndCap ); @@ -451,7 +453,7 @@ void StrokeModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilte aLineProps.maLineFill.moFillType = XML_noFill; } - aLineProps.pushToPropMap( rPropMap, rFilter, rFilter.getModelObjectHelper() ); + aLineProps.pushToPropMap( rPropMap, rModelObjectHelper, rGraphicHelper ); } // ============================================================================ @@ -471,7 +473,8 @@ void FillModel::assignUsed( const FillModel& rSource ) moRotate.assignIfUsed( rSource.moRotate ); } -void FillModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter ) const +void FillModel::pushToPropMap( PropertyMap& rPropMap, + ModelObjectHelper& rModelObjectHelper, const GraphicHelper& rGraphicHelper ) const { /* Convert VML fill formatting to DrawingML fill formatting and let the DrawingML code do the hard work. */ @@ -491,8 +494,8 @@ void FillModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter // prepare colors Color aColor1, aColor2; - lclGetColor( aColor1, rFilter, moColor, moOpacity, API_RGB_WHITE ); - lclGetColor( aColor2, rFilter, moColor2, moOpacity2, API_RGB_WHITE, aColor1.getColor( rFilter ) ); + lclGetColor( aColor1, rGraphicHelper, moColor, moOpacity, API_RGB_WHITE ); + lclGetColor( aColor2, rGraphicHelper, moColor2, moOpacity2, API_RGB_WHITE, aColor1.getColor( rGraphicHelper ) ); // type XML_gradient is linear or axial gradient if( nFillType == XML_gradient ) @@ -563,7 +566,7 @@ void FillModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter { aFillProps.moFillType = XML_solidFill; // fill color (default is white) - lclGetColor( aFillProps.maFillColor, rFilter, moColor, moOpacity, API_RGB_WHITE ); + lclGetColor( aFillProps.maFillColor, rGraphicHelper, moColor, moOpacity, API_RGB_WHITE ); } } } @@ -572,7 +575,7 @@ void FillModel::pushToPropMap( PropertyMap& rPropMap, const FilterBase& rFilter aFillProps.moFillType = XML_noFill; } - aFillProps.pushToPropMap( rPropMap, rFilter, rFilter.getModelObjectHelper() ); + aFillProps.pushToPropMap( rPropMap, rModelObjectHelper, rGraphicHelper ); } // ============================================================================ diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 014f1edf4c45..40b3e9952b43 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -195,12 +195,12 @@ Rectangle ShapeType::getRectangle( const ShapeParentAnchor* pParentAnchor ) cons Rectangle ShapeType::getAbsRectangle() const { - const XmlFilterBase& rFilter = mrDrawing.getFilter(); + const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper(); return Rectangle( - ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maLeft, 0, true, true ) + ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maMarginLeft, 0, true, true ), - ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maTop, 0, false, true ) + ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maMarginTop, 0, false, true ), - ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maWidth, 0, true, true ), - ConversionHelper::decodeMeasureToHmm( rFilter, maTypeModel.maHeight, 0, false, true ) ); + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maLeft, 0, true, true ) + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maMarginLeft, 0, true, true ), + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maTop, 0, false, true ) + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maMarginTop, 0, false, true ), + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maWidth, 0, true, true ), + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maHeight, 0, false, true ) ); } Rectangle ShapeType::getRelRectangle() const @@ -305,10 +305,12 @@ Rectangle ShapeBase::calcShapeRectangle( const ShapeParentAnchor* pParentAnchor void ShapeBase::convertShapeProperties( const Reference< XShape >& rxShape ) const { - PropertyMap aPropMap; + ModelObjectHelper& rModelObjectHelper = mrDrawing.getFilter().getModelObjectHelper(); + const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper(); - maTypeModel.maStrokeModel.pushToPropMap( aPropMap, mrDrawing.getFilter() ); - maTypeModel.maFillModel.pushToPropMap( aPropMap, mrDrawing.getFilter() ); + PropertyMap aPropMap; + maTypeModel.maStrokeModel.pushToPropMap( aPropMap, rModelObjectHelper, rGraphicHelper ); + maTypeModel.maFillModel.pushToPropMap( aPropMap, rModelObjectHelper, rGraphicHelper ); PropertySet aPropSet( rxShape ); aPropSet.setProperties( aPropMap ); @@ -440,12 +442,12 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes if( pControlInfo && (pControlInfo->maFragmentPath.getLength() > 0) && (maTypeModel.maName.getLength() > 0) ) { OSL_ENSURE( maTypeModel.maName == pControlInfo->maName, "ComplexShape::implConvertAndInsert - control name mismatch" ); - ::oox::ole::AxControl aControl( maTypeModel.maName ); + ::oox::ole::EmbeddedControl aControl( maTypeModel.maName ); // load the control properties from fragment if( rFilter.importFragment( new ::oox::ole::AxControlFragment( rFilter, pControlInfo->maFragmentPath, aControl ) ) ) try { // create control model and insert it into the form of the draw page - Reference< XControlModel > xCtrlModel( aControl.convertAndInsert( mrDrawing.getControlHelper() ), UNO_SET_THROW ); + Reference< XControlModel > xCtrlModel( mrDrawing.getControlForm().convertAndInsert( aControl ), UNO_SET_THROW ); if( maShapeModel.mxClientData.get() ) mrDrawing.convertControlClientData( xCtrlModel, *maShapeModel.mxClientData ); diff --git a/oox/source/vml/vmlshapecontainer.cxx b/oox/source/vml/vmlshapecontainer.cxx index 6b1711f3c0f9..8e36e4b0054e 100644 --- a/oox/source/vml/vmlshapecontainer.cxx +++ b/oox/source/vml/vmlshapecontainer.cxx @@ -33,7 +33,6 @@ using ::rtl::OUString; using ::com::sun::star::uno::Reference; using ::com::sun::star::awt::Rectangle; using ::com::sun::star::drawing::XShapes; -using ::oox::core::XmlFilterBase; namespace oox { namespace vml { diff --git a/oox/source/xls/biffdetector.cxx b/oox/source/xls/biffdetector.cxx index 82c7cb822d83..fc3e1e710bcb 100644 --- a/oox/source/xls/biffdetector.cxx +++ b/oox/source/xls/biffdetector.cxx @@ -31,7 +31,7 @@ #include #include #include "oox/helper/binaryinputstream.hxx" -#include "oox/helper/olestorage.hxx" +#include "oox/ole/olestorage.hxx" using ::rtl::OUString; using ::rtl::OStringBuffer; @@ -85,7 +85,7 @@ BiffType BiffDetector::detectStreamBiffVersion( BinaryInputStream& rInStream ) if( !rInStream.isEof() && rInStream.isSeekable() && (rInStream.getLength() > 4) ) { sal_Int64 nOldPos = rInStream.tell(); - rInStream.seek( 0 ); + rInStream.seekToStart(); sal_uInt16 nBofId, nBofSize; rInStream >> nBofId >> nBofSize; @@ -211,7 +211,7 @@ OUString SAL_CALL BiffDetector::detect( Sequence< PropertyValue >& rDescriptor ) if( xInStrm.is() ) { OUString aWorkbookName; - StorageRef xStorage( new OleStorage( mxFactory, xInStrm, true ) ); + StorageRef xStorage( new ::oox::ole::OleStorage( mxFactory, xInStrm, true ) ); switch( detectStorageBiffVersion( aWorkbookName, xStorage ) ) { case BIFF2: diff --git a/oox/source/xls/biffhelper.cxx b/oox/source/xls/biffhelper.cxx index f69cac731ee7..68699766804d 100644 --- a/oox/source/xls/biffhelper.cxx +++ b/oox/source/xls/biffhelper.cxx @@ -26,8 +26,8 @@ ************************************************************************/ #include "oox/xls/biffhelper.hxx" -#include #include +#include #include "oox/xls/biffinputstream.hxx" #include "oox/xls/biffoutputstream.hxx" #include "oox/xls/worksheethelper.hxx" @@ -56,69 +56,6 @@ const sal_uInt16 BIFF_IMGDATA_NATIVE = 14; // ---------------------------------------------------------------------------- -static const struct CodePageEntry -{ - sal_uInt16 mnCodePage; - rtl_TextEncoding meTextEnc; -} -spCodePages[] = -{ - { 437, RTL_TEXTENCODING_IBM_437 }, // OEM US -// { 720, RTL_TEXTENCODING_IBM_720 }, // OEM Arabic - { 737, RTL_TEXTENCODING_IBM_737 }, // OEM Greek - { 775, RTL_TEXTENCODING_IBM_775 }, // OEM Baltic - { 850, RTL_TEXTENCODING_IBM_850 }, // OEM Latin I - { 852, RTL_TEXTENCODING_IBM_852 }, // OEM Latin II (Central European) - { 855, RTL_TEXTENCODING_IBM_855 }, // OEM Cyrillic - { 857, RTL_TEXTENCODING_IBM_857 }, // OEM Turkish -// { 858, RTL_TEXTENCODING_IBM_858 }, // OEM Multilingual Latin I with Euro - { 860, RTL_TEXTENCODING_IBM_860 }, // OEM Portugese - { 861, RTL_TEXTENCODING_IBM_861 }, // OEM Icelandic - { 862, RTL_TEXTENCODING_IBM_862 }, // OEM Hebrew - { 863, RTL_TEXTENCODING_IBM_863 }, // OEM Canadian (French) - { 864, RTL_TEXTENCODING_IBM_864 }, // OEM Arabic - { 865, RTL_TEXTENCODING_IBM_865 }, // OEM Nordic - { 866, RTL_TEXTENCODING_IBM_866 }, // OEM Cyrillic (Russian) - { 869, RTL_TEXTENCODING_IBM_869 }, // OEM Greek (Modern) - { 874, RTL_TEXTENCODING_MS_874 }, // MS Windows Thai - { 932, RTL_TEXTENCODING_MS_932 }, // MS Windows Japanese Shift-JIS - { 936, RTL_TEXTENCODING_MS_936 }, // MS Windows Chinese Simplified GBK - { 949, RTL_TEXTENCODING_MS_949 }, // MS Windows Korean (Wansung) - { 950, RTL_TEXTENCODING_MS_950 }, // MS Windows Chinese Traditional BIG5 - { 1200, RTL_TEXTENCODING_DONTKNOW }, // Unicode (BIFF8) - return *_DONTKNOW to preserve old code page - { 1250, RTL_TEXTENCODING_MS_1250 }, // MS Windows Latin II (Central European) - { 1251, RTL_TEXTENCODING_MS_1251 }, // MS Windows Cyrillic - { 1252, RTL_TEXTENCODING_MS_1252 }, // MS Windows Latin I (BIFF4-BIFF8) - { 1253, RTL_TEXTENCODING_MS_1253 }, // MS Windows Greek - { 1254, RTL_TEXTENCODING_MS_1254 }, // MS Windows Turkish - { 1255, RTL_TEXTENCODING_MS_1255 }, // MS Windows Hebrew - { 1256, RTL_TEXTENCODING_MS_1256 }, // MS Windows Arabic - { 1257, RTL_TEXTENCODING_MS_1257 }, // MS Windows Baltic - { 1258, RTL_TEXTENCODING_MS_1258 }, // MS Windows Vietnamese - { 1361, RTL_TEXTENCODING_MS_1361 }, // MS Windows Korean (Johab) - { 10000, RTL_TEXTENCODING_APPLE_ROMAN }, // Apple Roman - { 32768, RTL_TEXTENCODING_APPLE_ROMAN }, // Apple Roman - { 32769, RTL_TEXTENCODING_MS_1252 } // MS Windows Latin I (BIFF2-BIFF3) -}; - -/** Predicate to search by given code page. */ -struct CodePageEntry_CPPred -{ - inline explicit CodePageEntry_CPPred( sal_uInt16 nCodePage ) : mnCodePage( nCodePage ) {} - inline bool operator()( const CodePageEntry& rEntry ) const { return rEntry.mnCodePage == mnCodePage; } - sal_uInt16 mnCodePage; -}; - -/** Predicate to search by given text encoding. */ -struct CodePageEntry_TEPred -{ - inline explicit CodePageEntry_TEPred( rtl_TextEncoding eTextEnc ) : meTextEnc( eTextEnc ) {} - inline bool operator()( const CodePageEntry& rEntry ) const { return rEntry.meTextEnc == meTextEnc; } - rtl_TextEncoding meTextEnc; -}; - -// ---------------------------------------------------------------------------- - bool lclCalcRkFromDouble( sal_Int32& ornRkValue, double fValue ) { // double @@ -193,7 +130,7 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, aOutStrm << sal_uInt16( 0x4D42 ) << nBmpSize << sal_Int32( 0 ) << nOffset; // copy the DIB header - aOutStrm.copyStream( rStrm, nDibHdrSize ); + rStrm.copyToStream( aOutStrm, nDibHdrSize ); nBytes -= nDibHdrSize; /* Excel 3.x and Excel 4.x seem to write broken or out-dated DIB data. @@ -215,8 +152,8 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, aOutStrm.seek( nOutStrmPos ); } - // copy remaining pixel data top output stream - aOutStrm.copyStream( rStrm, nBytes ); + // copy remaining pixel data to output stream + rStrm.copyToStream( aOutStrm, nBytes ); } rStrm.seek( nInStrmPos + nBytes ); } @@ -225,8 +162,6 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, // ============================================================================ -// conversion ----------------------------------------------------------------- - /*static*/ double BiffHelper::calcDoubleFromRk( sal_Int32 nRkValue ) { double fValue = 0.0; @@ -284,24 +219,24 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, /*static*/ rtl_TextEncoding BiffHelper::calcTextEncodingFromCodePage( sal_uInt16 nCodePage ) { - const CodePageEntry* pEntry = ::std::find_if( spCodePages, STATIC_ARRAY_END( spCodePages ), CodePageEntry_CPPred( nCodePage ) ); - if( pEntry == STATIC_ARRAY_END( spCodePages ) ) + // some specials for BIFF + switch( nCodePage ) { - OSL_ENSURE( false, "UnitConverter::calcTextEncodingFromCodePage - unknown code page" ); - return RTL_TEXTENCODING_DONTKNOW; + case 1200: return RTL_TEXTENCODING_DONTKNOW; // BIFF8 Unicode + case 32768: return RTL_TEXTENCODING_APPLE_ROMAN; + case 32769: return RTL_TEXTENCODING_MS_1252; // BIFF2-BIFF3 } - return pEntry->meTextEnc; + + rtl_TextEncoding eTextEnc = rtl_getTextEncodingFromWindowsCodePage( nCodePage ); + OSL_ENSURE( eTextEnc != RTL_TEXTENCODING_DONTKNOW, "BiffHelper::calcTextEncodingFromCodePage - unknown code page" ); + return eTextEnc; } /*static*/ sal_uInt16 BiffHelper::calcCodePageFromTextEncoding( rtl_TextEncoding eTextEnc ) { - const CodePageEntry* pEntry = ::std::find_if( spCodePages, STATIC_ARRAY_END( spCodePages ), CodePageEntry_TEPred( eTextEnc ) ); - if( pEntry == STATIC_ARRAY_END( spCodePages ) ) - { - OSL_ENSURE( false, "UnitConverter::calcCodePageFromTextEncoding - unsupported text encoding" ); - return 1252; - } - return pEntry->mnCodePage; + sal_uInt32 nCodePage = rtl_getWindowsCodePageFromTextEncoding( eTextEnc ); + OSL_ENSURE( (0 < nCodePage) && (nCodePage <= SAL_MAX_UINT16), "BiffHelper::calcCodePageFromTextEncoding - unknown text encoding" ); + return static_cast< sal_uInt16 >( (nCodePage == 0) ? 1252 : nCodePage ); } /*static*/ void BiffHelper::importImgData( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, BiffType eBiff ) diff --git a/oox/source/xls/excelfilter.cxx b/oox/source/xls/excelfilter.cxx index d5627c56b4a3..71475790851f 100644 --- a/oox/source/xls/excelfilter.cxx +++ b/oox/source/xls/excelfilter.cxx @@ -30,6 +30,7 @@ #include "oox/xls/biffdetector.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/excelchartconverter.hxx" +#include "oox/xls/stylesbuffer.hxx" #include "oox/xls/themebuffer.hxx" #include "oox/xls/workbookfragment.hxx" #include "oox/dump/biffdumper.hxx" @@ -56,29 +57,29 @@ namespace xls { // ============================================================================ ExcelFilterBase::ExcelFilterBase() : - mpHelper( 0 ) + mpData( 0 ) { } ExcelFilterBase::~ExcelFilterBase() { - OSL_ENSURE( !mpHelper, "ExcelFilterBase::~ExcelFilterBase - workbook helper not cleared" ); + OSL_ENSURE( !mpData, "ExcelFilterBase::~ExcelFilterBase - workbook data not cleared" ); } -void ExcelFilterBase::setWorkbookHelper( WorkbookHelper& rHelper ) +void ExcelFilterBase::registerWorkbookData( WorkbookData& rData ) { - mpHelper = &rHelper; + mpData = &rData; } -WorkbookHelper& ExcelFilterBase::getWorkbookHelper() const +WorkbookData& ExcelFilterBase::getWorkbookData() const { - OSL_ENSURE( mpHelper, "ExcelFilterBase::getWorkbookHelper - missing workbook helper" ); - return *mpHelper; + OSL_ENSURE( mpData, "ExcelFilterBase::getWorkbookData - missing workbook data" ); + return *mpData; } -void ExcelFilterBase::clearWorkbookHelper() +void ExcelFilterBase::unregisterWorkbookData() { - mpHelper = 0; + mpData = 0; } // ============================================================================ @@ -124,12 +125,7 @@ bool ExcelFilter::importDocument() throw() if( aWorkbookPath.getLength() > 0 ) { WorkbookHelperRoot aHelper( *this ); - if( aHelper.isValid() ) - { - setWorkbookHelper( aHelper ); // needed for callbacks - bRet = importFragment( new OoxWorkbookFragment( aHelper, aWorkbookPath ) ); - clearWorkbookHelper(); - } + bRet = aHelper.isValid() && importFragment( new OoxWorkbookFragment( aHelper, aWorkbookPath ) ); } return bRet; } @@ -139,19 +135,9 @@ bool ExcelFilter::exportDocument() throw() return false; } -sal_Int32 ExcelFilter::getSchemeColor( sal_Int32 nToken ) const -{ - return getWorkbookHelper().getTheme().getColorByToken( nToken ); -} - -sal_Int32 ExcelFilter::getPaletteColor( sal_Int32 nPaletteIdx ) const -{ - return getWorkbookHelper().getStyles().getPaletteColor( nPaletteIdx ); -} - const ::oox::drawingml::Theme* ExcelFilter::getCurrentTheme() const { - return &getWorkbookHelper().getTheme(); + return &WorkbookHelper( getWorkbookData() ).getTheme(); } ::oox::vml::Drawing* ExcelFilter::getVmlDrawing() @@ -166,7 +152,12 @@ const TableStyleListPtr ExcelFilter::getTableStyles() ::oox::drawingml::chart::ChartConverter& ExcelFilter::getChartConverter() { - return getWorkbookHelper().getChartConverter(); + return WorkbookHelper( getWorkbookData() ).getChartConverter(); +} + +GraphicHelper* ExcelFilter::implCreateGraphicHelper() const +{ + return new ExcelGraphicHelper( getWorkbookData() ); } OUString ExcelFilter::implGetImplementationName() const @@ -229,12 +220,7 @@ bool ExcelBiffFilter::importDocument() throw() if( eBiff != BIFF_UNKNOWN ) { WorkbookHelperRoot aHelper( *this, eBiff ); - if( aHelper.isValid() ) - { - setWorkbookHelper( aHelper ); // needed for callbacks - bRet = BiffWorkbookFragment( aHelper, aWorkbookName ).importFragment(); - clearWorkbookHelper(); - } + bRet = aHelper.isValid() && BiffWorkbookFragment( aHelper, aWorkbookName ).importFragment(); } return bRet; } @@ -244,9 +230,9 @@ bool ExcelBiffFilter::exportDocument() throw() return false; } -sal_Int32 ExcelBiffFilter::getPaletteColor( sal_Int32 nPaletteIdx ) const +GraphicHelper* ExcelBiffFilter::implCreateGraphicHelper() const { - return getWorkbookHelper().getStyles().getPaletteColor( nPaletteIdx ); + return new ExcelGraphicHelper( getWorkbookData() ); } OUString ExcelBiffFilter::implGetImplementationName() const diff --git a/oox/source/xls/excelvbaproject.cxx b/oox/source/xls/excelvbaproject.cxx new file mode 100755 index 000000000000..fc3caf7e59aa --- /dev/null +++ b/oox/source/xls/excelvbaproject.cxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/xls/excelvbaproject.hxx" +#include +#include +#include +#include +#include +#include "properties.hxx" +#include "oox/helper/helper.hxx" +#include "oox/helper/propertyset.hxx" + +using ::rtl::OUString; +using ::com::sun::star::container::XEnumeration; +using ::com::sun::star::container::XEnumerationAccess; +using ::com::sun::star::document::XEventsSupplier; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::sheet::XSpreadsheetDocument; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; + +namespace oox { +namespace xls { + +// ============================================================================ + +VbaProject::VbaProject( const Reference< XMultiServiceFactory >& rxGlobalFactory, const Reference< XSpreadsheetDocument >& rxDocument ) : + ::oox::ole::VbaProject( rxGlobalFactory, Reference< XModel >( rxDocument, UNO_QUERY ), CREATE_OUSTRING( "Calc" ) ), + mxDocument( rxDocument ) +{ +} + +void VbaProject::attachToEvents() +{ + // do nothing is code is not executable + if( !isImportVbaExecutable() ) + return; + + // document events + PropertySet aDocProp( mxDocument ); + OUString aCodeName; + aDocProp.getProperty( aCodeName, PROP_CodeName ); + attachToDocumentEvents( aCodeName ); + + // sheet events + if( mxDocument.is() ) try + { + Reference< XEnumerationAccess > xSheetsEA( mxDocument->getSheets(), UNO_QUERY_THROW ); + Reference< XEnumeration > xSheetsEnum( xSheetsEA->createEnumeration(), UNO_SET_THROW ); + // own try/catch for every sheet + while( xSheetsEnum->hasMoreElements() ) try + { + // TODO: once we have chart sheets we need a switch/case on sheet type + Reference< XEventsSupplier > xEventsSupp( xSheetsEnum->nextElement(), UNO_QUERY_THROW ); + PropertySet aSheetProp( xEventsSupp ); + aSheetProp.getProperty( aCodeName, PROP_CodeName ); + attachToSheetEvents( xEventsSupp, aCodeName ); + } + catch( Exception& ) + { + } + } + catch( Exception& ) + { + } +} + +// private -------------------------------------------------------------------- + +void VbaProject::attachToDocumentEvents( const OUString& rCodeName ) +{ + if( (rCodeName.getLength() == 0) || !hasModule( rCodeName ) ) + return; + + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnLoad" ), rCodeName, CREATE_OUSTRING( "Workbook_Open" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnFocus" ), rCodeName, CREATE_OUSTRING( "Workbook_Activate" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnUnfocus" ), rCodeName, CREATE_OUSTRING( "Workbook_Deactivate" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSave" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False, False" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAs" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True, False" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveDone" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAsDone" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveFailed" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAsFailed" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnPrint" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforePrint" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); + attachMacroToDocumentEvent( CREATE_OUSTRING( "OnPrepareUnload" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeClose" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); +} + +void VbaProject::attachToSheetEvents( const Reference< XEventsSupplier >& rxEventsSupp, const OUString& rCodeName ) +{ + if( !rxEventsSupp.is() || (rCodeName.getLength() == 0) || !hasModule( rCodeName ) ) + return; + + // attach macros to simple sheet events directly + attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnFocus" ), rCodeName, CREATE_OUSTRING( "Worksheet_Activate" ) ); + attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnUnfocus" ), rCodeName, CREATE_OUSTRING( "Worksheet_Deactivate" ) ); + attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnCalculate" ), rCodeName, CREATE_OUSTRING( "Worksheet_Calculate" ) ); + + /* Attach macros to complex sheet events. The events pass a cell range or + a collection of cell ranges depending on the event type and sheet + selection. The generated proxy macros need to convert these UNO renges + to VBA compatible ranges. + */ + +#define VBA_MACRONAME_RANGECONV "Local_GetVbaRangeFromUnoRange" +#define VBA_MACRONAME_TARGETCONV "Local_GetVbaTargetFromUnoTarget" + + /* If this variable turns to true, the macros that convert UNO cell ranges + to VBA Range objects have to be inserted. + */ + bool bNeedsTargetHelper = false; + + /* Insert the proxy macros attached to sheet events that notify something + has changed (changed selection and changed cell contents). These events + cannot be cancelled. The proxy macro converts the passed UNO cell range + or collection of cell ranges to a VBA Range object, and calls the VBA + event handler. + */ + OUString aChangeProxyArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); + OUString aChangeProxyCode = CREATE_OUSTRING( + "\tDim vbaTarget As Range : Set vbaTarget = " VBA_MACRONAME_TARGETCONV "( unoTarget )\n" + "\tIf Not vbaTarget Is Nothing Then $MACRO vbaTarget" ); + bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnChange" ), rCodeName, CREATE_OUSTRING( "Worksheet_Change" ), aChangeProxyArgs, OUString(), aChangeProxyCode ); + bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnSelect" ), rCodeName, CREATE_OUSTRING( "Worksheet_SelectionChange" ), aChangeProxyArgs, OUString(), aChangeProxyCode ); + + /* Insert the proxy macros attached to sheet events that notify an ongoing + mouse click event (double click and right click). These events can be + cancelled by returning false (in VBA: as a Boolean output parameter, in + UNO: as return value of the Basic function). The proxy macro converts + the passed UNO cell range or collection of cell ranges to a VBA Range + object, calls the VBA event handler, and returns the Boolean value + provided by the VBA event handler. + */ + OUString aClickProxyArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); + OUString aClickProxyRetT = CREATE_OUSTRING( "Boolean" ); + OUString aClickProxyCode = CREATE_OUSTRING( + "\tDim Cancel As Boolean : Cancel = False\n" + "\tDim vbaTarget As Range : Set vbaTarget = " VBA_MACRONAME_TARGETCONV "( unoTarget )\n" + "\tIf Not vbaTarget Is Nothing Then $MACRO vbaTarget, Cancel\n" + "\t$PROXY = Cancel" ); + bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnDoubleClick" ), rCodeName, CREATE_OUSTRING( "Worksheet_BeforeDoubleClick" ), aClickProxyArgs, aClickProxyRetT, aClickProxyCode ); + bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnRightClick" ), rCodeName, CREATE_OUSTRING( "Worksheet_BeforeRightClick" ), aClickProxyArgs, aClickProxyRetT, aClickProxyCode ); + + if( bNeedsTargetHelper ) + { + /* Generate a helper function that converts a + com.sun.star.sheet.SheetCellRange object to a VBA Range object. + */ + OUString aRangeConvName = CREATE_OUSTRING( VBA_MACRONAME_RANGECONV ); + OUString aRangeConvArgs = CREATE_OUSTRING( "ByVal unoRange As com.sun.star.sheet.SheetCellRange" ); + OUString aRangeConvRetT = CREATE_OUSTRING( "Range" ); + OUString aRangeConvCode = CREATE_OUSTRING( + "\tDim unoAddress As com.sun.star.table.CellRangeAddress : Set unoAddress = unoRange.RangeAddress\n" + "\tDim vbaSheet As Worksheet : Set vbaSheet = Application.ThisWorkbook.Sheets( unoAddress.Sheet + 1 )\n" + "\tSet $MACRO = vbaSheet.Range( vbaSheet.Cells( unoAddress.StartRow + 1, unoAddress.StartColumn + 1 ), vbaSheet.Cells( unoAddress.EndRow + 1, unoAddress.EndColumn + 1 ) )" ); + insertMacro( rCodeName, aRangeConvName, aRangeConvArgs, aRangeConvRetT, aRangeConvCode ); + + /* Generate a helper function that converts a generic range selection + object (com.sun.star.sheet.SheetCellRange or + com.sun.star.sheet.SheetCellRanges) to a VBA Range object. + */ + OUString aTargetConvName = CREATE_OUSTRING( VBA_MACRONAME_TARGETCONV ); + OUString aTargetConvArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); + OUString aTargetConvRetT = CREATE_OUSTRING( "Range" ); + OUString aTargetConvCode = CREATE_OUSTRING( + "\tDim vbaTarget As Range\n" + "\tIf unoTarget.supportsService( \"com.sun.star.sheet.SheetCellRange\" ) Then\n" + "\t\tSet vbaTarget = " VBA_MACRONAME_RANGECONV "( unoTarget )\n" + "\tElseIf unoTarget.supportsService( \"com.sun.star.sheet.SheetCellRanges\" ) Then\n" + "\t\tDim unoRangeEnum As Object : Set unoRangeEnum = unoTarget.createEnumeration\n" + "\t\tIf unoRangeEnum.hasMoreElements Then Set vbaTarget = " VBA_MACRONAME_RANGECONV "( unoRangeEnum.nextElement )\n" + "\t\tWhile unoRangeEnum.hasMoreElements\n" + "\t\t\tSet vbaTarget = Application.Union( vbaTarget, " VBA_MACRONAME_RANGECONV "( unoRangeEnum.nextElement ) )\n" + "\t\tWend\n" + "\tEnd If\n" + "\tSet $MACRO = vbaTarget" ); + insertMacro( rCodeName, aTargetConvName, aTargetConvArgs, aTargetConvRetT, aTargetConvCode ); + } +#undef VBA_MACRONAME_RANGECONV +#undef VBA_MACRONAME_TARGETCONV +} + +// ============================================================================ + +} // namespace xls +} // namespace oox diff --git a/oox/source/xls/formulaparser.cxx b/oox/source/xls/formulaparser.cxx index c0337444f59d..12deadecd695 100644 --- a/oox/source/xls/formulaparser.cxx +++ b/oox/source/xls/formulaparser.cxx @@ -2751,19 +2751,16 @@ FormulaParser::~FormulaParser() void FormulaParser::importFormula( FormulaContext& rContext, const OUString& rFormulaString ) const { - OOX_LOADSAVE_TIMER( IMPORTFORMULA ); mxImpl->importOoxFormula( rContext, rFormulaString ); } void FormulaParser::importFormula( FormulaContext& rContext, RecordInputStream& rStrm ) const { - OOX_LOADSAVE_TIMER( IMPORTFORMULA ); mxImpl->importOobFormula( rContext, rStrm ); } void FormulaParser::importFormula( FormulaContext& rContext, BiffInputStream& rStrm, const sal_uInt16* pnFmlaSize ) const { - OOX_LOADSAVE_TIMER( IMPORTFORMULA ); mxImpl->importBiffFormula( rContext, rStrm, pnFmlaSize ); } diff --git a/oox/source/xls/makefile.mk b/oox/source/xls/makefile.mk index cdb2e18c262d..b5ede953bbfe 100644 --- a/oox/source/xls/makefile.mk +++ b/oox/source/xls/makefile.mk @@ -59,6 +59,7 @@ SLOFILES = \ $(SLO)$/excelchartconverter.obj \ $(SLO)$/excelfilter.obj \ $(SLO)$/excelhandlers.obj \ + $(SLO)$/excelvbaproject.obj \ $(SLO)$/externallinkbuffer.obj \ $(SLO)$/externallinkfragment.obj \ $(SLO)$/formulabase.obj \ diff --git a/oox/source/xls/sheetdatacontext.cxx b/oox/source/xls/sheetdatacontext.cxx index be5644554d6d..43c2f1b0b654 100644 --- a/oox/source/xls/sheetdatacontext.cxx +++ b/oox/source/xls/sheetdatacontext.cxx @@ -171,7 +171,6 @@ OoxSheetDataContext::OoxSheetDataContext( OoxWorksheetFragmentBase& rFragment ) ContextHandlerRef OoxSheetDataContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) { - OOX_LOADSAVE_TIMER( ONCREATESHEETCONTEXT ); switch( getCurrentElement() ) { case XLS_TOKEN( sheetData ): @@ -201,7 +200,6 @@ ContextHandlerRef OoxSheetDataContext::onCreateContext( sal_Int32 nElement, cons void OoxSheetDataContext::onEndElement( const OUString& rChars ) { - OOX_LOADSAVE_TIMER( ONENDSHEETELEMENT ); switch( getCurrentElement() ) { case XLS_TOKEN( v ): @@ -342,7 +340,6 @@ ContextHandlerRef OoxSheetDataContext::onCreateRecordContext( sal_Int32 nRecId, void OoxSheetDataContext::importRow( const AttributeList& rAttribs ) { - OOX_LOADSAVE_TIMER( IMPORTROW ); RowModel aModel; aModel.mnFirstRow = aModel.mnLastRow = rAttribs.getInteger( XML_r, -1 ); aModel.mfHeight = rAttribs.getDouble( XML_ht, -1.0 ); @@ -361,7 +358,6 @@ void OoxSheetDataContext::importRow( const AttributeList& rAttribs ) void OoxSheetDataContext::importCell( const AttributeList& rAttribs ) { - OOX_LOADSAVE_TIMER( IMPORTCELL ); maCurrCell.reset(); maCurrCell.mxCell = getCell( rAttribs.getString( XML_r, OUString() ), &maCurrCell.maAddress ); maCurrCell.mnCellType = rAttribs.getToken( XML_t, XML_n ); diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx index 3eac90040667..e18f47a378ed 100644 --- a/oox/source/xls/stylesbuffer.cxx +++ b/oox/source/xls/stylesbuffer.cxx @@ -94,10 +94,6 @@ const sal_Int32 OOX_FONTFAMILY_MODERN = 3; const sal_Int32 OOX_FONTFAMILY_SCRIPT = 4; const sal_Int32 OOX_FONTFAMILY_DECORATIVE = 5; -// OOX font charset (also used in BIFF) -const sal_Int32 OOX_FONTCHARSET_UNUSED = -1; -const sal_Int32 OOX_FONTCHARSET_ANSI = 0; - // OOX cell text direction (also used in BIFF) const sal_Int32 OOX_XF_TEXTDIR_CONTEXT = 0; const sal_Int32 OOX_XF_TEXTDIR_LTR = 1; @@ -306,7 +302,27 @@ sal_Int32 lclReadRgbColor( BinaryInputStream& rStrm ) } // namespace -// ---------------------------------------------------------------------------- +// ============================================================================ + +ExcelGraphicHelper::ExcelGraphicHelper( const WorkbookHelper& rHelper ) : + GraphicHelper( rHelper.getGlobalFactory() ), + WorkbookHelper( rHelper ) +{ +} + +sal_Int32 ExcelGraphicHelper::getSchemeColor( sal_Int32 nToken ) const +{ + if( getFilterType() == FILTER_OOX ) + return getTheme().getColorByToken( nToken ); + return GraphicHelper::getSchemeColor( nToken ); +} + +sal_Int32 ExcelGraphicHelper::getPaletteColor( sal_Int32 nPaletteIdx ) const +{ + return getStyles().getPaletteColor( nPaletteIdx ); +} + +// ============================================================================ void Color::setAuto() { @@ -539,15 +555,15 @@ sal_Int32 ColorPalette::getColor( sal_Int32 nPaletteIdx ) const { case OOX_COLOR_WINDOWTEXT3: case OOX_COLOR_WINDOWTEXT: - case OOX_COLOR_CHWINDOWTEXT: nColor = getBaseFilter().getSystemColor( XML_windowText ); break; + case OOX_COLOR_CHWINDOWTEXT: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_windowText ); break; case OOX_COLOR_WINDOWBACK3: case OOX_COLOR_WINDOWBACK: - case OOX_COLOR_CHWINDOWBACK: nColor = getBaseFilter().getSystemColor( XML_window ); break; - case OOX_COLOR_BUTTONBACK: nColor = getBaseFilter().getSystemColor( XML_btnFace ); break; - case OOX_COLOR_CHBORDERAUTO: nColor = API_RGB_BLACK; /* really always black? */ break; - case OOX_COLOR_NOTEBACK: nColor = getBaseFilter().getSystemColor( XML_infoBk ); break; - case OOX_COLOR_NOTETEXT: nColor = getBaseFilter().getSystemColor( XML_infoText ); break; - case OOX_COLOR_FONTAUTO: nColor = API_RGB_TRANSPARENT; break; + case OOX_COLOR_CHWINDOWBACK: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_window ); break; + case OOX_COLOR_BUTTONBACK: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_btnFace ); break; + case OOX_COLOR_CHBORDERAUTO: nColor = API_RGB_BLACK; /* really always black? */ break; + case OOX_COLOR_NOTEBACK: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_infoBk ); break; + case OOX_COLOR_NOTETEXT: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_infoText ); break; + case OOX_COLOR_FONTAUTO: nColor = API_RGB_TRANSPARENT; break; default: OSL_ENSURE( false, "ColorPalette::getColor - unknown color index" ); } return nColor; @@ -572,7 +588,8 @@ void lclSetFontName( ApiScriptFontName& rFontName, const FontDescriptor& rFontDe { rFontName.maName = rFontDesc.Name; rFontName.mnFamily = rFontDesc.Family; - rFontName.mnCharSet = rFontDesc.CharSet; + // API font descriptor contains rtl_TextEncoding constants + rFontName.mnTextEnc = rFontDesc.CharSet; } else { @@ -587,7 +604,7 @@ void lclSetFontName( ApiScriptFontName& rFontName, const FontDescriptor& rFontDe FontModel::FontModel() : mnScheme( XML_none ), mnFamily( OOX_FONTFAMILY_NONE ), - mnCharSet( OOX_FONTCHARSET_ANSI ), + mnCharSet( WINDOWS_CHARSET_DEFAULT ), mfHeight( 0.0 ), mnUnderline( XML_none ), mnEscapement( XML_baseline ), @@ -655,7 +672,7 @@ ApiFontUsedFlags::ApiFontUsedFlags( bool bAllUsed ) : ApiScriptFontName::ApiScriptFontName() : mnFamily( ::com::sun::star::awt::FontFamily::DONTKNOW ), - mnCharSet( RTL_TEXTENCODING_DONTKNOW ) + mnTextEnc( RTL_TEXTENCODING_DONTKNOW ) { } @@ -977,13 +994,13 @@ void Font::finalizeImport() case OOX_FONTFAMILY_DECORATIVE: maApiData.maDesc.Family = cssawt::FontFamily::DECORATIVE; break; } - // character set - if( (0 <= maModel.mnCharSet) && (maModel.mnCharSet <= 255) ) + // character set (API font descriptor uses rtl_TextEncoding in member CharSet!) + if( (0 <= maModel.mnCharSet) && (maModel.mnCharSet <= SAL_MAX_UINT8) ) maApiData.maDesc.CharSet = static_cast< sal_Int16 >( rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maModel.mnCharSet ) ) ); // color, height, weight, slant, strikeout, outline, shadow - maApiData.mnColor = maModel.maColor.getColor( getBaseFilter() ); + maApiData.mnColor = maModel.maColor.getColor( getBaseFilter().getGraphicHelper() ); maApiData.maDesc.Height = static_cast< sal_Int16 >( maModel.mfHeight * 20.0 ); maApiData.maDesc.Weight = maModel.mbBold ? cssawt::FontWeight::BOLD : cssawt::FontWeight::NORMAL; maApiData.maDesc.Slant = maModel.mbItalic ? cssawt::FontSlant_ITALIC : cssawt::FontSlant_NONE; @@ -1084,19 +1101,19 @@ void Font::writeToPropertyMap( PropertyMap& rPropMap, FontPropertyType ePropType { rPropMap[ PROP_CharFontName ] <<= maApiData.maLatinFont.maName; rPropMap[ PROP_CharFontFamily ] <<= maApiData.maLatinFont.mnFamily; - rPropMap[ PROP_CharFontCharSet ] <<= maApiData.maLatinFont.mnCharSet; + rPropMap[ PROP_CharFontCharSet ] <<= maApiData.maLatinFont.mnTextEnc; } if( maApiData.maAsianFont.maName.getLength() > 0 ) { rPropMap[ PROP_CharFontNameAsian ] <<= maApiData.maAsianFont.maName; rPropMap[ PROP_CharFontFamilyAsian ] <<= maApiData.maAsianFont.mnFamily; - rPropMap[ PROP_CharFontCharSetAsian ] <<= maApiData.maAsianFont.mnCharSet; + rPropMap[ PROP_CharFontCharSetAsian ] <<= maApiData.maAsianFont.mnTextEnc; } if( maApiData.maCmplxFont.maName.getLength() > 0 ) { rPropMap[ PROP_CharFontNameComplex ] <<= maApiData.maCmplxFont.maName; rPropMap[ PROP_CharFontFamilyComplex ] <<= maApiData.maCmplxFont.mnFamily; - rPropMap[ PROP_CharFontCharSetComplex ] <<= maApiData.maCmplxFont.mnCharSet; + rPropMap[ PROP_CharFontCharSetComplex ] <<= maApiData.maCmplxFont.mnTextEnc; } } // font height @@ -1159,7 +1176,7 @@ void Font::importFontData2( BiffInputStream& rStrm ) maModel.setBiffHeight( nHeight ); maModel.mnFamily = OOX_FONTFAMILY_NONE; - maModel.mnCharSet = OOX_FONTCHARSET_UNUSED; // ensure to not use font charset in byte string import + maModel.mnCharSet = -1; // ensure to not use font charset in byte string import maModel.mnUnderline = getFlagValue( nFlags, BIFF_FONTFLAG_UNDERLINE, XML_single, XML_none ); maModel.mnEscapement = XML_none; maModel.mbBold = getFlag( nFlags, BIFF_FONTFLAG_BOLD ); @@ -1720,7 +1737,7 @@ BorderLineModel* Border::getBorderLine( sal_Int32 nElement ) bool Border::convertBorderLine( BorderLine& rBorderLine, const BorderLineModel& rModel ) { - rBorderLine.Color = rModel.maColor.getColor( getBaseFilter(), API_RGB_BLACK ); + rBorderLine.Color = rModel.maColor.getColor( getBaseFilter().getGraphicHelper(), API_RGB_BLACK ); switch( rModel.mnStyle ) { case XML_dashDot: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break; @@ -2016,7 +2033,7 @@ void Fill::importCfRule( BiffInputStream& rStrm, sal_uInt32 nFlags ) void Fill::finalizeImport() { - const FilterBase& rFilter = getBaseFilter(); + const GraphicHelper& rGraphicHelper = getBaseFilter().getGraphicHelper(); if( mxPatternModel.get() ) { @@ -2068,16 +2085,16 @@ void Fill::finalizeImport() case XML_solid: nAlpha = 0x80; break; } - sal_Int32 nWinTextColor = rFilter.getSystemColor( XML_windowText ); - sal_Int32 nWinColor = rFilter.getSystemColor( XML_window ); + sal_Int32 nWinTextColor = rGraphicHelper.getSystemColor( XML_windowText ); + sal_Int32 nWinColor = rGraphicHelper.getSystemColor( XML_window ); if( !rModel.mbPattColorUsed ) rModel.maPatternColor.setAuto(); - sal_Int32 nPattColor = rModel.maPatternColor.getColor( rFilter, nWinTextColor ); + sal_Int32 nPattColor = rModel.maPatternColor.getColor( rGraphicHelper, nWinTextColor ); if( !rModel.mbFillColorUsed ) rModel.maFillColor.setAuto(); - sal_Int32 nFillColor = rModel.maFillColor.getColor( rFilter, nWinColor ); + sal_Int32 nFillColor = rModel.maFillColor.getColor( rGraphicHelper, nWinColor ); maApiData.mnColor = lclGetMixedColor( nPattColor, nFillColor, nAlpha ); maApiData.mbTransparent = false; @@ -2089,11 +2106,11 @@ void Fill::finalizeImport() maApiData.mbUsed = true; // no support for differential attributes GradientFillModel::ColorMap::const_iterator aIt = rModel.maColors.begin(); OSL_ENSURE( !aIt->second.isAuto(), "Fill::finalizeImport - automatic gradient color" ); - maApiData.mnColor = aIt->second.getColor( rFilter, API_RGB_WHITE ); + maApiData.mnColor = aIt->second.getColor( rGraphicHelper, API_RGB_WHITE ); if( ++aIt != rModel.maColors.end() ) { OSL_ENSURE( !aIt->second.isAuto(), "Fill::finalizeImport - automatic gradient color" ); - sal_Int32 nEndColor = aIt->second.getColor( rFilter, API_RGB_WHITE ); + sal_Int32 nEndColor = aIt->second.getColor( rGraphicHelper, API_RGB_WHITE ); maApiData.mnColor = lclGetMixedColor( maApiData.mnColor, nEndColor, 0x40 ); maApiData.mbTransparent = false; } diff --git a/oox/source/xls/unitconverter.cxx b/oox/source/xls/unitconverter.cxx index 6f287581c854..170a1f66f2e2 100644 --- a/oox/source/xls/unitconverter.cxx +++ b/oox/source/xls/unitconverter.cxx @@ -108,7 +108,7 @@ UnitConverter::UnitConverter( const WorkbookHelper& rHelper ) : mnNullDate( lclGetDays( Date( 30, 12, 1899 ) ) ) { // initialize constant and default coefficients - const DeviceInfo& rDeviceInfo = getBaseFilter().getDeviceInfo(); + const DeviceInfo& rDeviceInfo = getBaseFilter().getGraphicHelper().getDeviceInfo(); maCoeffs[ UNIT_INCH ] = MM100_PER_INCH; maCoeffs[ UNIT_POINT ] = MM100_PER_POINT; maCoeffs[ UNIT_TWIP ] = MM100_PER_TWIP; diff --git a/oox/source/xls/viewsettings.cxx b/oox/source/xls/viewsettings.cxx index 69af326c2471..3d88e64dbb12 100644 --- a/oox/source/xls/viewsettings.cxx +++ b/oox/source/xls/viewsettings.cxx @@ -199,7 +199,7 @@ sal_Int32 SheetViewModel::getPageBreakZoom() const sal_Int32 SheetViewModel::getGridColor( const FilterBase& rFilter ) const { - return mbDefGridColor ? API_RGB_TRANSPARENT : maGridColor.getColor( rFilter ); + return mbDefGridColor ? API_RGB_TRANSPARENT : maGridColor.getColor( rFilter.getGraphicHelper() ); } const PaneSelectionModel* SheetViewModel::getPaneSelection( sal_Int32 nPaneId ) const diff --git a/oox/source/xls/workbookfragment.cxx b/oox/source/xls/workbookfragment.cxx index e61820a2e620..b5eb9a11dd2c 100644 --- a/oox/source/xls/workbookfragment.cxx +++ b/oox/source/xls/workbookfragment.cxx @@ -31,10 +31,13 @@ #include "oox/helper/progressbar.hxx" #include "oox/helper/propertyset.hxx" #include "oox/helper/recordinputstream.hxx" +#include "oox/ole/olestorage.hxx" +#include "oox/core/filterbase.hxx" #include "oox/drawingml/themefragmenthandler.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/chartsheetfragment.hxx" #include "oox/xls/connectionsfragment.hxx" +#include "oox/xls/excelvbaproject.hxx" #include "oox/xls/externallinkbuffer.hxx" #include "oox/xls/externallinkfragment.hxx" #include "oox/xls/pivotcachebuffer.hxx" @@ -53,6 +56,8 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::io::XInputStream; using ::com::sun::star::table::CellAddress; using ::oox::core::ContextHandlerRef; using ::oox::core::FragmentHandlerRef; @@ -284,13 +289,24 @@ void OoxWorkbookFragment::finalizeImport() // load all worksheets for( SheetFragmentVector::iterator aIt = aSheetFragments.begin(), aEnd = aSheetFragments.end(); aIt != aEnd; ++aIt ) { - OOX_LOADSAVE_TIMER( IMPORTSHEETFRAGMENT ); // import the sheet fragment importOoxFragment( *aIt ); // delete fragment object, will free all allocated sheet buffers aIt->clear(); } + // import the VBA project (after loading the sheets, as they have imported the code names) + OUString aVbaFragmentPath = getFragmentPathFromFirstType( CREATE_MSOFFICE_RELATIONSTYPE( "vbaProject" ) ); + if( aVbaFragmentPath.getLength() > 0 ) + { + Reference< XInputStream > xInStrm = getBaseFilter().openInputStream( aVbaFragmentPath ); + if( xInStrm.is() ) + { + ::oox::ole::OleStorage aVbaStrg( getGlobalFactory(), xInStrm, false ); + getVbaProject().importVbaProject( aVbaStrg, getBaseFilter().getGraphicHelper() ); + } + } + // final conversions, e.g. calculation settings and view settings finalizeWorkbookImport(); } @@ -344,7 +360,8 @@ void OoxWorkbookFragment::importPivotCacheDefFragment( const OUString& rRelId, s // ============================================================================ BiffWorkbookFragment::BiffWorkbookFragment( const WorkbookHelper& rHelper, const OUString& rStrmName ) : - BiffWorkbookFragmentBase( rHelper, rStrmName ) + BiffWorkbookFragmentBase( rHelper, rStrmName ), + mbImportVbaProject( false ) { } @@ -372,6 +389,13 @@ bool BiffWorkbookFragment::importFragment() sal_Int16 nCalcSheet = rWorksheets.getCalcSheetIndex( nWorksheet ); bNextSheet = importSheetFragment( *xSheetProgress, eSheetFragment, nCalcSheet ); } + // import the VBA project (after loading the sheets, as they have imported the code names) + if( mbImportVbaProject ) + { + StorageRef xVbaStrg = getBaseFilter().openSubStorage( CREATE_OUSTRING( "_VBA_PROJECT_CUR" ), false ); + if( xVbaStrg.get() ) + getVbaProject().importVbaProject( *xVbaStrg, getBaseFilter().getGraphicHelper() ); + } } break; @@ -462,6 +486,8 @@ bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgress StylesBuffer& rStyles = getStyles(); WorksheetBuffer& rWorksheets = getWorksheets(); PivotCacheBuffer& rPivotCaches = getPivotCaches(); + bool bHasVbaProject = false; + bool bEmptyVbaProject = false; // collect records that need to be loaded in a second pass typedef ::std::vector< sal_Int64 > RecordHandleVec; @@ -562,25 +588,27 @@ bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgress case BIFF8: switch( nRecId ) { - case BIFF_ID_BOOKBOOL: rWorkbookSett.importBookBool( mrStrm ); break; - case BIFF_ID_CODENAME: rWorkbookSett.importCodeName( mrStrm ); break; - case BIFF_ID_CRN: bExtLinkRec = true; break; - case BIFF5_ID_DEFINEDNAME: bExtLinkRec = true; break; - case BIFF_ID_EXTERNALBOOK: bExtLinkRec = true; break; - case BIFF5_ID_EXTERNALNAME: bExtLinkRec = true; break; - case BIFF_ID_EXTERNSHEET: bExtLinkRec = true; break; - case BIFF_ID_FILESHARING: rWorkbookSett.importFileSharing( mrStrm ); break; - case BIFF5_ID_FONT: rStyles.importFont( mrStrm ); break; - case BIFF4_ID_FORMAT: rStyles.importFormat( mrStrm ); break; - case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( mrStrm ); break; - case BIFF_ID_PALETTE: rStyles.importPalette( mrStrm ); break; - case BIFF_ID_PIVOTCACHE: rPivotCaches.importPivotCacheRef( mrStrm ); break; - case BIFF_ID_SHEET: rWorksheets.importSheet( mrStrm ); break; - case BIFF_ID_SST: rSharedStrings.importSst( mrStrm ); break; - case BIFF_ID_STYLE: rStyles.importStyle( mrStrm ); break; - case BIFF_ID_USESELFS: rWorkbookSett.importUsesElfs( mrStrm ); break; - case BIFF_ID_XCT: bExtLinkRec = true; break; - case BIFF5_ID_XF: rStyles.importXf( mrStrm ); break; + case BIFF_ID_BOOKBOOL: rWorkbookSett.importBookBool( mrStrm ); break; + case BIFF_ID_CODENAME: rWorkbookSett.importCodeName( mrStrm ); break; + case BIFF_ID_CRN: bExtLinkRec = true; break; + case BIFF5_ID_DEFINEDNAME: bExtLinkRec = true; break; + case BIFF_ID_EXTERNALBOOK: bExtLinkRec = true; break; + case BIFF5_ID_EXTERNALNAME: bExtLinkRec = true; break; + case BIFF_ID_EXTERNSHEET: bExtLinkRec = true; break; + case BIFF_ID_FILESHARING: rWorkbookSett.importFileSharing( mrStrm ); break; + case BIFF5_ID_FONT: rStyles.importFont( mrStrm ); break; + case BIFF4_ID_FORMAT: rStyles.importFormat( mrStrm ); break; + case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( mrStrm ); break; + case BIFF_ID_VBAPROJECT: bHasVbaProject = true; break; + case BIFF_ID_VBAPROJECTEMPTY: bEmptyVbaProject = true; break; + case BIFF_ID_PALETTE: rStyles.importPalette( mrStrm ); break; + case BIFF_ID_PIVOTCACHE: rPivotCaches.importPivotCacheRef( mrStrm ); break; + case BIFF_ID_SHEET: rWorksheets.importSheet( mrStrm ); break; + case BIFF_ID_SST: rSharedStrings.importSst( mrStrm ); break; + case BIFF_ID_STYLE: rStyles.importStyle( mrStrm ); break; + case BIFF_ID_USESELFS: rWorkbookSett.importUsesElfs( mrStrm ); break; + case BIFF_ID_XCT: bExtLinkRec = true; break; + case BIFF5_ID_XF: rStyles.importXf( mrStrm ); break; } break; @@ -618,6 +646,9 @@ bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgress bRet = mrStrm.startRecordByHandle( nEofHandle ); } + // import the VBA project + mbImportVbaProject = bHasVbaProject && !bEmptyVbaProject; + // #i56376# missing EOF - rewind before worksheet BOF record (see above) if( bRet && isBofRecord() ) mrStrm.rewindRecord(); diff --git a/oox/source/xls/workbookhelper.cxx b/oox/source/xls/workbookhelper.cxx index 93ad0a65422f..9794b58e6a1b 100644 --- a/oox/source/xls/workbookhelper.cxx +++ b/oox/source/xls/workbookhelper.cxx @@ -27,7 +27,6 @@ #include "oox/xls/workbookhelper.hxx" #include -#include #include #include #include @@ -44,14 +43,14 @@ #include "properties.hxx" #include "oox/helper/progressbar.hxx" #include "oox/helper/propertyset.hxx" -#include "oox/core/binaryfilterbase.hxx" -#include "oox/core/xmlfilterbase.hxx" #include "oox/drawingml/theme.hxx" #include "oox/xls/addressconverter.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/biffcodec.hxx" #include "oox/xls/defnamesbuffer.hxx" #include "oox/xls/excelchartconverter.hxx" +#include "oox/xls/excelfilter.hxx" +#include "oox/xls/excelvbaproject.hxx" #include "oox/xls/externallinkbuffer.hxx" #include "oox/xls/formulaparser.hxx" #include "oox/xls/pagesettings.hxx" @@ -68,7 +67,6 @@ #include "oox/xls/workbooksettings.hxx" #include "oox/xls/worksheetbuffer.hxx" -using ::rtl::OStringBuffer; using ::rtl::OUString; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; @@ -103,148 +101,6 @@ using ::oox::drawingml::Theme; namespace oox { namespace xls { -// DEBUG ====================================================================== - -#if OSL_DEBUG_LEVEL > 0 -namespace dbg { - -// ---------------------------------------------------------------------------- - -#if OOX_SHOW_LOADSAVE_TIME > 0 - -struct TimeCount -{ - sal_Int64 mnTime; - sal_Int32 mnCount; - inline explicit TimeCount() : mnTime( 0 ), mnCount( 0 ) {} -}; - -Timer::Timer( TimeCount& rTimeCount ) : - mrTimeCount( rTimeCount ) -{ - ++mrTimeCount.mnCount; - osl_getSystemTime( &maStartTime ); -} - -Timer::~Timer() -{ - TimeValue aEndTime; - osl_getSystemTime( &aEndTime ); - mrTimeCount.mnTime += (SAL_CONST_INT64( 1000000000 ) * (aEndTime.Seconds - maStartTime.Seconds) + aEndTime.Nanosec - maStartTime.Nanosec); -} - -#endif - -// ---------------------------------------------------------------------------- - -struct WorkbookData -{ -#if OOX_SHOW_LOADSAVE_TIME > 0 - typedef ::std::vector< TimeCount > TimeCountVector; - typedef ::boost::shared_ptr< Timer > TimerRef; - TimeCountVector maTimeCounts; - TimerRef mxTotal; -#endif - sal_Int32 mnObjCount; - - explicit WorkbookData(); - ~WorkbookData(); -#if OOX_SHOW_LOADSAVE_TIME > 0 - TimeCount& getTimeCount( TimerType eType ); -#endif -}; - -WorkbookData::WorkbookData() : -#if OOX_SHOW_LOADSAVE_TIME > 0 - maTimeCounts( static_cast< size_t >( TIMER_TOTAL + 1 ) ), - mxTotal( new Timer( getTimeCount( TIMER_TOTAL ) ) ), -#endif - mnObjCount( 0 ) -{ -} - -WorkbookData::~WorkbookData() -{ -#if OOX_SHOW_LOADSAVE_TIME > 0 - mxTotal.reset(); - static const sal_Char* sppcNames[] = - { - "importFormula\t", - "importSheetFragment", - " onCreateSheetContext", - " importRow\t", - " convertRowFormat", - " convertColumnFormat", - " importCell\t", - " onEndSheetElement", - " setCell\t\t", - " setCellFormat\t", - " mergeCellFormats", - " writeCellProperties", - " finalizeSheetData", - " finalizeDrawing", - "finalizeBookData", - "total\t\t" - }; - OStringBuffer aBuffer( "Call counts and load/save times:\n" ); - sal_Int32 nIdx = 0; - for( TimeCountVector::iterator aIt = maTimeCounts.begin(), aEnd = maTimeCounts.end(); aIt != aEnd; ++aIt, ++nIdx ) - { - if( aIt->mnCount > 0 ) - { - aBuffer.append( nIdx ).append( ":\t" ).append( sppcNames[ nIdx ] ). - append( "\tn=" ).append( aIt->mnCount ).append( ',' ). - append( "\tt=" ).append( (aIt->mnTime / 100000000) / 10.0 ).append( 's' ). - append( "\t(" ).append( static_cast< sal_Int32 >( ((aIt->mnTime * 1000) / maTimeCounts.back().mnTime) / 10 ) ).append( "%)" ); - if( aIt->mnCount > 1 ) - aBuffer.append( "\tt/n=" ).append( static_cast< sal_Int32 >( aIt->mnTime / aIt->mnCount / 1000 ) ).append( "mys" ); - aBuffer.append( '\n' ); - } - } - OSL_ENSURE( false, aBuffer.getStr() ); -#endif - OSL_ENSURE( mnObjCount == 0, - OStringBuffer( "WorkbookData::~WorkbookData - failed to delete " ).append( mnObjCount ).append( " objects" ).getStr() ); -} - -#if OOX_SHOW_LOADSAVE_TIME > 0 -TimeCount& WorkbookData::getTimeCount( TimerType eType ) -{ - return maTimeCounts[ static_cast< size_t >( eType ) ]; -} -#endif - -// ---------------------------------------------------------------------------- - -WorkbookHelper::WorkbookHelper( WorkbookData& rBookData ) : - mrDbgBookData( rBookData ) -{ - ++mrDbgBookData.mnObjCount; -} - -WorkbookHelper::WorkbookHelper( const WorkbookHelper& rCopy ) : - mrDbgBookData( rCopy.mrDbgBookData ) -{ - ++mrDbgBookData.mnObjCount; -} - -WorkbookHelper::~WorkbookHelper() -{ - --mrDbgBookData.mnObjCount; -} - -#if OOX_SHOW_LOADSAVE_TIME > 0 -TimeCount& WorkbookHelper::getTimeCount( TimerType eType ) const -{ - return mrDbgBookData.getTimeCount( eType ); -} -#endif - -// ---------------------------------------------------------------------------- - -} // namespace dbg -#endif - // ============================================================================ bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rName2 ) const @@ -257,13 +113,10 @@ bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rNam // ============================================================================ class WorkbookData -#if OSL_DEBUG_LEVEL > 0 - : public dbg::WorkbookData -#endif { public: - explicit WorkbookData( XmlFilterBase& rFilter ); - explicit WorkbookData( BinaryFilterBase& rFilter, BiffType eBiff ); + explicit WorkbookData( ExcelFilter& rFilter ); + explicit WorkbookData( ExcelBiffFilter& rFilter, BiffType eBiff ); ~WorkbookData(); /** Returns true, if this helper refers to a valid document. */ @@ -348,6 +201,8 @@ public: inline ExcelChartConverter& getChartConverter() const { return *mxChartConverter; } /** Returns the page/print settings converter. */ inline PageSettingsConverter& getPageSettingsConverter() const { return *mxPageSettConverter; } + /** Returns the VBA project used to import/export VBA and attach events. */ + inline VbaProject& getVbaProject() const { return *mxVbaProject; } // OOX specific ----------------------------------------------------------- @@ -396,11 +251,12 @@ private: typedef ::std::auto_ptr< WebQueryBuffer > WebQueryBfrPtr; typedef ::std::auto_ptr< PivotCacheBuffer > PivotCacheBfrPtr; typedef ::std::auto_ptr< PivotTableBuffer > PivotTableBfrPtr; + typedef ::std::auto_ptr< FormulaParser > FormulaParserPtr; typedef ::std::auto_ptr< UnitConverter > UnitConvPtr; typedef ::std::auto_ptr< AddressConverter > AddressConvPtr; typedef ::std::auto_ptr< ExcelChartConverter > ExcelChartConvPtr; typedef ::std::auto_ptr< PageSettingsConverter > PageSettConvPtr; - typedef ::std::auto_ptr< FormulaParser > FormulaParserPtr; + typedef ::std::auto_ptr< VbaProject > VbaProjectPtr; typedef ::std::auto_ptr< BiffCodecHelper > BiffCodecHelperPtr; OUString maCellStyles; /// Style family name for cell styles. @@ -409,6 +265,7 @@ private: OUString maPageStyleServ; /// Service name for a page style. Reference< XSpreadsheetDocument > mxDoc; /// Document model. FilterBase& mrBaseFilter; /// Base filter object. + ExcelFilterBase& mrExcelBase; /// Base object for registration of this structure. FilterType meFilterType; /// File type of the filter. ProgressBarPtr mxProgressBar; /// The progress bar. sal_Int16 mnCurrSheet; /// Current sheet index in Calc dcument. @@ -435,6 +292,7 @@ private: AddressConvPtr mxAddrConverter; /// Cell address and cell range address converter. ExcelChartConvPtr mxChartConverter; /// Chart object converter. PageSettConvPtr mxPageSettConverter; /// Page/print settings converter. + VbaProjectPtr mxVbaProject; /// VBA project. // OOX specific XmlFilterBase* mpOoxFilter; /// Base OOX filter object. @@ -449,27 +307,36 @@ private: // ---------------------------------------------------------------------------- -WorkbookData::WorkbookData( XmlFilterBase& rFilter ) : +WorkbookData::WorkbookData( ExcelFilter& rFilter ) : mrBaseFilter( rFilter ), + mrExcelBase( rFilter ), meFilterType( FILTER_OOX ), mpOoxFilter( &rFilter ), + mpBiffFilter( 0 ), meBiff( BIFF_UNKNOWN ) { + // register at the filter, needed for virtual callbacks (even during construction) + mrExcelBase.registerWorkbookData( *this ); initialize( true ); } -WorkbookData::WorkbookData( BinaryFilterBase& rFilter, BiffType eBiff ) : +WorkbookData::WorkbookData( ExcelBiffFilter& rFilter, BiffType eBiff ) : mrBaseFilter( rFilter ), + mrExcelBase( rFilter ), meFilterType( FILTER_BIFF ), + mpOoxFilter( 0 ), mpBiffFilter( &rFilter ), meBiff( eBiff ) { + // register at the filter, needed for virtual callbacks (even during construction) + mrExcelBase.registerWorkbookData( *this ); initialize( eBiff >= BIFF5 ); } WorkbookData::~WorkbookData() { finalize(); + mrExcelBase.unregisterWorkbookData(); } // document model ------------------------------------------------------------- @@ -681,8 +548,8 @@ void WorkbookData::initialize( bool bWorkbookFile ) mxUnitConverter.reset( new UnitConverter( *this ) ); mxAddrConverter.reset( new AddressConverter( *this ) ); mxChartConverter.reset( new ExcelChartConverter( *this ) ); - mxPageSettConverter.reset( new PageSettingsConverter( *this ) ); + mxVbaProject.reset( new VbaProject( mrBaseFilter.getGlobalFactory(), mxDoc ) ); // set some document properties needed during import if( mrBaseFilter.isImportFilter() ) @@ -715,7 +582,7 @@ void WorkbookData::initialize( bool bWorkbookFile ) switch( getFilterType() ) { case FILTER_BIFF: - mxCodecHelper.reset( new BiffCodecHelper( * this ) ); + mxCodecHelper.reset( new BiffCodecHelper( *this ) ); break; case FILTER_OOX: @@ -728,7 +595,6 @@ void WorkbookData::initialize( bool bWorkbookFile ) void WorkbookData::finalize() { - OOX_LOADSAVE_TIMER( FINALIZEBOOKDATA ); // set some document properties needed after import if( mrBaseFilter.isImportFilter() ) { @@ -752,14 +618,6 @@ void WorkbookData::finalize() // ============================================================================ -WorkbookHelper::WorkbookHelper( WorkbookData& rBookData ) : -#if OSL_DEBUG_LEVEL > 0 - dbg::WorkbookHelper( rBookData ), -#endif - mrBookData( rBookData ) -{ -} - WorkbookHelper::~WorkbookHelper() { } @@ -822,6 +680,9 @@ void WorkbookHelper::finalizeWorkbookImport() sheets. Automatic numbering is set by passing the value 0. */ PropertySet aDefPageStyle( getStyleObject( CREATE_OUSTRING( "Default" ), true ) ); aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 ); + + // attach VBA macros to document and sheet events + getVbaProject().attachToEvents(); } // document model ------------------------------------------------------------- @@ -1026,13 +887,16 @@ ExcelChartConverter& WorkbookHelper::getChartConverter() const return mrBookData.getChartConverter(); } -// property helpers ----------------------------------------------------------- - PageSettingsConverter& WorkbookHelper::getPageSettingsConverter() const { return mrBookData.getPageSettingsConverter(); } +VbaProject& WorkbookHelper::getVbaProject() const +{ + return mrBookData.getVbaProject(); +} + // OOX specific --------------------------------------------------------------- XmlFilterBase& WorkbookHelper::getOoxFilter() const @@ -1111,13 +975,13 @@ WorkbookDataOwner::~WorkbookDataOwner() // ---------------------------------------------------------------------------- -WorkbookHelperRoot::WorkbookHelperRoot( ::oox::core::XmlFilterBase& rFilter ) : +WorkbookHelperRoot::WorkbookHelperRoot( ExcelFilter& rFilter ) : prv::WorkbookDataOwner( prv::WorkbookDataRef( new WorkbookData( rFilter ) ) ), WorkbookHelper( *mxBookData ) { } -WorkbookHelperRoot::WorkbookHelperRoot( ::oox::core::BinaryFilterBase& rFilter, BiffType eBiff ) : +WorkbookHelperRoot::WorkbookHelperRoot( ExcelBiffFilter& rFilter, BiffType eBiff ) : prv::WorkbookDataOwner( prv::WorkbookDataRef( new WorkbookData( rFilter, eBiff ) ) ), WorkbookHelper( *mxBookData ) { diff --git a/oox/source/xls/workbooksettings.cxx b/oox/source/xls/workbooksettings.cxx index 1277b0879e7a..40d400da7757 100644 --- a/oox/source/xls/workbooksettings.cxx +++ b/oox/source/xls/workbooksettings.cxx @@ -130,7 +130,7 @@ void WorkbookSettings::importFileSharing( const AttributeList& rAttribs ) void WorkbookSettings::importWorkbookPr( const AttributeList& rAttribs ) { - maBookSettings.maCodeName = rAttribs.getString( XML_codePage, OUString() ); + maBookSettings.maCodeName = rAttribs.getString( XML_codeName, OUString() ); maBookSettings.mnShowObjectMode = rAttribs.getToken( XML_showObjects, XML_all ); maBookSettings.mnUpdateLinksMode = rAttribs.getToken( XML_updateLinks, XML_userSet ); maBookSettings.mnDefaultThemeVer = rAttribs.getInteger( XML_defaultThemeVersion, -1 ); @@ -318,6 +318,9 @@ void WorkbookSettings::finalizeImport() Reference< XCalculatable > xCalculatable( getDocument(), UNO_QUERY ); if( xCalculatable.is() ) xCalculatable->enableAutomaticCalculation( (maCalcSettings.mnCalcMode == XML_auto) || (maCalcSettings.mnCalcMode == XML_autoNoTable) ); + + // VBA code name + aPropSet.setProperty( PROP_CodeName, maBookSettings.maCodeName ); } sal_Int16 WorkbookSettings::getApiShowObjectMode() const diff --git a/oox/source/xls/worksheetfragment.cxx b/oox/source/xls/worksheetfragment.cxx index ff42c6afb704..14cf80a91d52 100644 --- a/oox/source/xls/worksheetfragment.cxx +++ b/oox/source/xls/worksheetfragment.cxx @@ -870,6 +870,7 @@ bool BiffWorksheetFragment::importFragment() case BIFF8: switch( nRecId ) { case BIFF_ID_CFHEADER: rCondFormats.importCfHeader( mrStrm ); break; + case BIFF_ID_CODENAME: rWorksheetSett.importCodeName( mrStrm ); break; case BIFF_ID_COLINFO: importColInfo(); break; case BIFF_ID_DATAVALIDATION: importDataValidation(); break; case BIFF_ID_DATAVALIDATIONS: importDataValidations(); break; @@ -1080,7 +1081,7 @@ void BiffWorksheetFragment::importHyperlink() return; // try to read the StdHlink data - if( !::oox::ole::OleHelper::importStdHlink( aModel, mrStrm, getTextEncoding(), true ) ) + if( !::oox::ole::OleHelper::importStdHlink( aModel, mrStrm, true ) ) return; // try to read the optional following SCREENTIP record diff --git a/oox/source/xls/worksheethelper.cxx b/oox/source/xls/worksheethelper.cxx index e28df89cd7b3..381def644ce5 100644 --- a/oox/source/xls/worksheethelper.cxx +++ b/oox/source/xls/worksheethelper.cxx @@ -30,15 +30,10 @@ #include #include #include -#include #include #include -#include -#include -#include -#include #include -#include +#include #include #include #include @@ -52,7 +47,12 @@ #include #include #include +#include #include +#include +#include +#include +#include #include "properties.hxx" #include "tokens.hxx" #include "oox/helper/containerhelper.hxx" @@ -75,30 +75,13 @@ using ::rtl::OUString; using ::rtl::OUStringBuffer; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::uno::UNO_SET_THROW; -using ::com::sun::star::lang::Locale; -using ::com::sun::star::lang::XMultiServiceFactory; -using ::com::sun::star::beans::XPropertySet; -using ::com::sun::star::util::DateTime; -using ::com::sun::star::util::XMergeable; -using ::com::sun::star::util::XNumberFormatsSupplier; -using ::com::sun::star::util::XNumberFormatTypes; using ::com::sun::star::awt::Point; using ::com::sun::star::awt::Size; +using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::drawing::XDrawPage; using ::com::sun::star::drawing::XDrawPageSupplier; -using ::com::sun::star::table::BorderLine; -using ::com::sun::star::table::CellAddress; -using ::com::sun::star::table::CellRangeAddress; -using ::com::sun::star::table::XCell; -using ::com::sun::star::table::XCellRange; -using ::com::sun::star::table::XColumnRowRange; -using ::com::sun::star::table::XTableColumns; -using ::com::sun::star::table::XTableRows; +using ::com::sun::star::lang::Locale; +using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::sheet::ConditionOperator; using ::com::sun::star::sheet::ValidationType; using ::com::sun::star::sheet::ValidationAlertStyle; @@ -113,9 +96,26 @@ using ::com::sun::star::sheet::XSheetCellRanges; using ::com::sun::star::sheet::XSheetCondition; using ::com::sun::star::sheet::XSheetOutline; using ::com::sun::star::sheet::XSpreadsheet; +using ::com::sun::star::table::BorderLine; +using ::com::sun::star::table::CellAddress; +using ::com::sun::star::table::CellRangeAddress; +using ::com::sun::star::table::XCell; +using ::com::sun::star::table::XCellRange; +using ::com::sun::star::table::XColumnRowRange; +using ::com::sun::star::table::XTableColumns; +using ::com::sun::star::table::XTableRows; using ::com::sun::star::text::XText; using ::com::sun::star::text::XTextContent; using ::com::sun::star::text::XTextRange; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::util::DateTime; +using ::com::sun::star::util::XMergeable; +using ::com::sun::star::util::XNumberFormatsSupplier; +using ::com::sun::star::util::XNumberFormatTypes; namespace oox { namespace xls { @@ -792,7 +792,6 @@ void WorksheetData::setDimension( const CellRangeAddress& rRange ) void WorksheetData::setCellFormat( const CellModel& rModel ) { - OOX_LOADSAVE_TIMER( SETCELLFORMAT ); if( rModel.mxCell.is() && ((rModel.mnXfId >= 0) || (rModel.mnNumFmtId >= 0)) ) { // try to merge existing ranges and to write some formatting properties @@ -954,7 +953,6 @@ void WorksheetData::setRowModel( const RowModel& rModel ) void WorksheetData::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol, sal_Int32 nXfId ) const { - OOX_LOADSAVE_TIMER( CONVERTCOLUMNFORMAT ); CellRangeAddress aRange( mnSheet, nFirstCol, 0, nLastCol, mrMaxApiPos.Row ); if( getAddressConverter().validateCellRange( aRange, true, false ) ) { @@ -965,7 +963,6 @@ void WorksheetData::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol void WorksheetData::convertRowFormat( sal_Int32 nFirstRow, sal_Int32 nLastRow, sal_Int32 nXfId ) const { - OOX_LOADSAVE_TIMER( CONVERTROWFORMAT ); CellRangeAddress aRange( mnSheet, 0, nFirstRow, mrMaxApiPos.Column, nLastRow ); if( getAddressConverter().validateCellRange( aRange, true, false ) ) { @@ -987,13 +984,13 @@ void WorksheetData::initializeWorksheetImport() void WorksheetData::finalizeWorksheetImport() { - OOX_LOADSAVE_TIMER( FINALIZESHEETDATA ); lclUpdateProgressBar( mxRowProgress, 1.0 ); finalizeXfIdRanges(); lclUpdateProgressBar( mxFinalProgress, 0.25 ); finalizeHyperlinkRanges(); finalizeValidationRanges(); finalizeMergedRanges(); + maSheetSett.finalizeImport(); maCondFormats.finalizeImport(); maPageSett.finalizeImport(); maSheetViewSett.finalizeImport(); @@ -1117,7 +1114,6 @@ void WorksheetData::writeXfIdRowRangeProperties( const XfIdRowRange& rXfIdRowRan void WorksheetData::writeXfIdRangeProperties( const XfIdRange& rXfIdRange ) const { - OOX_LOADSAVE_TIMER( WRITECELLPROPERTIES ); StylesBuffer& rStyles = getStyles(); PropertyMap aPropMap; if( rXfIdRange.mnXfId >= 0 ) @@ -1132,7 +1128,6 @@ void WorksheetData::mergeXfIdRanges() { if( !maXfIdRanges.empty() ) { - OOX_LOADSAVE_TIMER( MERGECELLFORMAT ); // get row index of last range sal_Int32 nLastRow = maXfIdRanges.rbegin()->second.maRange.StartRow; // process all ranges located in the same row of the last range @@ -1397,10 +1392,7 @@ void WorksheetData::finalizeDrawing() OSL_ENSURE( (getFilterType() == FILTER_OOX) || (maDrawingPath.getLength() == 0), "WorksheetData::finalizeDrawing - unexpected DrawingML path" ); if( (getFilterType() == FILTER_OOX) && (maDrawingPath.getLength() > 0) ) - { - OOX_LOADSAVE_TIMER( FINALIZEDRAWING ); importOoxFragment( new OoxDrawingFragment( *this, maDrawingPath ) ); - } } void WorksheetData::finalizeVmlDrawing() @@ -1822,7 +1814,6 @@ void WorksheetHelper::setErrorCell( const Reference< XCell >& rxCell, sal_uInt8 void WorksheetHelper::setCell( CellModel& orModel ) const { OSL_ENSURE( orModel.mxCell.is(), "WorksheetHelper::setCell - missing cell interface" ); - OOX_LOADSAVE_TIMER( SETCELL ); if( orModel.mbHasValueStr ) switch( orModel.mnCellType ) { case XML_b: diff --git a/oox/source/xls/worksheetsettings.cxx b/oox/source/xls/worksheetsettings.cxx index b9e4f4b8babc..6a42c38e1647 100644 --- a/oox/source/xls/worksheetsettings.cxx +++ b/oox/source/xls/worksheetsettings.cxx @@ -27,6 +27,7 @@ #include "oox/xls/worksheetsettings.hxx" #include +#include "properties.hxx" #include "oox/helper/attributelist.hxx" #include "oox/helper/recordinputstream.hxx" #include "oox/xls/biffinputstream.hxx" @@ -293,6 +294,11 @@ void WorksheetSettings::importSheetProtection( BiffInputStream& rStrm ) maSheetProt.mbSelectUnlocked = !getFlag( nFlags, BIFF_SHEETPROT_SELECT_UNLOCKED ); } +void WorksheetSettings::importCodeName( BiffInputStream& rStrm ) +{ + maSheetSettings.maCodeName = rStrm.readUniString(); +} + void WorksheetSettings::importPhoneticPr( BiffInputStream& rStrm ) { maPhoneticSett.importPhoneticPr( rStrm ); @@ -300,6 +306,7 @@ void WorksheetSettings::importPhoneticPr( BiffInputStream& rStrm ) void WorksheetSettings::finalizeImport() { + // sheet protection if( maSheetProt.mbSheet ) try { Reference< XProtectable > xProtectable( getSheet(), UNO_QUERY_THROW ); @@ -308,6 +315,10 @@ void WorksheetSettings::finalizeImport() catch( Exception& ) { } + + // VBA code name + PropertySet aPropSet( getSheet() ); + aPropSet.setProperty( PROP_CodeName, maSheetSettings.maCodeName ); } // ============================================================================ diff --git a/oox/util/makefile.mk b/oox/util/makefile.mk index 3d3aba15dd2e..8bbf8a3650f2 100644 --- a/oox/util/makefile.mk +++ b/oox/util/makefile.mk @@ -68,7 +68,8 @@ SHL1STDLIBS= \ $(RTLLIB) \ $(SALLIB) \ $(BASEGFXLIB) \ - $(SAXLIB) + $(SAXLIB) \ + $(XMLSCRIPTLIB) # link openssl, copied this bit from ucb/source/ucp/webdav/makefile.mk .IF "$(GUI)"=="WNT" -- cgit From 64da8a9b1cda404727ab3d70c01bf6deedaf8614 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 17:31:33 +0200 Subject: npower13_objectmodules: make vba import available in oox filters --- offapi/com/sun/star/script/ModuleInfo.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/offapi/com/sun/star/script/ModuleInfo.idl b/offapi/com/sun/star/script/ModuleInfo.idl index ea7684692e8e..158ba387be6b 100644 --- a/offapi/com/sun/star/script/ModuleInfo.idl +++ b/offapi/com/sun/star/script/ModuleInfo.idl @@ -45,7 +45,7 @@ module com { module sun { module star { module script { struct ModuleInfo { com::sun::star::uno::XInterface ModuleObject; - short ModuleType; + long ModuleType; }; //============================================================================= -- cgit From b798812d02e55e78ca20f6c55fefdd062f5cd164 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 17:31:33 +0200 Subject: npower13_objectmodules: make vba import available in oox filters --- sot/source/unoolestorage/xolesimplestorage.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sot/source/unoolestorage/xolesimplestorage.cxx b/sot/source/unoolestorage/xolesimplestorage.cxx index 68686ff8c8f5..1780e45c5ed6 100644 --- a/sot/source/unoolestorage/xolesimplestorage.cxx +++ b/sot/source/unoolestorage/xolesimplestorage.cxx @@ -199,9 +199,9 @@ void OLESimpleStorage::InsertNameAccessToStorage_Impl( BaseStorage* pStorage, :: uno::Reference< container::XNameAccess > xSubNameAccess; uno::Any aAny = xNameAccess->getByName( aElements[nInd] ); if ( aAny >>= xInputStream ) - InsertInputStreamToStorage_Impl( pNewStorage, aName, xInputStream ); + InsertInputStreamToStorage_Impl( pNewStorage, aElements[nInd], xInputStream ); else if ( aAny >>= xSubNameAccess ) - InsertNameAccessToStorage_Impl( pNewStorage, aName, xSubNameAccess ); + InsertNameAccessToStorage_Impl( pNewStorage, aElements[nInd], xSubNameAccess ); } } catch( uno::Exception& ) -- cgit From da9d0047fe373b0083b23e45bef4fca7f008af11 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 17:31:33 +0200 Subject: npower13_objectmodules: make vba import available in oox filters --- sc/source/ui/unoobj/servuno.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx index d69659b41f11..f4f27357bdbb 100644 --- a/sc/source/ui/unoobj/servuno.cxx +++ b/sc/source/ui/unoobj/servuno.cxx @@ -37,6 +37,7 @@ #include #include "servuno.hxx" +#include "unoguard.hxx" #include "unonames.hxx" #include "cellsuno.hxx" #include "fielduno.hxx" @@ -104,6 +105,7 @@ public: virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException ) { + ScUnoGuard aGuard; maCachedObject = uno::Any(); // clear cached object String sName = aName; @@ -150,6 +152,7 @@ public: } ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { + ScUnoGuard aGuard; OSL_TRACE("ScVbaObjectForCodeNameProvider::getByName( %s )", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr() ); if ( !hasByName( aName ) ) @@ -158,6 +161,7 @@ public: } virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException) { + ScUnoGuard aGuard; ScDocument* pDoc = mpDocShell->GetDocument(); if ( !pDoc ) throw uno::RuntimeException(); @@ -187,6 +191,7 @@ public: // XCodeNameQuery rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException ) { + ScUnoGuard aGuard; rtl::OUString sCodeName; if ( mpDocShell ) { -- cgit From 1f8d19b79c14ccd081f5c60dc0f6f89bb6c1ffea Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Wed, 14 Apr 2010 19:02:57 +0200 Subject: bserver52: #161974# an empty line in build.lst should be ignorred --- soldep/bootstrp/prj.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soldep/bootstrp/prj.cxx b/soldep/bootstrp/prj.cxx index 9fde614659b0..dfb29fe74754 100644 --- a/soldep/bootstrp/prj.cxx +++ b/soldep/bootstrp/prj.cxx @@ -183,7 +183,7 @@ ByteString SimpleConfig::GetCleanedNextLine( BOOL bReadComments ) if (bReadComments ) return aTmpStr; } - else + else if (aTmpStr != ByteString::EmptyString()) bReadNextLine = sal_False; } -- cgit From 1110315ea427c77a9ca630fc80d1f9e15242f29e Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 19:14:53 +0200 Subject: npower13_objectmodules: compiler errors --- oox/inc/oox/helper/binarystreambase.hxx | 2 +- oox/source/dump/dffdumper.cxx | 6 +++--- oox/source/dump/oledumper.cxx | 20 ++++++++++---------- oox/source/helper/binarystreambase.cxx | 2 +- oox/source/ole/vbacontrol.cxx | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/oox/inc/oox/helper/binarystreambase.hxx b/oox/inc/oox/helper/binarystreambase.hxx index 5cebdc681e8d..abe4c5f1c274 100644 --- a/oox/inc/oox/helper/binarystreambase.hxx +++ b/oox/inc/oox/helper/binarystreambase.hxx @@ -69,7 +69,7 @@ public: inline void seekToEnd() { seek( getLength() ); } /** Seeks the stream forward to a position that is a multiple of the passed block size, relative to the passed stream position, if stream is seekable. */ - void align( sal_Int32 nBlockSize, sal_Int64 nAnchorPos = 0 ); + void alignToBlock( sal_Int32 nBlockSize, sal_Int64 nAnchorPos = 0 ); protected: inline explicit BinaryStreamBase() : mbEof( false ) {} diff --git a/oox/source/dump/dffdumper.cxx b/oox/source/dump/dffdumper.cxx index 1b93d9b213c4..8730698561ce 100644 --- a/oox/source/dump/dffdumper.cxx +++ b/oox/source/dump/dffdumper.cxx @@ -138,10 +138,10 @@ void DffStreamObject::implDumpRecordBody() dumpDec< sal_uInt32 >( "shape-count" ); dumpDec< sal_uInt32 >( "drawing-count" ); mxOut->resetItemIndex( 1 ); - TableGuard aTabGuard( *mxOut, 15, 16 ); + TableGuard aTabGuard( mxOut, 15, 16 ); for( sal_uInt32 nCluster = 1; !mxStrm->isEof() && (nCluster < nClusters); ++nCluster ) { - MultiItemsGuard aMultiGuard( *mxOut ); + MultiItemsGuard aMultiGuard( mxOut ); writeEmptyItem( "#cluster" ); dumpDec< sal_uInt32 >( "drawing-id" ); dumpHex< sal_uInt32 >( "next-free-id", "CONV-DEC" ); @@ -287,7 +287,7 @@ void DffStreamObject::dumpDffOpt() writeEmptyItem( "#complex-data" ); writeHexItem( "id", aIt->mnId, "DFFOPT-PROPERTY-NAMES" ); mxOut->endMultiItems(); - IndentGuard aIndent( *mxOut ); + IndentGuard aIndent( mxOut ); switch( aIt->meType ) { case PROPTYPE_BINARY: diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx index 9c3e00fdcf30..4e358801a513 100644 --- a/oox/source/dump/oledumper.cxx +++ b/oox/source/dump/oledumper.cxx @@ -1098,7 +1098,7 @@ sal_uInt32 AxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const s return nDefault; } -sal_uInt32 OcxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault ) +sal_uInt32 AxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault ) { if( startNextProperty() ) { @@ -1108,7 +1108,7 @@ sal_uInt32 OcxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault ) return nDefault; } -sal_Unicode OcxPropertyObjectBase::dumpUnicodeProperty() +sal_Unicode AxPropertyObjectBase::dumpUnicodeProperty() { if( startNextProperty() ) { @@ -1783,11 +1783,11 @@ void VbaFormDesignExtObject::implDumpShortProperties() namespace { -const sal_uInt32 OCX_FORM_HASDESIGNEXTENDER = 0x00004000; -const sal_uInt32 OCX_FORM_SKIPCLASSTABLE = 0x00008000; +const sal_uInt32 AX_FORM_HASDESIGNEXTENDER = 0x00004000; +const sal_uInt32 AX_FORM_SKIPCLASSTABLE = 0x00008000; -const sal_uInt8 OCX_FORM_SITECOUNTTYPE_COUNT = 0x80; -const sal_uInt8 OCX_FORM_SITECOUNTTYPE_MASK = 0x7F; +const sal_uInt8 AX_FORM_SITECOUNTTYPE_COUNT = 0x80; +const sal_uInt8 AX_FORM_SITECOUNTTYPE_MASK = 0x7F; } // namespace @@ -1841,7 +1841,7 @@ void VbaFStreamObject::implDumpExtended() void VbaFStreamObject::dumpClassInfos() { - if( ensureValid() && !getFlag( mnFlags, OCX_FORM_SKIPCLASSTABLE ) ) + if( ensureValid() && !getFlag( mnFlags, AX_FORM_SKIPCLASSTABLE ) ) { mxOut->emptyLine(); sal_uInt16 nCount = dumpDec< sal_uInt16 >( "class-info-count" ); @@ -1887,10 +1887,10 @@ void VbaFStreamObject::dumpSiteData() IndentGuard aIndGuard( mxOut ); dumpDec< sal_uInt8 >( "depth" ); sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "VBA-FORM-SITE-TYPECOUNT" ); - if( getFlag( nTypeCount, OCX_FORM_SITECOUNTTYPE_COUNT ) ) + if( getFlag( nTypeCount, AX_FORM_SITECOUNTTYPE_COUNT ) ) { dumpDec< sal_uInt8 >( "repeated-type" ); - nSiteIdx += (nTypeCount & OCX_FORM_SITECOUNTTYPE_MASK); + nSiteIdx += (nTypeCount & AX_FORM_SITECOUNTTYPE_MASK); } else { @@ -1906,7 +1906,7 @@ void VbaFStreamObject::dumpSiteData() void VbaFStreamObject::dumpDesignExtender() { - if( ensureValid() && getFlag( mnFlags, OCX_FORM_HASDESIGNEXTENDER ) ) + if( ensureValid() && getFlag( mnFlags, AX_FORM_HASDESIGNEXTENDER ) ) { mxOut->emptyLine(); writeEmptyItem( "design-extender" ); diff --git a/oox/source/helper/binarystreambase.cxx b/oox/source/helper/binarystreambase.cxx index 86eae793a3c1..a8f9320ffc94 100644 --- a/oox/source/helper/binarystreambase.cxx +++ b/oox/source/helper/binarystreambase.cxx @@ -67,7 +67,7 @@ sal_Int64 BinaryStreamBase::getRemaining() const return ((nPos >= 0) && (nLen >= 0)) ? ::std::max< sal_Int64 >( nLen - nPos, 0 ) : -1; } -void BinaryStreamBase::align( sal_Int32 nBlockSize, sal_Int64 nAnchorPos ) +void BinaryStreamBase::alignToBlock( sal_Int32 nBlockSize, sal_Int64 nAnchorPos ) { sal_Int64 nStrmPos = tell(); // nothing to do, if stream is at anchor position diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx index 2674c30d9a73..b43e8289a592 100755 --- a/oox/source/ole/vbacontrol.cxx +++ b/oox/source/ole/vbacontrol.cxx @@ -525,7 +525,7 @@ bool VbaFormControl::importEmbeddedSiteModels( BinaryInputStream& rInStrm ) } } // align the stream to 32bit, relative to start of entire site info - rInStrm.align( 4, nAnchorPos ); + rInStrm.alignToBlock( 4, nAnchorPos ); // import the site models for all embedded controls maControls.clear(); -- cgit From 130bbc98813c32460dc354dfa712de620cedecff Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 19:14:53 +0200 Subject: npower13_objectmodules: compiler errors --- xmlscript/source/xmldlg_imexp/exp_share.hxx | 2 +- xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx | 2 +- xmlscript/source/xmldlg_imexp/xmldlg_export.cxx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xmlscript/source/xmldlg_imexp/exp_share.hxx b/xmlscript/source/xmldlg_imexp/exp_share.hxx index d32d46698003..a53d02393ae6 100644 --- a/xmlscript/source/xmldlg_imexp/exp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/exp_share.hxx @@ -117,7 +117,7 @@ public: inline bool readProp( T * ret, ::rtl::OUString const & rPropName ); css::uno::Any readProp( ::rtl::OUString const & rPropName ); // - void readDefaults( bool supportPrintable = true ); + void readDefaults( bool supportPrintable = true, bool supportVisible = true ); // void readStringAttr( ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName ); diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx index 55b46edc1392..b30c24b4b419 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx @@ -1138,7 +1138,7 @@ void ElementDescriptor::readDialogModel( StyleBag * all_styles ) } // collect elements - readDefaults( false ); + readDefaults( false, false ); readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Closeable") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":closeable") ) ); diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx index 088d6e841c94..365355375808 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx @@ -972,7 +972,7 @@ void ElementDescriptor::readSelectionTypeAttr( OUString const & rPropName, OUStr } } //__________________________________________________________________________________________________ -void ElementDescriptor::readDefaults( bool supportPrintable ) +void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible ) { Any a( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) ); addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), @@ -995,7 +995,7 @@ void ElementDescriptor::readDefaults( bool supportPrintable ) } sal_Bool bVisible = sal_True; - try + if (supportVisible) try { if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("EnableVisible") ) ) >>= bVisible) { -- cgit From dbd1daa7f89f25ca26a526207690789a351828d4 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 21:08:24 +0200 Subject: npower13_objectmodules: load vba after applying workbook codename --- oox/inc/oox/xls/workbookfragment.hxx | 3 --- oox/inc/oox/xls/workbookhelper.hxx | 7 +++---- oox/source/xls/workbookfragment.cxx | 23 ++++++----------------- oox/source/xls/workbookhelper.cxx | 32 ++++++++++++++++++++------------ 4 files changed, 29 insertions(+), 36 deletions(-) diff --git a/oox/inc/oox/xls/workbookfragment.hxx b/oox/inc/oox/xls/workbookfragment.hxx index 0a4853748bf5..f9f0bb25c78f 100644 --- a/oox/inc/oox/xls/workbookfragment.hxx +++ b/oox/inc/oox/xls/workbookfragment.hxx @@ -92,9 +92,6 @@ private: bool importSheetFragment( ISegmentProgressBar& rProgressBar, BiffFragmentType eFragment, sal_Int16 nCalcSheet ); - -private: - bool mbImportVbaProject; /// True = import VBA project at end of filter. }; // ============================================================================ diff --git a/oox/inc/oox/xls/workbookhelper.hxx b/oox/inc/oox/xls/workbookhelper.hxx index 8a6f436bbaaf..0ff8c0f9d3e5 100644 --- a/oox/inc/oox/xls/workbookhelper.hxx +++ b/oox/inc/oox/xls/workbookhelper.hxx @@ -30,7 +30,7 @@ #include #include -//#include "oox/helper/storagebase.hxx" +#include "oox/helper/storagebase.hxx" #include "oox/xls/biffhelper.hxx" namespace com { namespace sun { namespace star { @@ -113,7 +113,6 @@ class UnitConverter; class AddressConverter; class ExcelChartConverter; class PageSettingsConverter; -class VbaProject; class BiffCodecHelper; /** Helper class to provice access to global workbook data. @@ -151,6 +150,8 @@ public: /** Sets the index of the current sheet in the Calc document. */ void setCurrentSheetIndex( sal_Int16 nSheet ); + /** Sets the VBA project storage. */ + void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ); /** Final conversion after importing the workbook. */ void finalizeWorkbookImport(); @@ -255,8 +256,6 @@ public: ExcelChartConverter& getChartConverter() const; /** Returns the page and print settings converter. */ PageSettingsConverter& getPageSettingsConverter() const; - /** Returns the VBA project used to import/export VBA and attach events. */ - VbaProject& getVbaProject() const; // OOX specific (MUST NOT be called in BIFF filter) ----------------------- diff --git a/oox/source/xls/workbookfragment.cxx b/oox/source/xls/workbookfragment.cxx index b5eb9a11dd2c..d64abf268008 100644 --- a/oox/source/xls/workbookfragment.cxx +++ b/oox/source/xls/workbookfragment.cxx @@ -37,7 +37,6 @@ #include "oox/xls/biffinputstream.hxx" #include "oox/xls/chartsheetfragment.hxx" #include "oox/xls/connectionsfragment.hxx" -#include "oox/xls/excelvbaproject.hxx" #include "oox/xls/externallinkbuffer.hxx" #include "oox/xls/externallinkfragment.hxx" #include "oox/xls/pivotcachebuffer.hxx" @@ -295,16 +294,13 @@ void OoxWorkbookFragment::finalizeImport() aIt->clear(); } - // import the VBA project (after loading the sheets, as they have imported the code names) + // open the VBA project storage OUString aVbaFragmentPath = getFragmentPathFromFirstType( CREATE_MSOFFICE_RELATIONSTYPE( "vbaProject" ) ); if( aVbaFragmentPath.getLength() > 0 ) { Reference< XInputStream > xInStrm = getBaseFilter().openInputStream( aVbaFragmentPath ); if( xInStrm.is() ) - { - ::oox::ole::OleStorage aVbaStrg( getGlobalFactory(), xInStrm, false ); - getVbaProject().importVbaProject( aVbaStrg, getBaseFilter().getGraphicHelper() ); - } + setVbaProjectStorage( StorageRef( new ::oox::ole::OleStorage( getGlobalFactory(), xInStrm, false ) ) ); } // final conversions, e.g. calculation settings and view settings @@ -360,8 +356,7 @@ void OoxWorkbookFragment::importPivotCacheDefFragment( const OUString& rRelId, s // ============================================================================ BiffWorkbookFragment::BiffWorkbookFragment( const WorkbookHelper& rHelper, const OUString& rStrmName ) : - BiffWorkbookFragmentBase( rHelper, rStrmName ), - mbImportVbaProject( false ) + BiffWorkbookFragmentBase( rHelper, rStrmName ) { } @@ -389,13 +384,6 @@ bool BiffWorkbookFragment::importFragment() sal_Int16 nCalcSheet = rWorksheets.getCalcSheetIndex( nWorksheet ); bNextSheet = importSheetFragment( *xSheetProgress, eSheetFragment, nCalcSheet ); } - // import the VBA project (after loading the sheets, as they have imported the code names) - if( mbImportVbaProject ) - { - StorageRef xVbaStrg = getBaseFilter().openSubStorage( CREATE_OUSTRING( "_VBA_PROJECT_CUR" ), false ); - if( xVbaStrg.get() ) - getVbaProject().importVbaProject( *xVbaStrg, getBaseFilter().getGraphicHelper() ); - } } break; @@ -646,8 +634,9 @@ bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgress bRet = mrStrm.startRecordByHandle( nEofHandle ); } - // import the VBA project - mbImportVbaProject = bHasVbaProject && !bEmptyVbaProject; + // open the VBA project storage + if( bHasVbaProject && !bEmptyVbaProject ) + setVbaProjectStorage( getBaseFilter().openSubStorage( CREATE_OUSTRING( "_VBA_PROJECT_CUR" ), false ) ); // #i56376# missing EOF - rewind before worksheet BOF record (see above) if( bRet && isBofRecord() ) diff --git a/oox/source/xls/workbookhelper.cxx b/oox/source/xls/workbookhelper.cxx index 9794b58e6a1b..afeed95accca 100644 --- a/oox/source/xls/workbookhelper.cxx +++ b/oox/source/xls/workbookhelper.cxx @@ -136,6 +136,10 @@ public: inline sal_Int16 getCurrentSheetIndex() const { return mnCurrSheet; } /** Sets the index of the current sheet in the Calc document. */ inline void setCurrentSheetIndex( sal_Int16 nSheet ) { mnCurrSheet = nSheet; } + /** Returns the VBA project storage. */ + inline StorageRef getVbaProjectStorage() const { return mxVbaPrjStrg; } + /** Sets the VBA project storage. */ + inline void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ) { mxVbaPrjStrg = rxVbaPrjStrg; } // document model --------------------------------------------------------- @@ -201,8 +205,6 @@ public: inline ExcelChartConverter& getChartConverter() const { return *mxChartConverter; } /** Returns the page/print settings converter. */ inline PageSettingsConverter& getPageSettingsConverter() const { return *mxPageSettConverter; } - /** Returns the VBA project used to import/export VBA and attach events. */ - inline VbaProject& getVbaProject() const { return *mxVbaProject; } // OOX specific ----------------------------------------------------------- @@ -256,7 +258,6 @@ private: typedef ::std::auto_ptr< AddressConverter > AddressConvPtr; typedef ::std::auto_ptr< ExcelChartConverter > ExcelChartConvPtr; typedef ::std::auto_ptr< PageSettingsConverter > PageSettConvPtr; - typedef ::std::auto_ptr< VbaProject > VbaProjectPtr; typedef ::std::auto_ptr< BiffCodecHelper > BiffCodecHelperPtr; OUString maCellStyles; /// Style family name for cell styles. @@ -268,6 +269,7 @@ private: ExcelFilterBase& mrExcelBase; /// Base object for registration of this structure. FilterType meFilterType; /// File type of the filter. ProgressBarPtr mxProgressBar; /// The progress bar. + StorageRef mxVbaPrjStrg; /// Storage containing the VBA project. sal_Int16 mnCurrSheet; /// Current sheet index in Calc dcument. bool mbWorkbook; /// True = multi-sheet file. @@ -292,7 +294,6 @@ private: AddressConvPtr mxAddrConverter; /// Cell address and cell range address converter. ExcelChartConvPtr mxChartConverter; /// Chart object converter. PageSettConvPtr mxPageSettConverter; /// Page/print settings converter. - VbaProjectPtr mxVbaProject; /// VBA project. // OOX specific XmlFilterBase* mpOoxFilter; /// Base OOX filter object. @@ -549,7 +550,6 @@ void WorkbookData::initialize( bool bWorkbookFile ) mxAddrConverter.reset( new AddressConverter( *this ) ); mxChartConverter.reset( new ExcelChartConverter( *this ) ); mxPageSettConverter.reset( new PageSettingsConverter( *this ) ); - mxVbaProject.reset( new VbaProject( mrBaseFilter.getGlobalFactory(), mxDoc ) ); // set some document properties needed during import if( mrBaseFilter.isImportFilter() ) @@ -659,6 +659,11 @@ void WorkbookHelper::setCurrentSheetIndex( sal_Int16 nSheet ) mrBookData.setCurrentSheetIndex( nSheet ); } +void WorkbookHelper::setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ) +{ + mrBookData.setVbaProjectStorage( rxVbaPrjStrg ); +} + void WorkbookHelper::finalizeWorkbookImport() { // workbook settings, document and sheet view settings @@ -681,8 +686,16 @@ void WorkbookHelper::finalizeWorkbookImport() PropertySet aDefPageStyle( getStyleObject( CREATE_OUSTRING( "Default" ), true ) ); aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 ); - // attach VBA macros to document and sheet events - getVbaProject().attachToEvents(); + /* Import the VBA project (after finalizing workbook settings which + contains the workbook code name), and attach VBA macros to document and + sheet events. */ + StorageRef xVbaPrjStrg = mrBookData.getVbaProjectStorage(); + if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() ) + { + VbaProject aVbaProject( getGlobalFactory(), getDocument() ); + aVbaProject.importVbaProject( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() ); + aVbaProject.attachToEvents(); + } } // document model ------------------------------------------------------------- @@ -892,11 +905,6 @@ PageSettingsConverter& WorkbookHelper::getPageSettingsConverter() const return mrBookData.getPageSettingsConverter(); } -VbaProject& WorkbookHelper::getVbaProject() const -{ - return mrBookData.getVbaProject(); -} - // OOX specific --------------------------------------------------------------- XmlFilterBase& WorkbookHelper::getOoxFilter() const -- cgit From 0f0f6396110e83a99f979a37f0cfe3e11ec6faa6 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 14 Apr 2010 20:47:35 +0100 Subject: npower13_objectmodules: fix order of XModuleInfo/Module creation order --- oox/source/ole/vbamodule.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx index b5319672d538..ff4c37e93b88 100755 --- a/oox/source/ole/vbamodule.cxx +++ b/oox/source/ole/vbamodule.cxx @@ -214,24 +214,24 @@ void VbaModule::importSourceCode( StorageBase& rVbaStrg, if( !mbExecutable ) aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End Sub\n" ) ); - // insert the module into the passed Basic library + // insert extended module info try { - rxBasicLib->insertByName( maName, Any( aSourceCode.makeStringAndClear() ) ); + Reference< XVBAModuleInfo > xVBAModuleInfo( rxBasicLib, UNO_QUERY_THROW ); + xVBAModuleInfo->insertModuleInfo( maName, aModuleInfo ); } catch( Exception& ) { - OSL_ENSURE( false, "VbaModule::importSourceCode - cannot insert module into library" ); } - // insert extended module info + // insert the module into the passed Basic library try { - Reference< XVBAModuleInfo > xVBAModuleInfo( rxBasicLib, UNO_QUERY_THROW ); - xVBAModuleInfo->insertModuleInfo( maName, aModuleInfo ); + rxBasicLib->insertByName( maName, Any( aSourceCode.makeStringAndClear() ) ); } catch( Exception& ) { + OSL_ENSURE( false, "VbaModule::importSourceCode - cannot insert module into library" ); } } -- cgit From 17d93702799ada4b7d07720e9a6573d38c4d7484 Mon Sep 17 00:00:00 2001 From: Vladimir Glazunov Date: Thu, 15 Apr 2010 16:54:54 +0200 Subject: #i109357# changes for glibc2.5 --- solenv/config/sdev300.ini | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/solenv/config/sdev300.ini b/solenv/config/sdev300.ini index 907d5295c15c..9bce93121760 100644 --- a/solenv/config/sdev300.ini +++ b/solenv/config/sdev300.ini @@ -559,7 +559,7 @@ unxlngi6 COPY_PACKED TRUE DEVROOT %SOL_TMP%$/r PCLEAN_PATH %SOLARROOT%/etools - PERL %SOL_TMP%$/r$/bt_linux_libc2.32$/%WORK_STAMP%$/bin$/perl + PERL %SOL_TMP%$/r$/bt_linux_libc2.5$/%WORK_STAMP%$/bin$/perl SOLARENV %SOL_TMP%$/o%CWS_WORK_STAMP_EXT%$/%WORK_STAMP%$/ooo%UPDMINOREXT%$/solenv SOLARROOT %SOL_TMP%$/r SOLARVER %SOL_TMP%$/o%CWS_WORK_STAMP_EXT%/%WORK_STAMP% @@ -571,7 +571,7 @@ unxlngi6 COPYALL FALSE DEVROOT %SOL_TMP%$/r PCLEAN_PATH %SOL_TMP%$/r/etools - PERL %SOL_TMP%$/r$/bt_linux_libc2.32$/%WORK_STAMP%$/bin$/perl + PERL %SOL_TMP%$/r$/bt_linux_libc2.5$/%WORK_STAMP%$/bin$/perl SOLARENV %SOL_TMP%$/o%CWS_WORK_STAMP_EXT%$/%WORK_STAMP%$/ooo%UPDMINOREXT%$/solenv SOLARROOT %SOL_TMP%$/r SOLARVER %SOL_TMP%$/o%CWS_WORK_STAMP_EXT%/%WORK_STAMP% @@ -606,14 +606,14 @@ unxlngi6 { SOLAR_ENV_ROOT /so/env SOLAR_SOURCE_ROOT %DRIVE_O% - SOLAR_SYSBASE_ROOT /so/env/gcc_4.2.3_linux_libc2.32/glibc2.3.2 + SOLAR_SYSBASE_ROOT /so/env/gcc_4.2.3_linux_libc2.5/glibc2.5 } common1 { - COMPATH %SOLAR_ENV_ROOT%$/gcc_4.2.3_linux_libc2.32 + COMPATH %SOLAR_ENV_ROOT%$/gcc_4.2.3_linux_libc2.5 DEVROOT %SOLAR_ENV_ROOT% LFS_CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 - PERL %SOLAR_ENV_ROOT%/bt_linux_libc2.32/%WORK_STAMP%/bin/perl + PERL %SOLAR_ENV_ROOT%/bt_linux_libc2.5/%WORK_STAMP%/bin/perl PKGFORMAT rpm SHARED_SOLARENV %SOLAR_SOURCE_ROOT%/%WORK_STAMP%/ooo%UPDMINOREXT%/solenv SHARED_SOLARVERSION %SOLAR_SOURCE_ROOT%/%WORK_STAMP% @@ -631,7 +631,7 @@ unxlngi6 common2 { ENABLE_GRAPHITE TRUE - BUILD_TOOLS %SOLARROOT%/bt_linux_libc2.32/%WORK_STAMP%/bin + BUILD_TOOLS %SOLARROOT%/bt_linux_libc2.5/%WORK_STAMP%/bin COM GCC COMMON_BUILD_TOOLS %SOLARROOT%$/btools COMMON_ENV_TOOLS %SOLARROOT%$/etools @@ -641,7 +641,7 @@ unxlngi6 ENABLE_KAB TRUE ENABLE_KDE TRUE ENABLE_EVOAB2 TRUE - ENV_TOOLS %SOLARROOT%/et_linux_libc2.32/%WORK_STAMP%/bin + ENV_TOOLS %SOLARROOT%/et_linux_libc2.5/%WORK_STAMP%/bin GUI UNX GUIBASE unx GVER VCL -- cgit From 11a8887e1fca7b9273d61c9cab4041688aee9c6f Mon Sep 17 00:00:00 2001 From: Vladimir Glazunov Date: Thu, 15 Apr 2010 16:54:54 +0200 Subject: #i109357# changes for glibc2.5 --- moz/makefile.mk | 6 +++++- moz/patches/linux_libc2.5.patch | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 moz/patches/linux_libc2.5.patch diff --git a/moz/makefile.mk b/moz/makefile.mk index c1649d2f8b85..d827266fab50 100644 --- a/moz/makefile.mk +++ b/moz/makefile.mk @@ -83,7 +83,11 @@ TARFILE_ROOTDIR=mozilla PATCH_FILES = \ seamonkey-source-$(MOZILLA_VERSION).patch \ patches/dtoa.patch \ - patches/respect_disable_pango.patch \ + patches/respect_disable_pango.patch + +.IF "$(OUTPATH)"=="unxlngi6" +PATCH_FILES += patches/linux_libc2.5.patch +.ENDIF # This file is needed for the W32 build when BUILD_MOZAB is set # (currently only vc8/vs2005 is supported when BUILD_MOZAB is set) diff --git a/moz/patches/linux_libc2.5.patch b/moz/patches/linux_libc2.5.patch new file mode 100644 index 000000000000..b7f18141f457 --- /dev/null +++ b/moz/patches/linux_libc2.5.patch @@ -0,0 +1,11 @@ +--- misc/mozilla/configure 2010-04-14 18:08:55.402759185 +0200 ++++ misc/build/mozilla/configure 2010-04-14 18:07:13.036410334 +0200 +@@ -11886,7 +11886,7 @@ + $(DIST)/lib/$(LIB_PREFIX)nss'$NSS_VERSION'.$(IMPORT_LIB_SUFFIX) \\\ + $(DIST)/lib/$(LIB_PREFIX)softokn'$NSS_VERSION'.$(IMPORT_LIB_SUFFIX)' + else +- NSS_LIBS='-L$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lsoftokn$NSS_VERSION" ++ NSS_LIBS='-L$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION -lsoftokn$NSS_VERSION" + fi + fi + -- cgit From dc295f1cf1c99b2dbe0760c7542a92febb33a27d Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Thu, 15 Apr 2010 19:46:12 +0200 Subject: npower13_objectmodules: would be a good idea to really seek the wrapped stream... --- oox/source/helper/binaryinputstream.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/oox/source/helper/binaryinputstream.cxx b/oox/source/helper/binaryinputstream.cxx index 9ca6938f2ff1..a5a3cf9a2c30 100644 --- a/oox/source/helper/binaryinputstream.cxx +++ b/oox/source/helper/binaryinputstream.cxx @@ -321,6 +321,7 @@ void RelativeInputStream::skip( sal_Int32 nBytes ) if( !mbEof ) { sal_Int32 nSkipBytes = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, mnLength - mnRelPos ); + mrInStrm.skip( nSkipBytes ); mnRelPos += nSkipBytes; mbEof = nSkipBytes < nBytes; } -- cgit From 3a8d3af3d9f9ba84156525c6737a4aa14eb8ccee Mon Sep 17 00:00:00 2001 From: Gregor Hartmann Date: Fri, 16 Apr 2010 14:10:50 +0200 Subject: add declaration of unoToSbxValue to header instead of in several cxx files --- basic/inc/basic/sbuno.hxx | 2 ++ basic/source/classes/eventatt.cxx | 6 +----- basic/source/classes/sbunoobj.cxx | 2 +- basic/source/runtime/step1.cxx | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/basic/inc/basic/sbuno.hxx b/basic/inc/basic/sbuno.hxx index 68e2c6ab8778..d816d424313b 100644 --- a/basic/inc/basic/sbuno.hxx +++ b/basic/inc/basic/sbuno.hxx @@ -41,5 +41,7 @@ void createAllObjectProperties( SbxObject* pObj ); ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar ); +void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue ); + #endif diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx index 5c57af5b6ce8..4bd9a981bddb 100644 --- a/basic/source/classes/eventatt.cxx +++ b/basic/source/classes/eventatt.cxx @@ -62,6 +62,7 @@ #include #include #include +#include #include #include @@ -85,11 +86,6 @@ using namespace ::osl; -//=================================================================== -void unoToSbxValue( SbxVariable* pVar, const Any& aValue ); -Any sbxToUnoValue( SbxVariable* pVar ); - - Reference< frame::XModel > getModelFromBasic( SbxObject* pBasic ) { OSL_PRECOND( pBasic != NULL, "getModelFromBasic: illegal call!" ); diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 1e278bf583a7..476dfbc90686 100755 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -564,7 +564,7 @@ SbxDataType unoToSbxType( const Reference< XIdlClass >& xIdlClass ) } return eRetType; } -void unoToSbxValue( SbxVariable* pVar, const Any& aValue ); + static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int32 >& indices, Sequence< sal_Int32 >& sizes, const Any& aValue, sal_Int32& dimension, sal_Bool bIsZeroIndex, Type* pType = NULL ) { Type aType = aValue.getValueType(); diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx index 399257cf6ad3..fafb71acfeb3 100644 --- a/basic/source/runtime/step1.cxx +++ b/basic/source/runtime/step1.cxx @@ -30,6 +30,7 @@ #include #include +#include #include "runtime.hxx" #include "sbintern.hxx" #include "iosys.hxx" @@ -230,8 +231,6 @@ void SbiRuntime::StepRETURN( UINT32 nOp1 ) // FOR-Variable testen (+Endlabel) -void unoToSbxValue( SbxVariable* pVar, const Any& aValue ); - void SbiRuntime::StepTESTFOR( UINT32 nOp1 ) { if( !pForStk ) -- cgit From 591628e221db19e0ebe86208bea9c522c8c9c629 Mon Sep 17 00:00:00 2001 From: Gregor Hartmann Date: Fri, 16 Apr 2010 14:12:57 +0200 Subject: add new VCLTestTool methods for TableControl --- automation/source/server/statemnt.cxx | 143 +++++++++++++++++++++------------- 1 file changed, 91 insertions(+), 52 deletions(-) diff --git a/automation/source/server/statemnt.cxx b/automation/source/server/statemnt.cxx index 71e76f146e10..89be43de60ab 100644 --- a/automation/source/server/statemnt.cxx +++ b/automation/source/server/statemnt.cxx @@ -97,6 +97,7 @@ #include #endif #include +#include #include #include #include @@ -6185,9 +6186,65 @@ protected: { ::svt::table::PTableModel pModel = pTC->GetModel(); Any aCell = pModel->getCellContent()[nNr2-1][nNr1-1]; - ::rtl::OUString aContent; - aCell >>= aContent; - pRet->GenReturn ( RET_Value, aUId, aContent ); + /* doesn't work ATM since it gets casted to SbxDATE in VCLTestTool unfortunately + SbxVariableRef xRes = new SbxVariable( SbxVARIANT ); + unoToSbxValue( xRes, aCell ); + pRet->GenReturn ( RET_Value, aUId, *xRes );*/ + + Type aType = aCell.getValueType(); + TypeClass eTypeClass = aType.getTypeClass(); + switch( eTypeClass ) + { + /*case TypeClass_ENUM: + { + sal_Int32 nEnum = 0; + enum2int( nEnum, aValue ); + pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)nEnum ); + } + break;*/ + case TypeClass_BOOLEAN: + pRet->GenReturn ( RET_Value, aUId, *(sal_Bool*)aCell.getValue() ); + break; + case TypeClass_CHAR: + { + ::rtl::OUString aContent( *(sal_Unicode*)aCell.getValue() ); + pRet->GenReturn ( RET_Value, aUId, aContent ); + } + break; + case TypeClass_STRING: + { + ::rtl::OUString aContent; + aCell >>= aContent; + pRet->GenReturn ( RET_Value, aUId, aContent ); + } + break; + //case TypeClass_FLOAT: break; + //case TypeClass_DOUBLE: break; + //case TypeClass_OCTET: break; + case TypeClass_BYTE: + case TypeClass_SHORT: + case TypeClass_LONG: + case TypeClass_HYPER: + case TypeClass_UNSIGNED_LONG: + case TypeClass_UNSIGNED_HYPER: + { + comm_ULONG val = 0; + aCell >>= val; + pRet->GenReturn ( RET_Value, aUId, val ); + } + break; + //case TypeClass_UNSIGNED_OCTET:break; + case TypeClass_UNSIGNED_SHORT: + { + comm_USHORT val = 0; + aCell >>= val; + pRet->GenReturn ( RET_Value, aUId, val ); + } + break; + default: + pRet->GenReturn ( RET_Value, aUId, comm_USHORT(0) ); + break; + } } } break; @@ -6201,43 +6258,49 @@ protected: pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTC->GetRowCount() ); } break; -/* case M_IsEditing : - { - CellControllerRef aControler; - aControler = pEBBox->Controller(); - pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)aControler.Is() ); - } - break;*/ case M_Select : { - if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetColumnCount() ) && - ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() )) + if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetRowCount() )) { - if ( pTC->GoTo( ::svt::table::ColPos( nNr1 ), ::svt::table::RowPos( nNr2 ) ) ) - pTC->Select(); + if ( pTC->GoToRow( ::svt::table::RowPos( nNr1-1 ) ) ) + { + Size aSize( pTC->GetSizePixel() ); +// DirectLog( S_QAError, UniString::CreateFromInt32( aSize.Width() ).Append( UniString::CreateFromInt32( aSize.Height() ) ) ); + Point aPos( aSize.Width() / 2, aSize.Height() / 2 ); + long nStep = aSize.Height() / 4; + ::svt::table::RowPos nLastPos; + while ( ( nLastPos = pTC->GetCurrentRow( aPos ) ) != nNr1-1 && nStep > 0 ) + { + if ( nLastPos > nNr1-1 ) + aPos.Y() -= nStep; + else + aPos.Y() += nStep; + nStep /= 2; + } + if ( pTC->GetCurrentRow( aPos ) == nNr1-1 ) + { + MouseEvent aMEvnt(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,MOUSE_LEFT,KEY_MOD1); + pTC->getSelEngine()->SelMouseButtonDown( aMEvnt ); + pTC->getSelEngine()->SelMouseButtonUp( aMEvnt ); + } + else + ReportError( aUId, GEN_RES_STR2c2( S_METHOD_FAILED, MethodString( nMethodId ), "find pos" ) ); + } else ReportError( aUId, GEN_RES_STR2c2( S_METHOD_FAILED, MethodString( nMethodId ), "GoTo" ) ); } } break; - - - - -/* case M_GetSelCount : - pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount())); + case M_GetSelCount : + pRet->GenReturn ( RET_Value, aUId, comm_USHORT( pTC->GetSelectedRows().size() )); break; case M_GetSelIndex : if ( ! (nParams & PARAM_USHORT_1) ) nNr1 = 1; - if ( ValueOK(aUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) ) - { - nNr1--; - COUNT_LBOX( FirstSelected, NextSelected, nNr1); - pRet->GenReturn ( RET_Value, aUId, comm_ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 ); - } + if ( ValueOK( aUId, CUniString("GetSelIndex"), nNr1, pTC->GetSelectedRows().size() ) ) + pRet->GenReturn ( RET_Value, aUId, comm_USHORT( pTC->GetSelectedRows()[nNr1-1] +1 ) ); break; - case M_GetSelText : +/* case M_GetSelText : if ( ! (nParams & PARAM_USHORT_1) ) nNr1 = 1; if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) ) @@ -6248,31 +6311,7 @@ protected: pRet->GenReturn ( RET_Value, aUId, pItem->GetText() ); } break; - case M_Select : - if ( ! (nParams & PARAM_BOOL_1) ) - bBool1 = TRUE; - if( nParams & PARAM_STR_1 ) - { - / * ListBox *pLB = ((ListBox*)pControl); - if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND ) - ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) ); - else - { - pLB->SelectEntry( aString1, bBool1 ); - if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL - ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) ); - } - * / ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) ); - } - else - { - if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) ) - { - SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 ); - ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 ); - } - } - break;*/ + */ default: ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TableControl" ) ); break; -- cgit From 02f50ebfc8097e6bebb607b9faa82f3baff0421e Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 14:47:11 +0200 Subject: npower13_objectmodules: use document frame from media descriptor --- oox/inc/oox/core/filterbase.hxx | 5 +++++ oox/inc/oox/helper/graphichelper.hxx | 4 +++- oox/source/core/filterbase.cxx | 10 +++++++++- oox/source/helper/graphichelper.cxx | 28 ++++++++++++++++++++-------- oox/source/ppt/pptimport.cxx | 2 +- oox/source/xls/stylesbuffer.cxx | 2 +- 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/oox/inc/oox/core/filterbase.hxx b/oox/inc/oox/core/filterbase.hxx index b2709ea4b33b..31e26d38f590 100644 --- a/oox/inc/oox/core/filterbase.hxx +++ b/oox/inc/oox/core/filterbase.hxx @@ -49,6 +49,7 @@ namespace com { namespace sun { namespace star { namespace frame { class XModel; } namespace task { class XStatusIndicator; } namespace task { class XInteractionHandler; } + namespace frame { class XFrame; } namespace io { class XInputStream; } namespace io { class XOutputStream; } namespace io { class XStream; } @@ -123,6 +124,10 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getModelFactory() const; + /** Returns the frame that will contain the document model. */ + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& + getTargetFrame() const; + /** Returns the status indicator (may be null). */ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >& getStatusIndicator() const; diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx index dc9dddfea7e8..2d0964b37715 100644 --- a/oox/inc/oox/helper/graphichelper.hxx +++ b/oox/inc/oox/helper/graphichelper.hxx @@ -40,6 +40,7 @@ namespace com { namespace sun { namespace star { namespace awt { struct Size; } namespace awt { class XUnitConversion; } namespace io { class XInputStream; } + namespace frame { class XFrame; } namespace graphic { class XGraphic; } namespace graphic { class XGraphicObject; } namespace graphic { class XGraphicProvider; } @@ -66,7 +67,8 @@ class GraphicHelper { public: explicit GraphicHelper( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory ); + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxTargetFrame ); virtual ~GraphicHelper(); /** Returns a system color specified by the passed XML token identifier. */ diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index 27a1b26fbcfd..902784cafe80 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -55,6 +55,7 @@ using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::lang::XComponent; using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::frame::XFrame; using ::com::sun::star::frame::XModel; using ::com::sun::star::io::XInputStream; using ::com::sun::star::io::XOutputStream; @@ -148,6 +149,7 @@ struct FilterBaseImpl Reference< XMultiServiceFactory > mxGlobalFactory; Reference< XModel > mxModel; Reference< XMultiServiceFactory > mxModelFactory; + Reference< XFrame > mxTargetFrame; Reference< XInputStream > mxInStream; Reference< XStream > mxOutStream; Reference< XStatusIndicator > mxStatusIndicator; @@ -261,6 +263,11 @@ const Reference< XMultiServiceFactory >& FilterBase::getModelFactory() const return mxImpl->mxModelFactory; } +const Reference< XFrame >& FilterBase::getTargetFrame() const +{ + return mxImpl->mxTargetFrame; +} + const Reference< XStatusIndicator >& FilterBase::getStatusIndicator() const { return mxImpl->mxStatusIndicator; @@ -572,6 +579,7 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc } mxImpl->maFileUrl = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() ); + mxImpl->mxTargetFrame = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_FRAME(), Reference< XFrame >() ); mxImpl->mxStatusIndicator = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STATUSINDICATOR(), Reference< XStatusIndicator >() ); mxImpl->mxInteractionHandler = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() ); } @@ -579,7 +587,7 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc GraphicHelper* FilterBase::implCreateGraphicHelper() const { // default: return base implementation without any special behaviour - return new GraphicHelper( mxImpl->mxGlobalFactory ); + return new GraphicHelper( mxImpl->mxGlobalFactory, mxImpl->mxTargetFrame ); } // ============================================================================ diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx index 6e57ac8f2b2f..6b294f61abef 100644 --- a/oox/source/helper/graphichelper.cxx +++ b/oox/source/helper/graphichelper.cxx @@ -76,7 +76,7 @@ inline sal_Int32 lclConvertScreenPixelToHmm( double fPixel, double fPixelPerHmm // ============================================================================ -GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalFactory ) : +GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalFactory, const Reference< XFrame >& rxTargetFrame ) : mxGraphicProvider( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ), maGraphicObjScheme( CREATE_OUSTRING( "vnd.sun.star.GraphicObject:" ) ) { @@ -115,21 +115,34 @@ GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxGlobalF maSystemPalette[ XML_windowFrame ] = 0x000000; maSystemPalette[ XML_windowText ] = 0x000000; - // get the metric of the output device - if( rxGlobalFactory.is() ) try + // if no target frame has been passed (e.g. OLE objects), try to fallback to the active frame + // TODO: we need some mechanism to keep and pass the parent frame + Reference< XFrame > xFrame = rxTargetFrame; + if( !xFrame.is() && rxGlobalFactory.is() ) try { Reference< XFramesSupplier > xFramesSupp( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY_THROW ); - Reference< XFrame > xFrame( xFramesSupp->getActiveFrame(), UNO_SET_THROW ); + xFrame = xFramesSupp->getActiveFrame(); + } + catch( Exception& ) + { + } + + // get the metric of the output device + OSL_ENSURE( xFrame.is(), "GraphicHelper::GraphicHelper - cannot get target frame" ); + maDeviceInfo.PixelPerMeterX = maDeviceInfo.PixelPerMeterY = 3500.0; // some default just in case + if( xFrame.is() ) try + { Reference< XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW ); mxUnitConversion.set( xDevice, UNO_QUERY ); + OSL_ENSURE( mxUnitConversion.is(), "GraphicHelper::GraphicHelper - cannot get unit converter" ); maDeviceInfo = xDevice->getInfo(); - mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0; - mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0; } catch( Exception& ) { OSL_ENSURE( false, "GraphicHelper::GraphicHelper - cannot get output device info" ); } + mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0; + mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0; } GraphicHelper::~GraphicHelper() @@ -138,8 +151,7 @@ GraphicHelper::~GraphicHelper() sal_Int32 GraphicHelper::getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ) const { - const sal_Int32* pnColor = ContainerHelper::getMapElement( maSystemPalette, nToken ); - return pnColor ? *pnColor : nDefaultRgb; + return ContainerHelper::getMapElement( maSystemPalette, nToken, nDefaultRgb ); } sal_Int32 GraphicHelper::getSchemeColor( sal_Int32 /*nToken*/ ) const diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx index 578d469395db..39ad52316a92 100644 --- a/oox/source/ppt/pptimport.cxx +++ b/oox/source/ppt/pptimport.cxx @@ -163,7 +163,7 @@ private: }; PptGraphicHelper::PptGraphicHelper( const PowerPointImport& rFilter ) : - GraphicHelper( rFilter.getGlobalFactory() ), + GraphicHelper( rFilter.getGlobalFactory(), rFilter.getTargetFrame() ), mrFilter( rFilter ) { } diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx index e18f47a378ed..e48104065315 100644 --- a/oox/source/xls/stylesbuffer.cxx +++ b/oox/source/xls/stylesbuffer.cxx @@ -305,7 +305,7 @@ sal_Int32 lclReadRgbColor( BinaryInputStream& rStrm ) // ============================================================================ ExcelGraphicHelper::ExcelGraphicHelper( const WorkbookHelper& rHelper ) : - GraphicHelper( rHelper.getGlobalFactory() ), + GraphicHelper( rHelper.getGlobalFactory(), rHelper.getBaseFilter().getTargetFrame() ), WorkbookHelper( rHelper ) { } -- cgit From 7d7fc88ec456d716350f24c4eb6ce5fa2de4b440 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 14:47:11 +0200 Subject: npower13_objectmodules: use document frame from media descriptor --- offapi/com/sun/star/document/MediaDescriptor.idl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/offapi/com/sun/star/document/MediaDescriptor.idl b/offapi/com/sun/star/document/MediaDescriptor.idl index 72690a45eccd..89a3141a443d 100644 --- a/offapi/com/sun/star/document/MediaDescriptor.idl +++ b/offapi/com/sun/star/document/MediaDescriptor.idl @@ -51,6 +51,10 @@ #include #endif +#ifndef __com_sun_star_frame_XFrame_idl__ +#include +#endif + //============================================================================= module com { module sun { module star { module document { @@ -594,6 +598,11 @@ published service MediaDescriptor @since OOo 3.0 */ [optional,property] string ViewControllerName; + //------------------------------------------------------------------------- + + /** specifies the frame containing the document. May be empty. + */ + [optional,property] com::sun::star::frame::XFrame Frame; }; //============================================================================= -- cgit From 63c03e7f1bb7349cd4168ed30a0535f7c928207f Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 14:47:11 +0200 Subject: npower13_objectmodules: use document frame from media descriptor --- comphelper/inc/comphelper/mediadescriptor.hxx | 1 + comphelper/source/misc/mediadescriptor.cxx | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/comphelper/inc/comphelper/mediadescriptor.hxx b/comphelper/inc/comphelper/mediadescriptor.hxx index ac9661c76ebc..e20440a3d30d 100644 --- a/comphelper/inc/comphelper/mediadescriptor.hxx +++ b/comphelper/inc/comphelper/mediadescriptor.hxx @@ -83,6 +83,7 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap static const ::rtl::OUString& PROP_FILTERNAME(); static const ::rtl::OUString& PROP_FILTEROPTIONS(); static const ::rtl::OUString& PROP_FORMAT(); + static const ::rtl::OUString& PROP_FRAME(); static const ::rtl::OUString& PROP_FRAMENAME(); static const ::rtl::OUString& PROP_HIDDEN(); static const ::rtl::OUString& PROP_INPUTSTREAM(); diff --git a/comphelper/source/misc/mediadescriptor.cxx b/comphelper/source/misc/mediadescriptor.cxx index 7e3be338992b..1710a43027cf 100644 --- a/comphelper/source/misc/mediadescriptor.cxx +++ b/comphelper/source/misc/mediadescriptor.cxx @@ -183,6 +183,12 @@ const ::rtl::OUString& MediaDescriptor::PROP_FORMAT() return sProp; } +const ::rtl::OUString& MediaDescriptor::PROP_FRAME() +{ + static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Frame")); + return sProp; +} + const ::rtl::OUString& MediaDescriptor::PROP_FRAMENAME() { static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("FrameName")); -- cgit From 219103d56e4c84589ab2eec75cc77f420a1dfa0d Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 16 Apr 2010 16:55:27 +0200 Subject: gridcontrol_03:fixes for #i110947#, #i110521# --- svtools/inc/svtools/table/abstracttablecontrol.hxx | 1 + svtools/inc/svtools/table/tablecontrol.hxx | 7 +- svtools/inc/svtools/table/tabledatawindow.hxx | 7 + svtools/inc/svtools/table/tablemodel.hxx | 1 - svtools/source/table/defaultinputhandler.cxx | 18 +- svtools/source/table/gridtablerenderer.cxx | 186 +++++------- svtools/source/table/tablecontrol.cxx | 14 +- svtools/source/table/tablecontrol_impl.cxx | 325 ++++++++++++--------- svtools/source/table/tablecontrol_impl.hxx | 3 +- svtools/source/table/tabledatawindow.cxx | 20 +- svtools/source/uno/svtxgridcontrol.cxx | 15 +- 11 files changed, 316 insertions(+), 281 deletions(-) diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx index 95ac7b6bdd94..849c2cd23905 100644 --- a/svtools/inc/svtools/table/abstracttablecontrol.hxx +++ b/svtools/inc/svtools/table/abstracttablecontrol.hxx @@ -121,6 +121,7 @@ namespace svt { namespace table virtual void resizeColumn(const Point& rPoint ) = 0; virtual bool startResizeColumn(const Point& rPoint) = 0; virtual bool endResizeColumn(const Point& rPoint) = 0; + virtual bool isRowSelected(RowPos _nRow); virtual ~IAbstractTableControl() {}; }; diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index cfb4357eb5ac..313b2b7b7735 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -69,7 +69,10 @@ namespace svt { namespace table class SVT_DLLPUBLIC TableControl : public Control, public IAccessibleTable { private: - DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplMouseButtonDownHdl, MouseEvent* ); + DECL_DLLPRIVATE_LINK( ImplMouseButtonUpHdl, MouseEvent* ); + + DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); TableControl_Impl* m_pImpl; ::com::sun::star::uno::Sequence< sal_Int32 > m_nCols; @@ -185,7 +188,6 @@ namespace svt { namespace table virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet, AccessibleTableControlObjType eObjType ) const; - //// Window virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ); virtual void GrabFocus(); @@ -221,6 +223,7 @@ namespace svt { namespace table void setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols); void selectionChanged(bool _bChanged); + protected: /// retrieves the XAccessible implementation associated with the GridControl instance ::svt::IAccessibleFactory& getAccessibleFactory(); diff --git a/svtools/inc/svtools/table/tabledatawindow.hxx b/svtools/inc/svtools/table/tabledatawindow.hxx index 00630be35ae4..0e65f9847816 100644 --- a/svtools/inc/svtools/table/tabledatawindow.hxx +++ b/svtools/inc/svtools/table/tabledatawindow.hxx @@ -52,9 +52,16 @@ namespace svt { namespace table friend class TableFunctionSet; private: TableControl_Impl& m_rTableControl; + Link m_aMouseButtonDownHdl; + Link m_aMouseButtonUpHdl; Link m_aSelectHdl; + RowPos m_nRowAlreadySelected; public: TableDataWindow( TableControl_Impl& _rTableControl ); + inline void SetMouseButtonDownHdl( const Link& rLink ) { m_aMouseButtonDownHdl = rLink; } + inline const Link& GetMouseButtonDownHdl() const { return m_aMouseButtonDownHdl; } + inline void SetMouseButtonUpHdl( const Link& rLink ) { m_aMouseButtonUpHdl = rLink; } + inline const Link& GetMouseButtonUpHdl() const { return m_aMouseButtonUpHdl; } inline void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } inline const Link& GetSelectHdl() const { return m_aSelectHdl; } diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index fbc60fb7bc0e..3da396d9d86c 100644 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -444,7 +444,6 @@ namespace svt { namespace table @param actWidth the given width of the table */ virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const = 0; - virtual bool hasVerticalScrollbar() =0; virtual bool hasHorizontalScrollbar() = 0; /** fills cells with content diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx index 6a33b96b2742..ad8f7a7562d3 100644 --- a/svtools/source/table/defaultinputhandler.cxx +++ b/svtools/source/table/defaultinputhandler.cxx @@ -77,21 +77,26 @@ namespace svt { namespace table { bool bHandled = false; Point aPoint = _rMEvt.GetPosPixel(); - if(_rControl.getCurrentRow(aPoint) == -1) + RowPos nRow = _rControl.getCurrentRow(aPoint); + if(nRow == -1) { m_bResize = _rControl.startResizeColumn(aPoint); bHandled = true; } - else if(_rControl.getCurrentRow(aPoint) >= 0) + else if(nRow >= 0) { if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION) { - LoseFocus(_rControl); _rControl.setCursorAtCurrentCell(aPoint); bHandled = true; } else - bHandled = _rControl.getSelEngine()->SelMouseButtonDown(_rMEvt); + { + if(!_rControl.isRowSelected(nRow)) + bHandled = _rControl.getSelEngine()->SelMouseButtonDown(_rMEvt); + else + bHandled = true; + } } return bHandled; } @@ -109,12 +114,12 @@ namespace svt { namespace table } else if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION) { - GetFocus(_rControl); - _rControl.setCursorAtCurrentCell(aPoint); bHandled = true; } else + { bHandled = _rControl.getSelEngine()->SelMouseButtonUp(_rMEvt); + } } else { @@ -224,7 +229,6 @@ namespace svt { namespace table // TODO return false; } - //........................................................................ } } // namespace svt::table //........................................................................ diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 5c7a8dbd6832..77db8fc30904 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -79,34 +79,21 @@ namespace svt { namespace table OSL_PRECOND( _bIsColHeaderArea || _bIsRowHeaderArea, "GridTableRenderer::PaintHeaderArea: invalid area flags!" ); - // fill the rows with alternating background colors _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); - Color background = m_pImpl->rModel.getHeaderBackgroundColor(); - Color line = m_pImpl->rModel.getLineColor(); - //default background and line color is white - //background and lines should have same color, that's means lines aren't visible - //in case line color isn't set and background color is set, this should be changed - if( background != 0xFFFFFF && line == 0xFFFFFF) - { - _rDevice.SetLineColor(background); - _rDevice.SetFillColor(background); - } - else - { - //if Line color is set, then it was user defined and should be visible - //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible - _rDevice.SetLineColor(line); - _rDevice.SetFillColor(background); - } + Color background = m_pImpl->rModel.getHeaderBackgroundColor(); + if( background != 0xFFFFFF) + _rDevice.SetFillColor(background); + else + _rDevice.SetFillColor(_rStyle.GetDialogColor()); + _rDevice.SetLineColor(_rStyle.GetSeparatorColor()); _rDevice.DrawRect( _rArea ); // delimiter lines at bottom/right _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); _rDevice.Pop(); - (void)_rStyle; - (void)_bIsColHeaderArea; - (void)_bIsRowHeaderArea; + (void)_bIsColHeaderArea; + (void)_bIsRowHeaderArea; } //-------------------------------------------------------------------- @@ -114,41 +101,30 @@ namespace svt { namespace table OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) { _rDevice.Push( PUSH_LINECOLOR); - //default background and line color is white - //background and lines should have same color, that's means lines aren't visible - //in case line color isn't set and background color is set, this should be changed - Color background = m_pImpl->rModel.getHeaderBackgroundColor(); - Color line = m_pImpl->rModel.getLineColor(); - if(line == 0xFFFFFF) - _rDevice.SetLineColor(_rStyle.GetShadowColor()); - else - //if Line color is set, then it was user defined and should be visible - //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible - _rDevice.SetLineColor(line); + _rDevice.SetLineColor(_rStyle.GetSeparatorColor()); _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight()); String sHeaderText; - PColumnModel pColumn = m_pImpl->rModel.getColumnModel( _nCol ); DBG_ASSERT( !!pColumn, "GridTableRenderer::PaintColumnHeader: invalid column model object!" ); if ( !!pColumn ) sHeaderText = pColumn->getName(); - _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); - ULONG nHorFlag = TEXT_DRAW_LEFT; - ULONG nVerFlag = TEXT_DRAW_TOP; - if(m_pImpl->rModel.getVerticalAlign() == 1) - nVerFlag = TEXT_DRAW_VCENTER; - else if(m_pImpl->rModel.getVerticalAlign() == 2) - nVerFlag = TEXT_DRAW_BOTTOM; - if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 1) - nHorFlag = TEXT_DRAW_CENTER; - else if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2) - nHorFlag = TEXT_DRAW_RIGHT; - Rectangle aRect(_rArea); - aRect.Left()+=4; aRect.Right()-=4; - aRect.Top()+=4; aRect.Bottom()-=4; - _rDevice.DrawText( aRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); - _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); + _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); + ULONG nHorFlag = TEXT_DRAW_LEFT; + ULONG nVerFlag = TEXT_DRAW_TOP; + if(m_pImpl->rModel.getVerticalAlign() == 1) + nVerFlag = TEXT_DRAW_VCENTER; + else if(m_pImpl->rModel.getVerticalAlign() == 2) + nVerFlag = TEXT_DRAW_BOTTOM; + if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 1) + nHorFlag = TEXT_DRAW_CENTER; + else if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2) + nHorFlag = TEXT_DRAW_RIGHT; + Rectangle aRect(_rArea); + aRect.Left()+=4; aRect.Right()-=4; + aRect.Top()+=2; aRect.Bottom()-=2; + _rDevice.DrawText( aRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); _rDevice.Pop(); (void)_bActive; @@ -168,95 +144,75 @@ namespace svt { namespace table _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); Color aRowBackground = m_pImpl->rModel.getOddRowBackgroundColor(); - Color line = m_pImpl->rModel.getLineColor(); - Color aRowBackground2 = m_pImpl->rModel.getEvenRowBackgroundColor(); - //if row is selected background color becomes blue, and lines should be also blue - //if they aren't user defined - if(_bSelected) - { - Color aSelected(_rStyle.GetHighlightColor()); - aRowBackground = aSelected; - if(line == 0xFFFFFF) - _rDevice.SetLineColor(aRowBackground); - else - _rDevice.SetLineColor(line); - } - //if row not selected, check the cases whether user defined backgrounds are set - //and set line color to be the same - else - { - if(aRowBackground2 != 0xFFFFFF && _nRow%2) + Color line = m_pImpl->rModel.getLineColor(); + Color aRowBackground2 = m_pImpl->rModel.getEvenRowBackgroundColor(); + //if row is selected background color becomes blue, and lines should be also blue + //if they aren't user defined + if(_bSelected) { - aRowBackground = aRowBackground2; + Color aSelected(_rStyle.GetHighlightColor()); + aRowBackground = aSelected; if(line == 0xFFFFFF) _rDevice.SetLineColor(aRowBackground); else _rDevice.SetLineColor(line); } - //fill the rows with alternating background colors if second background color is specified - else if(aRowBackground != 0xFFFFFF && line == 0xFFFFFF) - _rDevice.SetLineColor(aRowBackground); + //if row not selected, check the cases whether user defined backgrounds are set + //and set line color to be the same else { - //if Line color is set, then it was user defined and should be visible - //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible - _rDevice.SetLineColor(line); + if(aRowBackground2 != 0xFFFFFF && _nRow%2) + { + aRowBackground = aRowBackground2; + if(line == 0xFFFFFF) + _rDevice.SetLineColor(aRowBackground); + else + _rDevice.SetLineColor(line); + } + //fill the rows with alternating background colors if second background color is specified + else if(aRowBackground != 0xFFFFFF && line == 0xFFFFFF) + _rDevice.SetLineColor(aRowBackground); + else + { + //if Line color is set, then it was user defined and should be visible + //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible + _rDevice.SetLineColor(line); + } } - } - Rectangle aRect(_rRowArea); - if(m_pImpl->rModel.hasColumnHeaders() || _nRow != 0) - --aRect.Top(); - if(m_pImpl->rModel.hasRowHeaders()) - --aRect.Left(); _rDevice.SetFillColor( aRowBackground ); - _rDevice.DrawRect( aRect ); + _rDevice.DrawRect( _rRowArea ); // TODO: active? _rDevice.Pop(); - (void)_bActive; + (void)_bActive; } //-------------------------------------------------------------------- void GridTableRenderer::PaintRowHeader( bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText ) { - _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); - //default background and line color is white - //background and lines should have same color, that's means lines aren't visible - //in case line color isn't set and background color is set, this should be changed - Color background = m_pImpl->rModel.getHeaderBackgroundColor(); - Color line = m_pImpl->rModel.getLineColor(); - if(background != 0xFFFFFF && line == 0xFFFFFF) - { - _rDevice.SetLineColor(background); - } - else - { - //if Line color is set, then it was user defined and should be visible - //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible - _rDevice.SetLineColor(line); - } + _rDevice.Push( PUSH_LINECOLOR); + _rDevice.SetLineColor(_rStyle.GetSeparatorColor()); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); - _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); - ULONG nHorFlag = TEXT_DRAW_LEFT; - ULONG nVerFlag = TEXT_DRAW_TOP; - if(m_pImpl->rModel.getVerticalAlign() == 1) - nVerFlag = TEXT_DRAW_VCENTER; - else if(m_pImpl->rModel.getVerticalAlign() == 2) - nVerFlag = TEXT_DRAW_BOTTOM; - if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 1) - nHorFlag = TEXT_DRAW_CENTER; - else if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2) - nHorFlag = TEXT_DRAW_RIGHT; - Rectangle aRect(_rArea); - aRect.Left()+=4; aRect.Right()-=4; - aRect.Top()+=4; aRect.Bottom()-=4; + _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); + ULONG nHorFlag = TEXT_DRAW_LEFT; + ULONG nVerFlag = TEXT_DRAW_TOP; + if(m_pImpl->rModel.getVerticalAlign() == 1) + nVerFlag = TEXT_DRAW_VCENTER; + else if(m_pImpl->rModel.getVerticalAlign() == 2) + nVerFlag = TEXT_DRAW_BOTTOM; + if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 1) + nHorFlag = TEXT_DRAW_CENTER; + else if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2) + nHorFlag = TEXT_DRAW_RIGHT; + Rectangle aRect(_rArea); + aRect.Left()+=4; aRect.Right()-=4; + aRect.Top()+=2; aRect.Bottom()-=2; _rDevice.DrawText( aRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); // TODO: active? selected? (void)_bActive; (void)_bSelected; - (void)_rStyle; //at the moment no special paint for selected row header _rDevice.Pop(); } @@ -330,7 +286,6 @@ namespace svt { namespace table (void)_bActive; // no special painting for the active cell at the moment - (void)_rStyle; } //-------------------------------------------------------------------- @@ -392,13 +347,12 @@ namespace svt { namespace table nHorFlag = TEXT_DRAW_RIGHT; Rectangle textRect(_rArea); textRect.Left()+=4; textRect.Right()-=4; - textRect.Top()+=4; textRect.Bottom()-=4; + textRect.Top()+=2; textRect.Bottom()-=2; _rDevice.DrawText( textRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); } _rDevice.Pop(); (void)_bActive; // no special painting for the active cell at the moment - (void)_rStyle; } //-------------------------------------------------------------------- diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 7452bda6d02a..12def82d3ecf 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -71,6 +71,8 @@ namespace svt { namespace table ,m_pImpl( new TableControl_Impl( *this ) ) ,m_bSelectionChanged(false) { + m_pImpl->getDataWindow()->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) ); + m_pImpl->getDataWindow()->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) ); m_pImpl->getDataWindow()->SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) ); m_pAccessTable.reset(new ::svt::table::AccessibleTableControl_Impl()); } @@ -335,7 +337,7 @@ namespace svt { namespace table ::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const { - ::com::sun::star::uno::Any cellContent = ::com::sun::star::uno::Any(::rtl::OUString::createFromAscii("")); + ::com::sun::star::uno::Any cellContent(::com::sun::star::uno::Any(::rtl::OUString::createFromAscii(""))); std::vector >& aTableContent = GetModel()->getCellContent(); if(&aTableContent) cellContent = aTableContent[_nRowPos][_nColPos]; @@ -555,6 +557,16 @@ IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG ) Select(); return 1; } +IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData ) +{ + CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData ); + return 1; +} +IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData ) +{ + CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData ); + return 1; +} // ----------------------------------------------------------------------- void TableControl::Select() { diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 9ef171bf6c8c..4057be745097 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -580,88 +580,89 @@ namespace svt { namespace table m_aColumnWidthsPixel.reserve( colCount ); m_aAccColumnWidthsPixel.reserve( colCount ); long accumulatedPixelWidth = 0; - double gridWidth = m_rAntiImpl.GetSizePixel().Width()-4; - if(m_pModel->hasRowHeaders()) - { - TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); - gridWidth-= m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); - } - if(m_pModel->hasVerticalScrollbar()) - { - sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); - gridWidth-=scrollbarWidth; - } - double colWidthsSum = 0.0; - double colWithoutFixedWidthsSum = 0.0; - double minColWithoutFixedSum = 0.0; - for ( ColPos col = 0; col < colCount; ++col ) + double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width(); + if(m_pModel->hasRowHeaders()) { - PColumnModel pColumn = m_pModel->getColumnModel( col ); - DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); - if ( !pColumn ) - continue; - TableMetrics colWidth = 0; - TableMetrics colPrefWidth = pColumn->getPreferredWidth(); - bool bResizable = pColumn->isResizable(); - if(pColumn->getMinWidth() == 0 && bResizable) + TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); + gridWidth-= m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); + } + if(m_pModel->hasVerticalScrollbar()) { - pColumn->setMinWidth(1); - minColWithoutFixedSum+=m_rAntiImpl.LogicToPixel( Size( 1, 0 ), MAP_APPFONT ).Width(); + sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); + gridWidth-=scrollbarWidth; } - if(pColumn->getMaxWidth() == 0 && bResizable) - pColumn->setMaxWidth(m_rAntiImpl.LogicToPixel( Size( (int)gridWidth, 0 ), MAP_APPFONT ).Width()); - if( colPrefWidth != 0) + double colWidthsSum = 0.0; + double colWithoutFixedWidthsSum = 0.0; + double minColWithoutFixedSum = 0.0; + for ( ColPos col = 0; col < colCount; ++col ) { - if(m_bResizingGrid) + PColumnModel pColumn = m_pModel->getColumnModel( col ); + DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + if ( !pColumn ) + continue; + TableMetrics colWidth = 0; + TableMetrics colPrefWidth = pColumn->getPreferredWidth(); + bool bResizable = pColumn->isResizable(); + if(pColumn->getMinWidth() == 0 && bResizable) { - colWidth = pColumn->getWidth(); - pColumn->setPreferredWidth(0); + pColumn->setMinWidth(1); + minColWithoutFixedSum+=m_rAntiImpl.LogicToPixel( Size( 1, 0 ), MAP_APPFONT ).Width(); } - else + if(pColumn->getMaxWidth() == 0 && bResizable) + pColumn->setMaxWidth(m_rAntiImpl.LogicToPixel( Size( (int)gridWidth, 0 ), MAP_APPFONT ).Width()); + if( colPrefWidth != 0) { - colWidth = colPrefWidth; - pColumn->setWidth(colPrefWidth); + if(m_bResizingGrid) + { + colWidth = pColumn->getWidth(); + pColumn->setPreferredWidth(0); + } + else + { + colWidth = colPrefWidth; + pColumn->setWidth(colPrefWidth); + } } + else + colWidth = pColumn->getWidth(); + long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + if(bResizable && colPrefWidth == 0) + colWithoutFixedWidthsSum+=pixelWidth; + colWidthsSum+=pixelWidth; } - else - colWidth = pColumn->getWidth(); - long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - if(bResizable && colPrefWidth == 0) - colWithoutFixedWidthsSum+=pixelWidth; - colWidthsSum+=pixelWidth; - } - gridWidth = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; - double scalingFactor = 1.0; - if(m_bResizingGrid) - { - if(gridWidth > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum)) - scalingFactor = gridWidth/colWithoutFixedWidthsSum; - } - else - { - if(colWidthsSum < gridWidth) + gridWidth = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; + double scalingFactor = 1.0; + if(m_bResizingGrid) { - if(colWithoutFixedWidthsSum>0) + if(gridWidth > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum)) scalingFactor = gridWidth/colWithoutFixedWidthsSum; } - } - long pixelWidth = 0; - for ( ColPos col = 0; col < colCount; ++col ) - { - PColumnModel pColumn = m_pModel->getColumnModel( col ); - DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); - if ( !pColumn ) - continue; - TableMetrics colWidth = pColumn->getWidth(); - if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) + else { - colWidth*=scalingFactor; - pColumn->setWidth(colWidth); + if(colWidthsSum < gridWidth) + { + if(colWithoutFixedWidthsSum>0) + scalingFactor = gridWidth/colWithoutFixedWidthsSum; + } + } + long pixelWidth = 0; + for ( ColPos i = 0; i < colCount; ++i ) + { + PColumnModel pColumn = m_pModel->getColumnModel( i ); + DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + if ( !pColumn ) + continue; + TableMetrics colWidth = pColumn->getWidth(); + if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) + { + colWidth*=scalingFactor; + //colWidth+=1; + pColumn->setWidth(colWidth); + } + pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + m_aColumnWidthsPixel.push_back( pixelWidth ); + m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += pixelWidth ); } - pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - m_aColumnWidthsPixel.push_back( pixelWidth ); - m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += pixelWidth ); - } } //-------------------------------------------------------------------- @@ -882,6 +883,11 @@ namespace svt { namespace table m_pScrollCorner->SetPosPixel( Point( aDataCellPlayground.Right() + 1, aDataCellPlayground.Bottom() + 1 ) ); m_pScrollCorner->Show(); } + else if(bHaveScrollCorner && bNeedScrollCorner) + { + m_pScrollCorner->SetPosPixel( Point( aDataCellPlayground.Right() + 1, aDataCellPlayground.Bottom() + 1 ) ); + m_pScrollCorner->Show(); + } // resize the data window m_pDataWindow->SetSizePixel( Size( @@ -894,16 +900,22 @@ namespace svt { namespace table void TableControl_Impl::onResize() { DBG_CHECK_ME(); - if(m_nRowCount != 0) - { - if(m_nColumnCount != 0) + if(m_nRowCount != 0) { - if(m_bResizingGrid) - impl_ni_updateColumnWidths(); - invalidateRows(); - m_bResizingGrid = true; + if(m_nColumnCount != 0) + { + if(m_bResizingGrid) + impl_ni_updateColumnWidths(); + invalidateRows(); + m_bResizingGrid = true; + } } - } + else + //In the case that column headers are defined but data hasn't yet been set, + //only column headers will be shown + if(m_pModel->hasColumnHeaders()) + if(m_nColHeaderHeightPixel>1) + m_pDataWindow->SetSizePixel( m_rAntiImpl.GetOutputSizePixel()); } //-------------------------------------------------------------------- @@ -920,23 +932,28 @@ namespace svt { namespace table // our current style settings, to be passed to the renderer const StyleSettings& rStyle = m_rAntiImpl.GetSettings().GetStyleSettings(); - m_nRowCount = m_pModel->getRowCount(); - TableSize nVisibleRows = impl_getVisibleRows(true); - TableSize nActualRows = m_nRowCount; - if(m_nRowCount>nVisibleRows) - nActualRows = nVisibleRows; + m_nRowCount = m_pModel->getRowCount(); + TableSize nVisibleRows = impl_getVisibleRows(true); + TableSize nActualRows = m_nRowCount; + if(m_nRowCount>nVisibleRows) + nActualRows = nVisibleRows; // the area occupied by all (at least partially) visible cells, including // headers Rectangle aAllCellsWithHeaders; impl_getAllVisibleCellsArea( aAllCellsWithHeaders ); + // ............................ // draw the header column area - if ( getModel()->hasColumnHeaders() ) + if ( m_pModel->hasColumnHeaders() ) { TableRowGeometry aHeaderRow( *this, Rectangle( Point( 0, 0 ), aAllCellsWithHeaders.BottomRight() ), ROW_COL_HEADERS ); + Rectangle aColRect(aHeaderRow.getRect()); + //to avoid double lines when scrolling horizontally + if(m_nLeftColumn != 0) + --aColRect.Left(); pRenderer->PaintHeaderArea( - *m_pDataWindow, aHeaderRow.getRect(), true, false, rStyle + *m_pDataWindow, aColRect, true, false, rStyle ); // Note that strictly, aHeaderRow.getRect() also contains the intersection between column // and row header area. However, below we go to paint this intersection, again, @@ -963,11 +980,14 @@ namespace svt { namespace table { aRowHeaderArea = aAllCellsWithHeaders; aRowHeaderArea.Right() = m_nRowHeaderWidthPixel - 1; - if(m_nTopRow+nActualRows>m_nRowCount) - aRowHeaderArea.Bottom() = m_nRowHeightPixel * (nActualRows -1)+ m_nColHeaderHeightPixel - 1; - else - aRowHeaderArea.Bottom() = m_nRowHeightPixel * nActualRows + m_nColHeaderHeightPixel - 1; - pRenderer->PaintHeaderArea(*m_pDataWindow, aRowHeaderArea, false, true, rStyle); + if(m_nTopRow+nActualRows>m_nRowCount) + aRowHeaderArea.Bottom() = m_nRowHeightPixel * (nActualRows -1)+ m_nColHeaderHeightPixel - 1; + else + aRowHeaderArea.Bottom() = m_nRowHeightPixel * nActualRows + m_nColHeaderHeightPixel - 1; + //to avoid double lines when scrolling vertically + if(m_nTopRow != 0) + --aRowHeaderArea.Top(); + pRenderer->PaintHeaderArea(*m_pDataWindow, aRowHeaderArea, false, true, rStyle); // Note that strictly, aRowHeaderArea also contains the intersection between column // and row header area. However, below we go to paint this intersection, again, // so this hopefully doesn't hurt if we already paint it here. @@ -976,8 +996,15 @@ namespace svt { namespace table { TableCellGeometry aIntersection( *this, Rectangle( Point( 0, 0 ), aAllCellsWithHeaders.BottomRight() ), COL_ROW_HEADERS, ROW_COL_HEADERS ); + Rectangle aInters(aIntersection.getRect()); + //to avoid double line when scrolling vertically + if( m_nTopRow != 0 ) + { + --aInters.Top(); + --aInters.Bottom(); + } pRenderer->PaintHeaderArea( - *m_pDataWindow, aIntersection.getRect(), true, true, rStyle + *m_pDataWindow, aInters, true, true, rStyle ); } } @@ -990,34 +1017,46 @@ namespace svt { namespace table // paint all rows Rectangle aAllDataCellsArea; impl_getAllVisibleDataCellArea( aAllDataCellsArea ); - ::std::vector< std::vector< ::com::sun::star::uno::Any > >& aCellContent = m_pModel->getCellContent(); + ::std::vector< std::vector< ::com::sun::star::uno::Any > >& aCellContent = m_pModel->getCellContent(); for ( TableRowGeometry aRowIterator( *this, aAllCellsWithHeaders, getTopRow() ); aRowIterator.isValid(); aRowIterator.moveDown() ) { if ( _rUpdateRect.GetIntersection( aRowIterator.getRect() ).IsEmpty() ) - continue; + continue; bool isActiveRow = ( aRowIterator.getRow() == getCurRow() ); - bool isSelectedRow = false; - if(!m_nRowSelected.empty()) - { - for(std::vector::iterator itSel=m_nRowSelected.begin(); - itSel!=m_nRowSelected.end();++itSel) + bool isSelectedRow = false; + if(!m_nRowSelected.empty()) { - if(*itSel == aRowIterator.getRow()) - isSelectedRow = true; + for(std::vector::iterator itSel=m_nRowSelected.begin(); + itSel!=m_nRowSelected.end();++itSel) + { + if(*itSel == aRowIterator.getRow()) + isSelectedRow = true; + } } - } + Rectangle aRect = aRowIterator.getRect().GetIntersection( aAllDataCellsArea ); + //to avoid double lines + if( aRowIterator.getRow() != 0 ) + --aRect.Top(); + else + if(m_nColHeaderHeightPixel>1) + --aRect.Top(); + if(m_nLeftColumn != 0) + --aRect.Left(); + else + if(m_pModel->hasRowHeaders()) + --aRect.Left(); // give the redenderer a chance to prepare the row pRenderer->PrepareRow( aRowIterator.getRow(), isActiveRow, isSelectedRow, - *m_pDataWindow, aRowIterator.getRect().GetIntersection( aAllDataCellsArea ), rStyle ); + *m_pDataWindow, aRect, rStyle ); // paint the row header if ( m_pModel->hasRowHeaders() ) { - Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); - rtl::OUString rowHeaderName = m_pModel->getRowHeaderName()[aRowIterator.getRow()]; - pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, + Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); + rtl::OUString rowHeaderName = m_pModel->getRowHeaderName()[aRowIterator.getRow()]; + pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, rStyle, rowHeaderName ); } if ( !colCount ) @@ -1028,25 +1067,25 @@ namespace svt { namespace table aCell.moveRight() ) { - bool isSelectedColumn = false; - Size siz = m_rAntiImpl.GetSizePixel(); - ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; - ::com::sun::star::uno::Any rCellData = aCellContent[aRowIterator.getRow()][aCell.getColumn()]; - if(rCellData>>=xGraphic) - { - Image* pImage = new Image(xGraphic); - if(pImage!=NULL) - pRenderer->PaintCellImage( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, + bool isSelectedColumn = false; + // Size siz = m_rAntiImpl.GetSizePixel(); + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; + ::com::sun::star::uno::Any rCellData = aCellContent[aRowIterator.getRow()][aCell.getColumn()]; + if(rCellData>>=xGraphic) + { + Image* pImage = new Image(xGraphic); + if(pImage!=NULL) + pRenderer->PaintCellImage( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, *m_pDataWindow, aCell.getRect(), rStyle, pImage ); - } - else - { - ::rtl::OUString sContent = convertToString(rCellData); - pRenderer->PaintCellString( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, + } + else + { + ::rtl::OUString sContent = convertToString(rCellData); + pRenderer->PaintCellString( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, *m_pDataWindow, aCell.getRect(), rStyle, sContent ); + } } } - } } //-------------------------------------------------------------------- void TableControl_Impl::hideCursor() @@ -1454,10 +1493,12 @@ namespace svt { namespace table { Rectangle aCellRect; impl_getCellRect( m_nCurColumn, m_nCurRow, aCellRect ); - if ( _bShow ) - pRenderer->ShowCellCursor( *m_pDataWindow, aCellRect); - else - pRenderer->HideCellCursor( *m_pDataWindow, aCellRect); + if(!m_pModel->hasRowHeaders() && m_nCurColumn == 0) + aCellRect.Left()++; + if ( _bShow ) + pRenderer->ShowCellCursor( *m_pDataWindow, aCellRect); + else + pRenderer->HideCellCursor( *m_pDataWindow, aCellRect); } } @@ -1480,6 +1521,7 @@ namespace svt { namespace table TableCellGeometry aCell( *this, aAllCells, _nColumn, _nRow ); _rCellRect = aCell.getRect(); + _rCellRect.Top()--;_rCellRect.Left()--; } //------------------------------------------------------------------------------- RowPos TableControl_Impl::getCurrentRow(const Point& rPoint) @@ -1497,9 +1539,7 @@ namespace svt { namespace table { newRowPos = i; newColPos = j; - if(newColPos == -1) - m_nCurColumn = 0; - else + if(newColPos != -1) m_nCurColumn = newColPos; return newRowPos; } @@ -1617,13 +1657,18 @@ namespace svt { namespace table //------------------------------------------------------------------------------ void TableControl_Impl::invalidateRows() { - impl_ni_updateScrollbars(); - TableSize nVisibleRows = impl_getVisibleRows(true); - if(m_nTopRow+nVisibleRows>m_nRowCount && m_nRowCount>=nVisibleRows) - m_nTopRow--; - else - m_nTopRow = 0; - m_pDataWindow->Invalidate(); + impl_ni_updateScrollbars(); + TableSize nVisibleRows = impl_getVisibleRows(true); + TableSize nVisibleCols = impl_getVisibleColumns(true); + if(m_nTopRow+nVisibleRows>m_nRowCount && m_nRowCount>=nVisibleRows) + m_nTopRow--; + else + m_nTopRow = 0; + if(m_nLeftColumn+nVisibleCols>m_nColumnCount && m_nColumnCount>=nVisibleCols) + m_nLeftColumn--; + else + m_nLeftColumn = 0; + m_pDataWindow->Invalidate(); } //-------------------------------------------------------------------- @@ -1799,17 +1844,22 @@ namespace svt { namespace table //------------------------------------------------------------------------------- SelectionEngine* TableControl_Impl::getSelEngine() { - return m_pSelEngine; + return m_pSelEngine; } //------------------------------------------------------------------------------- TableDataWindow* TableControl_Impl::getDataWindow() { - return m_pDataWindow; + return m_pDataWindow; } //------------------------------------------------------------------------------- BOOL TableControl_Impl::isRowSelected(const ::std::vector& selectedRows, RowPos current) { return ::std::find(selectedRows.begin(),selectedRows.end(),current) != selectedRows.end(); + } + //------------------------------------------------------------------------------- + bool TableControl_Impl::isRowSelected(RowPos current) + { + return ::std::find(m_nRowSelected.begin(),m_nRowSelected.end(),current) != m_nRowSelected.end(); } //------------------------------------------------------------------------------- int TableControl_Impl::getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current) @@ -1906,7 +1956,7 @@ namespace svt { namespace table //MouseButton was pressed but not yet released, mouse is moving if(m_bResizing) { - if(rPoint.X() > m_pDataWindow->GetSizePixel().Width() || rPoint.X() < m_aVisibleColumnWidthsPixel[resizingColumn]-newColWidth) + if(rPoint.X() > m_pDataWindow->GetOutputSizePixel().Width() || rPoint.X() < m_aVisibleColumnWidthsPixel[resizingColumn]-newColWidth) aNewPointer = Pointer( POINTER_NOTALLOWED); else aNewPointer = Pointer( POINTER_HSPLIT ); @@ -1915,7 +1965,7 @@ namespace svt { namespace table if(m_pModel->hasColumnHeaders()) lineHeight+= m_nColHeaderHeightPixel; lineHeight+=m_nRowHeightPixel*m_nRowCount; - int gridHeight = m_pDataWindow->GetSizePixel().Height(); + int gridHeight = m_pDataWindow->GetOutputSizePixel().Height(); if(lineHeight >= gridHeight) lineHeight = gridHeight; m_pDataWindow->ShowTracking(Rectangle(Point(rPoint.X(),0), Size(1, lineHeight )), @@ -2046,7 +2096,7 @@ namespace svt { namespace table } //when the sum of all visible columns and the next to the left column is smaller than //window width, then update m_nLeftColumn - if(widthsPixelGetSizePixel().Width()) + if(widthsPixelGetOutputSizePixel().Width()) m_nLeftColumn--; } //-------------------------------------------------------------------- @@ -2085,6 +2135,7 @@ namespace svt { namespace table impl_getAllVisibleDataCellArea(aRect); return aRect; } + //-------------------------------------------------------------------- IMPL_LINK( TableControl_Impl, OnScroll, ScrollBar*, _pScrollbar ) { diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 61fcda7ceb71..da4108e3af09 100644 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -190,6 +190,8 @@ namespace svt { namespace table void setCursorAtCurrentCell(const Point& rPoint); /** checks whether the vector with the selected rows contains the current row*/ BOOL isRowSelected(const ::std::vector& selectedRows, RowPos current); + + bool isRowSelected(RowPos current); /** returns the position of the current row in the selection vector */ int getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current); /** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/ @@ -201,7 +203,6 @@ namespace svt { namespace table /** updates the vector, which contains the selected rows after removing the row nRowPos*/ void removeSelectedRow(RowPos _nRowPos); void invalidateRows(); - // IAbstractTableControl virtual void hideCursor(); virtual void showCursor(); diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 1a1696a6ea58..e602f0418cfe 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -44,6 +44,7 @@ namespace svt { namespace table TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl ) :Window( &_rTableControl.getAntiImpl() ) ,m_rTableControl ( _rTableControl ) + ,m_nRowAlreadySelected( -1 ) { } @@ -75,13 +76,24 @@ namespace svt { namespace table //-------------------------------------------------------------------- void TableDataWindow::MouseButtonDown( const MouseEvent& rMEvt ) { + Point aPoint = rMEvt.GetPosPixel(); + RowPos nCurRow = m_rTableControl.getCurrentRow(aPoint); if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) ) Window::MouseButtonDown( rMEvt ); else { - Point aPoint = rMEvt.GetPosPixel(); - if(m_rTableControl.getCurrentRow(aPoint) >= 0) - m_aSelectHdl.Call( NULL ); + if(nCurRow >= 0 && m_rTableControl.getSelEngine()->GetSelectionMode() != NO_SELECTION) + { + if( m_nRowAlreadySelected != nCurRow ) + { + m_nRowAlreadySelected = nCurRow; + m_aSelectHdl.Call( NULL ); + } + else + m_aMouseButtonDownHdl.Call((MouseEvent*) &rMEvt); + } + else + m_aMouseButtonDownHdl.Call((MouseEvent*) &rMEvt); } m_rTableControl.getAntiImpl().LoseFocus(); } @@ -90,6 +102,8 @@ namespace svt { namespace table { if ( !m_rTableControl.getInputHandler()->MouseButtonUp( m_rTableControl, rMEvt ) ) Window::MouseButtonUp( rMEvt ); + else + m_aMouseButtonUpHdl.Call((MouseEvent*) &rMEvt); m_rTableControl.getAntiImpl().GetFocus(); } //-------------------------------------------------------------------- diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 404caadd9fb7..8d3edad11be5 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -127,9 +127,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An ::vos::OGuard aGuard( GetMutex() ); TableControl* pTable = (TableControl*)GetWindow(); - const StyleSettings& rStyleSettings = GetWindow()->GetSettings().GetStyleSettings(); - const com::sun::star::awt::FontDescriptor& aFont = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); - + sal_Int32 fontHeight = GetWindow()->GetTextHeight(); switch( GetPropertyId( PropertyName ) ) { case BASEPROPERTY_GRID_SELECTIONMODE: @@ -293,7 +291,6 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } else throw GridInvalidDataException(rtl::OUString::createFromAscii("The data model isn't set!"), m_xDataModel); - sal_Int32 fontHeight = aFont.Height+8; if(m_xDataModel->getRowHeight() == 0) m_pTableModel->setRowHeight(fontHeight); else @@ -312,7 +309,6 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An Sequence > columns = m_xColumnModel->getColumns(); std::vector > aNewColumns( comphelper::sequenceToContainer > >(columns)); - sal_Int32 fontHeight = aFont.Height+8; if(m_xColumnModel->getColumnHeaderHeight() == 0) m_pTableModel->setColumnHeaderHeight(fontHeight); else @@ -671,14 +667,7 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R { TableControl* pTable = (TableControl*)GetWindow(); std::vector& selectedRows = pTable->GetSelectedRows(); - ::std::vector::iterator iter = selectedRows.begin(); - sal_Bool bSelected = sal_False; - for(;iter!=selectedRows.end();iter++) - { - if(*iter == index) - bSelected = sal_True; - } - return bSelected; + return std::find(selectedRows.begin(),selectedRows.end(), index) != selectedRows.end(); } void SAL_CALL SVTXGridControl::selectRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) -- cgit From d66af9e10fa0f8fcf82b7c06dac789b5e5f4910b Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 17:28:52 +0200 Subject: npower13_objectmodules: uppercase UNO constants --- filter/source/msfilter/msvbasic.cxx | 14 ++++++++------ filter/source/msfilter/msvbasic.hxx | 7 +------ filter/source/msfilter/svxmsbas.cxx | 19 ++++++++++--------- oox/source/ole/vbamodule.cxx | 22 +++++++++++----------- oox/source/ole/vbaproject.cxx | 14 +++++++------- 5 files changed, 37 insertions(+), 39 deletions(-) diff --git a/filter/source/msfilter/msvbasic.cxx b/filter/source/msfilter/msvbasic.cxx index 8a87c70f19d0..be8ee6bd30e5 100644 --- a/filter/source/msfilter/msvbasic.cxx +++ b/filter/source/msfilter/msvbasic.cxx @@ -38,6 +38,8 @@ #include //rtl_getTextEncodingFromWindowsCodePage #include "msvbasic.hxx" +#include + using namespace ::com::sun::star::script; /* @@ -439,7 +441,7 @@ ModType VBA_Impl::GetModuleType( const UniString& rModuleName ) { return iter->second; } - return ModuleType::Unknown; + return ModuleType::UNKNOWN; } bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) @@ -482,7 +484,7 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) static const String sClass( RTL_CONSTASCII_USTRINGPARAM( "Class" ) ); static const String sBaseClass( RTL_CONSTASCII_USTRINGPARAM( "BaseClass" ) ); static const String sDocument( RTL_CONSTASCII_USTRINGPARAM( "Document" ) ); - mhModHash[ sThisDoc ] = ModuleType::Class; + mhModHash[ sThisDoc ] = ModuleType::CLASS; while ( pStp->ReadByteStringLine( tmp, meCharSet ) ) { xub_StrLen index = tmp.Search( '=' ); @@ -492,14 +494,14 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) String value = tmp.Copy( index + 1 ); if ( key == sClass ) { - mhModHash[ value ] = ModuleType::Class; + mhModHash[ value ] = ModuleType::CLASS; OSL_TRACE("Module %s is of type Class", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); } else if ( key == sBaseClass ) { - mhModHash[ value ] = ModuleType::Form; + mhModHash[ value ] = ModuleType::FORM; OSL_TRACE("Module %s is of type Form", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); @@ -512,14 +514,14 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel ) // value is of form /&H, strip the identifier value.Erase( value.Search( '/' ) ); - mhModHash[ value ] = ModuleType::Document; + mhModHash[ value ] = ModuleType::DOCUMENT; OSL_TRACE("Module %s is of type Document VBA", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); } else if ( key == sModule ) { - mhModHash[ value ] = ModuleType::Normal; + mhModHash[ value ] = ModuleType::NORMAL; OSL_TRACE("Module %s is of type Normal VBA", ::rtl::OUStringToOString( value , RTL_TEXTENCODING_ASCII_US ).pData->buffer ); diff --git a/filter/source/msfilter/msvbasic.hxx b/filter/source/msfilter/msvbasic.hxx index ed77b34c4f48..171671e8cd5c 100644 --- a/filter/source/msfilter/msvbasic.hxx +++ b/filter/source/msfilter/msvbasic.hxx @@ -30,17 +30,12 @@ #ifndef _MSVBASIC_HXX #define _MSVBASIC_HXX -#ifdef _SOLAR_H #include -#endif #include #include #include -#ifndef __SGI_STL_VECTOR #include -#endif -#include -#include +#include /* class VBA: * The VBA class provides a set of methods to handle Visual Basic For diff --git a/filter/source/msfilter/svxmsbas.cxx b/filter/source/msfilter/svxmsbas.cxx index 3b32b951c16a..55465850d8c8 100644 --- a/filter/source/msfilter/svxmsbas.cxx +++ b/filter/source/msfilter/svxmsbas.cxx @@ -51,6 +51,7 @@ using namespace com::sun::star::awt; #include #include #include +#include #include #include @@ -332,23 +333,23 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, switch( mType ) { - case ModuleType::Class: + case ModuleType::CLASS: modeTypeComment = sClassRem + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAClassModule\n" ) ); break; - case ModuleType::Form: + case ModuleType::FORM: modeTypeComment = sClassRem + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAFormModule\n" ) ); break; - case ModuleType::Document: + case ModuleType::DOCUMENT: modeTypeComment = sClassRem + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBADocumentModule\n" ) ); break; - case ModuleType::Normal: + case ModuleType::NORMAL: modeTypeComment = sClassRem + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAModule\n" ) ); break; - case ModuleType::Unknown: + case ModuleType::UNKNOWN: modeTypeComment = sClassRem + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAUnknown\n" ) ); break; @@ -360,7 +361,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, if ( !bAsComment ) { modeTypeComment = modeTypeComment + sVBAOption; - if ( mType == ModuleType::Class ) + if ( mType == ModuleType::CLASS ) modeTypeComment = modeTypeComment + sClassOption; } @@ -443,7 +444,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, for ( std::vector< String >::const_iterator it = codeNames.begin(); it != codeNames.end(); ++it ) { script::ModuleInfo sModuleInfo; - sModuleInfo.ModuleType = ModuleType::Document; + sModuleInfo.ModuleType = ModuleType::DOCUMENT; moduleInfos[ *it ] = sModuleInfo; moduleData[ *it ] = uno::makeAny( sVBAOption ); } @@ -455,13 +456,13 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, if ( it_info != moduleInfos.end() ) { ModuleInfo& sModuleInfo = it_info->second; - if ( sModuleInfo.ModuleType == ModuleType::Form ) + if ( sModuleInfo.ModuleType == ModuleType::FORM ) // hack, the module ( imo document basic should... // know the XModel... ) but it doesn't sModuleInfo.ModuleObject.set( rDocSh.GetModel(), UNO_QUERY ); // document modules, we should be able to access // the api objects at this time - else if ( sModuleInfo.ModuleType == ModuleType::Document ) + else if ( sModuleInfo.ModuleType == ModuleType::DOCUMENT ) { if ( xVBACodeNamedObjectAccess.is() ) { diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx index ff4c37e93b88..e9388e54215a 100755 --- a/oox/source/ole/vbamodule.cxx +++ b/oox/source/ole/vbamodule.cxx @@ -60,7 +60,7 @@ VbaModule::VbaModule( const Reference< XModel >& rxDocModel, const OUString& rNa mxDocModel( rxDocModel ), maName( rName ), meTextEnc( eTextEnc ), - mnType( ApiModuleType::Unknown ), + mnType( ApiModuleType::UNKNOWN ), mnOffset( SAL_MAX_UINT32 ), mbReadOnly( false ), mbPrivate( false ), @@ -107,13 +107,13 @@ void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) break; case VBA_ID_MODULETYPEPROCEDURAL: OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); - OSL_ENSURE( mnType == ApiModuleType::Unknown, "VbaModule::importDirRecords - multiple module type records" ); - mnType = ApiModuleType::Normal; + OSL_ENSURE( mnType == ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" ); + mnType = ApiModuleType::NORMAL; break; case VBA_ID_MODULETYPEDOCUMENT: OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); - OSL_ENSURE( mnType == ApiModuleType::Unknown, "VbaModule::importDirRecords - multiple module type records" ); - mnType = ApiModuleType::Document; + OSL_ENSURE( mnType == ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" ); + mnType = ApiModuleType::DOCUMENT; break; case VBA_ID_MODULEREADONLY: OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); @@ -130,7 +130,7 @@ void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) } OSL_ENSURE( maName.getLength() > 0, "VbaModule::importDirRecords - missing module name" ); OSL_ENSURE( maStreamName.getLength() > 0, "VbaModule::importDirRecords - missing module stream name" ); - OSL_ENSURE( mnType != ApiModuleType::Unknown, "VbaModule::importDirRecords - missing module type" ); + OSL_ENSURE( mnType != ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - missing module type" ); OSL_ENSURE( mnOffset < SAL_MAX_UINT32, "VbaModule::importDirRecords - missing module stream offset" ); } @@ -155,18 +155,18 @@ void VbaModule::importSourceCode( StorageBase& rVbaStrg, aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem Attribute VBA_ModuleType=" ) ); switch( mnType ) { - case ApiModuleType::Normal: + case ApiModuleType::NORMAL: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAModule" ) ); break; - case ApiModuleType::Class: + case ApiModuleType::CLASS: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAClassModule" ) ); break; - case ApiModuleType::Form: + case ApiModuleType::FORM: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAFormModule" ) ); // hack from old filter, document Basic should know the XModel, but it doesn't aModuleInfo.ModuleObject.set( mxDocModel, UNO_QUERY ); break; - case ApiModuleType::Document: + case ApiModuleType::DOCUMENT: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBADocumentModule" ) ); // get the VBA object associated to the document module if( rxDocObjectNA.is() ) try @@ -184,7 +184,7 @@ void VbaModule::importSourceCode( StorageBase& rVbaStrg, if( mbExecutable ) { aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option VBASupport 1\n" ) ); - if( mnType == ApiModuleType::Class ) + if( mnType == ApiModuleType::CLASS ) aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option ClassModule\n" ) ); } else diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx index 92a556d8b885..a370fb3d168e 100755 --- a/oox/source/ole/vbaproject.cxx +++ b/oox/source/ole/vbaproject.cxx @@ -394,23 +394,23 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap bExitLoop = (nLineLen >= 2) && (aLine[ 0 ] == '[') && (aLine[ nLineLen - 1 ] == ']'); if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) ) { - sal_Int32 nType = ApiModuleType::Unknown; + sal_Int32 nType = ApiModuleType::UNKNOWN; if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Document" ) ) ) { - nType = ApiModuleType::Document; + nType = ApiModuleType::DOCUMENT; // strip automation server version from module names sal_Int32 nSlashPos = aValue.indexOf( '/' ); if( nSlashPos >= 0 ) aValue = aValue.copy( 0, nSlashPos ); } else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Module" ) ) ) - nType = ApiModuleType::Normal; + nType = ApiModuleType::NORMAL; else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Class" ) ) ) - nType = ApiModuleType::Class; + nType = ApiModuleType::CLASS; else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "BaseClass" ) ) ) - nType = ApiModuleType::Form; + nType = ApiModuleType::FORM; - if( (nType != ApiModuleType::Unknown) && (aValue.getLength() > 0) ) + if( (nType != ApiModuleType::UNKNOWN) && (aValue.getLength() > 0) ) { OSL_ENSURE( aModules.has( aValue ), "VbaProject::importVba - module not found" ); if( VbaModule* pModule = aModules.get( aValue ).get() ) @@ -475,7 +475,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap { // resolve module name from storage name (which equals the module stream name) VbaModule* pModule = aModulesByStrm.get( *aIt ).get(); - OSL_ENSURE( pModule && (pModule->getType() == ApiModuleType::Form), + OSL_ENSURE( pModule && (pModule->getType() == ApiModuleType::FORM), "VbaProject::importVba - form substorage without form module" ); OUString aModuleName; if( pModule ) -- cgit From d17f9a78f7eec405bca5c5e5707f2bf222a04d87 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 17:28:52 +0200 Subject: npower13_objectmodules: uppercase UNO constants --- basctl/source/basicide/baside2.cxx | 8 ++++---- basctl/source/basicide/bastype2.cxx | 10 +++++----- basctl/source/basicide/bastypes.cxx | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 95671cd8ae47..0fa09a00f255 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -1410,7 +1410,7 @@ BasicEntryDescriptor ModulWindow::CreateEntryDescriptor() { switch( xModule->GetModuleType() ) { - case script::ModuleType::Document: + case script::ModuleType::DOCUMENT: { aLibSubName = String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ); uno::Reference< container::XNameContainer > xLib = aDocument.getOrCreateLibrary( E_SCRIPTS, aLibName ); @@ -1425,13 +1425,13 @@ BasicEntryDescriptor ModulWindow::CreateEntryDescriptor() } break; } - case script::ModuleType::Form: + case script::ModuleType::FORM: aLibSubName = String( IDEResId( RID_STR_USERFORMS ) ); break; - case script::ModuleType::Normal: + case script::ModuleType::NORMAL: aLibSubName = String( IDEResId( RID_STR_NORMAL_MODULES ) ); break; - case script::ModuleType::Class: + case script::ModuleType::CLASS: aLibSubName = String( IDEResId( RID_STR_CLASS_MODULES ) ); break; } diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index 6132d81f9c65..2360011399dd 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -63,7 +63,7 @@ void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, sal_Int32 lcl_getModuleType( const uno::Reference< container::XNameContainer >& rLib, const String& rModName ) { - sal_Int32 nType = com::sun::star::script::ModuleType::Normal; + sal_Int32 nType = com::sun::star::script::ModuleType::NORMAL; uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) ) { @@ -448,16 +448,16 @@ void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubR BasicEntryType eType = OBJ_TYPE_UNKNOWN; switch( lcl_getModuleType( xLib, aModName ) ) { - case script::ModuleType::Document: + case script::ModuleType::DOCUMENT: eType = OBJ_TYPE_DOCUMENT_OBJECTS; break; - case script::ModuleType::Form: + case script::ModuleType::FORM: eType = OBJ_TYPE_USERFORMS; break; - case script::ModuleType::Normal: + case script::ModuleType::NORMAL: eType = OBJ_TYPE_NORMAL_MODULES; break; - case script::ModuleType::Class: + case script::ModuleType::CLASS: eType = OBJ_TYPE_CLASS_MODULES; break; } diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index 85dfa146e178..150e10a5a76f 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -599,7 +599,7 @@ void __EXPORT BasicIDETabBar::Command( const CommandEvent& rCEvt ) if( pWin && pWin->ISA( ModulWindow ) ) { SbModule* pActiveModule = (SbModule*)pBasic->FindModule( pWin->GetName() ); - if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::Document ) ) + if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::DOCUMENT ) ) { aPopup.EnableItem( SID_BASICIDE_DELETECURRENT, FALSE ); aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE ); -- cgit From 45cc8f5bd1f3f7bb3cb4e63088f280dc8e8b93fc Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 17:28:52 +0200 Subject: npower13_objectmodules: uppercase UNO constants --- basic/inc/basic/sbmod.hxx | 3 --- basic/source/basmgr/basmgr.cxx | 1 - basic/source/classes/sb.cxx | 14 +++++++------- basic/source/classes/sbxmod.cxx | 5 +++-- basic/source/comp/codegen.cxx | 7 ++++--- basic/source/comp/parser.cxx | 5 +++-- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index ba468b252d2a..63ffef6cdd61 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -31,10 +31,7 @@ #include #include #include -#ifndef _RTL_USTRING_HXX #include -#endif -#include class SbMethod; class SbProperty; diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index ac7812fd6c66..1caa22980f1b 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -67,7 +67,6 @@ #include #include #include -#include #include #include diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 7f7ac8784742..233b181757f0 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -490,7 +490,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) } } } - SetModuleType( com::sun::star::script::ModuleType::Class ); + SetModuleType( ModuleType::CLASS ); } SbClassModuleObject::~SbClassModuleObject() @@ -790,7 +790,7 @@ SbModule* StarBASIC::MakeModule( const String& rName, const String& rSrc ) SbModule* StarBASIC::MakeModule32( const String& rName, const ::rtl::OUString& rSrc ) { ModuleInfo mInfo; - mInfo.ModuleType = ModuleType::Normal; + mInfo.ModuleType = ModuleType::NORMAL; return MakeModule32( rName, mInfo, rSrc ); } SbModule* StarBASIC::MakeModule32( const String& rName, const ModuleInfo& mInfo, const rtl::OUString& rSrc ) @@ -800,17 +800,17 @@ SbModule* StarBASIC::MakeModule32( const String& rName, const ModuleInfo& mInfo, SbModule* p = NULL; switch ( mInfo.ModuleType ) { - case ModuleType::Document: + case ModuleType::DOCUMENT: // In theory we should be able to create Object modules // in ordinary basic ( in vba mode thought these are create // by the application/basic and not by the user ) p = new SbObjModule( rName, mInfo, isVBAEnabled() ); break; - case ModuleType::Class: + case ModuleType::CLASS: p = new SbModule( rName, isVBAEnabled() ); - p->SetModuleType( com::sun::star::script::ModuleType::Class ); + p->SetModuleType( ModuleType::CLASS ); break; - case ModuleType::Form: + case ModuleType::FORM: p = new SbUserFormModule( rName, mInfo, isVBAEnabled() ); break; default: @@ -995,7 +995,7 @@ SbxVariable* StarBASIC::Find( const String& rName, SbxClassType t ) // Only variables qualified by the Module Name e.g. Sheet1.foo // should work for Documant && Class type Modules INT32 nType = p->GetModuleType(); - if ( nType == com::sun::star::script::ModuleType::Document || nType == com::sun::star::script::ModuleType::Form ) + if ( nType == ModuleType::DOCUMENT || nType == ModuleType::FORM ) continue; // otherwise check if the element is available diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index ab655c88ce10..93705d05460e 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -54,6 +54,7 @@ #include #include #include +#include // for the bsearch @@ -165,7 +166,7 @@ SbModule::SbModule( const String& rName, BOOL bVBACompat ) { SetName( rName ); SetFlag( SBX_EXTSEARCH | SBX_GBLSEARCH ); - SetModuleType( com::sun::star::script::ModuleType::Normal ); + SetModuleType( script::ModuleType::NORMAL ); } SbModule::~SbModule() @@ -1503,7 +1504,7 @@ SbObjModule::SbObjModule( const String& rName, const com::sun::star::script::Mod : SbModule( rName, bIsVbaCompatible ) { SetModuleType( mInfo.ModuleType ); - if ( mInfo.ModuleType == script::ModuleType::Form ) + if ( mInfo.ModuleType == script::ModuleType::FORM ) { SetClassName( rtl::OUString::createFromAscii( "Form" ) ); } diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index 1cf38f171e8b..46f829b382e8 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -32,6 +32,7 @@ #include "sbcomp.hxx" #include "image.hxx" #include +#include // nInc ist die Inkrementgroesse der Puffer @@ -129,7 +130,7 @@ void SbiCodeGen::Save() p->SetFlag( SBIMG_EXPLICIT ); int nIfaceCount = 0; - if( rMod.mnType == com::sun::star::script::ModuleType::Class ) + if( rMod.mnType == com::sun::star::script::ModuleType::CLASS ) { OSL_TRACE("COdeGen::save() classmodule processing"); rMod.bIsProxyModule = true; @@ -156,8 +157,8 @@ void SbiCodeGen::Save() { pCLASSFAC->RemoveClassModule( &rMod ); // Only a ClassModule can revert to Normal - if ( rMod.mnType == com::sun::star::script::ModuleType::Class ) - rMod.mnType = com::sun::star::script::ModuleType::Normal; + if ( rMod.mnType == com::sun::star::script::ModuleType::CLASS ) + rMod.mnType = com::sun::star::script::ModuleType::NORMAL; rMod.bIsProxyModule = false; } if( pParser->bText ) diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx index 9fbd1035fa5f..8770dc8539f0 100644 --- a/basic/source/comp/parser.cxx +++ b/basic/source/comp/parser.cxx @@ -29,6 +29,7 @@ #include "precompiled_basic.hxx" #include #include "sbcomp.hxx" +#include struct SbiParseStack { // "Stack" fuer Statement-Blocks SbiParseStack* pNext; // Chain @@ -140,7 +141,7 @@ SbiParser::SbiParser( StarBASIC* pb, SbModule* pm ) bNewGblDefs = bSingleLineIf = bExplicit = FALSE; - bClassModule = ( pm->GetModuleType() == com::sun::star::script::ModuleType::Class ); + bClassModule = ( pm->GetModuleType() == com::sun::star::script::ModuleType::CLASS ); OSL_TRACE("Parser - %s, bClassModule %d", rtl::OUStringToOString( pm->GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), bClassModule ); pPool = &aPublics; for( short i = 0; i < 26; i++ ) @@ -756,7 +757,7 @@ void SbiParser::Option() case CLASSMODULE: bClassModule = TRUE; - aGen.GetModule().SetModuleType( com::sun::star::script::ModuleType::Class ); + aGen.GetModule().SetModuleType( com::sun::star::script::ModuleType::CLASS ); break; case VBASUPPORT: if( Next() == NUMBER ) -- cgit From 6890276d6062c9b70169aa2b6eb45678babd97d7 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 17:28:52 +0200 Subject: npower13_objectmodules: uppercase UNO constants --- offapi/com/sun/star/script/ModuleType.idl | 32 ++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/offapi/com/sun/star/script/ModuleType.idl b/offapi/com/sun/star/script/ModuleType.idl index adf51e0dc6f1..a9bde042fa5a 100644 --- a/offapi/com/sun/star/script/ModuleType.idl +++ b/offapi/com/sun/star/script/ModuleType.idl @@ -36,19 +36,33 @@ #ifndef __com_sun_star_script_ModuleType_idl__ #define __com_sun_star_script_ModuleType_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - //============================================================================= + module com { module sun { module star { module script { + published constants ModuleType { - const long Unknown = 0; - const long Normal = 1; - const long Class = 2; - const long Form = 3; - const long Document = 4; + // ------------------------------------------------------------------------ + + const long UNKNOWN = 0; + + // ------------------------------------------------------------------------ + + const long NORMAL = 1; + + // ------------------------------------------------------------------------ + + const long CLASS = 2; + + // ------------------------------------------------------------------------ + + const long FORM = 3; + + // ------------------------------------------------------------------------ + + const long DOCUMENT = 4; + + // ------------------------------------------------------------------------ }; //============================================================================= -- cgit From 2cc76813f2da296840d94e94c652f573313b21cf Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 17:28:52 +0200 Subject: npower13_objectmodules: uppercase UNO constants --- sc/source/ui/docshell/docfunc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 3b735c061cab..01d03d49b50a 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2601,7 +2601,7 @@ script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule ) { ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )); script::ModuleInfo sModuleInfo; - sModuleInfo.ModuleType = script::ModuleType::Document; + sModuleInfo.ModuleType = script::ModuleType::DOCUMENT; sModuleInfo.ModuleObject = GetDocModuleObject( rDocSh, sModule ); return sModuleInfo; } -- cgit From a5858e6d95685ee5f54b0879b42529c3df49ee83 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 19:03:55 +0200 Subject: npower13_objectmodules: solaris compiler warning --- oox/source/ole/olehelper.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index 68ae8c90802e..0a0796e15a7e 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -147,7 +147,6 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, { case OLE_COLORTYPE_CLIENT: return bDefaultColorBgr ? lclDecodeBgrColor( nOleColor ) : rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK ); - break; case OLE_COLORTYPE_PALETTE: return rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK ); -- cgit From 7780dbea502bce290f94c8fe357566d45509ff55 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 19 Apr 2010 11:02:13 +0100 Subject: npower13_objectmodules: fold in review comment ( about making lcl_getObjectName & lcl_getModuleType 'real' methods of a helper for basctl) --- basctl/source/basicide/bastype2.cxx | 31 +++++++++++++++++++++++++++---- basctl/source/basicide/scriptdocument.cxx | 4 ++-- basctl/source/inc/bastypes.hxx | 10 +++++++++- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index 2360011399dd..0709fe38cbe2 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -55,13 +55,36 @@ #include #include #include +#include +#include using namespace ::com::sun::star::uno; using namespace ::com::sun::star; -void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName ); +void ModuleInfoHelper::getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName ) +{ + try + { + uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); + if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) ) + { + script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName ); + uno::Any aObject( aModuleInfo.ModuleObject ); + uno::Reference< lang::XServiceInfo > xServiceInfo( aObject, uno::UNO_QUERY ); + if( xServiceInfo.is() && xServiceInfo->supportsService( rtl::OUString::createFromAscii( "ooo.vba.excel.Worksheet" ) ) ) + { + uno::Reference< container::XNamed > xNamed( aObject, uno::UNO_QUERY ); + if( xNamed.is() ) + rObjName = xNamed->getName(); + } + } + } + catch( uno::Exception& ) + { + } +} -sal_Int32 lcl_getModuleType( const uno::Reference< container::XNameContainer >& rLib, const String& rModName ) +sal_Int32 ModuleInfoHelper::getModuleType( const uno::Reference< container::XNameContainer >& rLib, const String& rModName ) { sal_Int32 nType = com::sun::star::script::ModuleType::NORMAL; uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); @@ -446,7 +469,7 @@ void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubR { String aModName = pModNames[ i ]; BasicEntryType eType = OBJ_TYPE_UNKNOWN; - switch( lcl_getModuleType( xLib, aModName ) ) + switch( ModuleInfoHelper::getModuleType( xLib, aModName ) ) { case script::ModuleType::DOCUMENT: eType = OBJ_TYPE_DOCUMENT_OBJECTS; @@ -470,7 +493,7 @@ void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubR if( eType == OBJ_TYPE_DOCUMENT_OBJECTS ) { String sObjName; - lcl_getObjectName( xLib, aModName, sObjName ); + ModuleInfoHelper::getObjectName( xLib, aModName, sObjName ); if( sObjName.Len() ) { aEntryName.AppendAscii(" (").Append(sObjName).AppendAscii(")"); diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index 6d175674a63d..a8c6d24a3ff5 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -691,7 +691,7 @@ namespace basctl } // insert element by new name in container - if ( _eType == E_SCRIPTS ) + else if ( _eType == E_SCRIPTS ) { Reference< XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); if ( xVBAModuleInfo->hasModuleInfo( _rOldName ) ) @@ -765,7 +765,7 @@ namespace basctl Reference< XNameContainer > xLib( getOrCreateLibrary( E_SCRIPTS, _rLibName ), UNO_QUERY_THROW ); if ( !xLib->hasByName( _rModName ) ) return false; - xLib->replaceByName( _rModName, makeAny( _rModuleCode ) ); + xLib->replaceByName( _rModName, makeAny( _rModuleCode ) ); return true; } catch( const Exception& ) diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx index c9981001e456..bc588fccaf14 100644 --- a/basctl/source/inc/bastypes.hxx +++ b/basctl/source/inc/bastypes.hxx @@ -328,5 +328,13 @@ BOOL QueryDelModule( const String& rName, Window* pParent = 0 ); BOOL QueryDelLib( const String& rName, BOOL bRef = FALSE, Window* pParent = 0 ); BOOL QueryPassword( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >& xLibContainer, const String& rLibName, String& rPassword, BOOL bRepeat = FALSE, BOOL bNewTitle = FALSE ); - +class ModuleInfoHelper +{ +ModuleInfoHelper(); +ModuleInfoHelper(const ModuleInfoHelper&); +ModuleInfoHelper& operator = (const ModuleInfoHelper&); +public: + static void getObjectName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const String& rModName, String& rObjName ); + static sal_Int32 getModuleType( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const String& rModName ); +}; #endif // _BASTYPES_HXX -- cgit From 876116a06642ed8a7be922995ec9ea45cb0ee3fb Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 17:23:07 +0200 Subject: sw33bf03: #i110241#: revert change from writerfilter32bugfixes01 this will break import of certain "format" redlines. --- sw/source/core/doc/docredln.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index dddf027647c1..3fb23299d4c3 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1112,8 +1112,7 @@ bool SwDoc::AppendRedline( SwRedline* pNewRedl, bool bCallDelete ) case POS_EQUAL: case POS_INSIDE: - // TODO Check if there is any side effect - //delete pNewRedl, pNewRedl = 0; + delete pNewRedl, pNewRedl = 0; break; case POS_OUTSIDE: -- cgit From 40f2ebaa07d820660f5d14531eb22818287d7e93 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 17:25:53 +0200 Subject: sw33bf03: #i104585#: copy outline numbering rule to clipboard --- sw/source/core/docnode/ndcopy.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 088fe5b50424..315a51f85b88 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -922,6 +922,12 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, bool bCopyBookmarks = true; BOOL bStartIsTxtNode = 0 != pSttTxtNd; + // #i104585# copy outline num rule to clipboard (for ASCII filter) + if (pDoc->IsClipBoard() && GetOutlineNumRule()) + { + pDoc->SetOutlineNumRule(*GetOutlineNumRule()); + } + // --> OD 2009-08-25 #i86492# // Correct the search for a previous list: // First search for non-outline numbering list. Then search for non-outline -- cgit From 64cb69b7093f7629513293d25240a1794ae8f7f3 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 17:27:33 +0200 Subject: sw33bf03: #i110586#: use proper which range for autoformat item set --- sw/source/core/txtnode/thints.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 0e8c7163abc1..730e61c96c85 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -776,7 +776,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, // For each attribute in the automatic style check if it // is also set the the new character style: - SfxItemSet aNewSet( *pOldStyle->GetPool(), RES_CHRATR_BEGIN, RES_CHRATR_END ); + SfxItemSet aNewSet( *pOldStyle->GetPool(), + aCharAutoFmtSetRange); SfxItemIter aItemIter( *pOldStyle ); const SfxPoolItem* pItem = aItemIter.GetCurItem(); while( TRUE ) -- cgit From 1bd25912372dad5ad1371d363838b35b0775861d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 17:28:53 +0200 Subject: sw33bf03: #i110655#: SwRect::Justify(): fix regression from #i106401# --- sw/source/core/bastyp/swrect.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sw/source/core/bastyp/swrect.cxx b/sw/source/core/bastyp/swrect.cxx index e156c71aa5fb..554dad2ebfa2 100644 --- a/sw/source/core/bastyp/swrect.cxx +++ b/sw/source/core/bastyp/swrect.cxx @@ -245,7 +245,7 @@ void SwRect::Justify() } if ( m_Size.getWidth() < 0 ) { - m_Point.Y() += m_Size.getWidth() + 1; + m_Point.X() += m_Size.getWidth() + 1; m_Size.setWidth(-m_Size.getWidth()); } } -- cgit From c72e885c09d39d03bf35f27614342f7660e9f357 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 17:29:55 +0200 Subject: sw33bf03: xmloff: fonthdl.hxx: fix broken header guard --- xmloff/source/style/XMLFontAutoStylePool.cxx | 5 +++-- xmloff/source/style/XMLFontStylesContext.cxx | 15 +++++--------- xmloff/source/style/fonthdl.cxx | 2 -- xmloff/source/style/fonthdl.hxx | 6 +++--- xmloff/source/style/prhdlfac.cxx | 5 +++-- xmloff/source/style/xmlnume.cxx | 21 ++++++++++--------- xmloff/source/style/xmlnumi.cxx | 30 +++++++++++++--------------- 7 files changed, 40 insertions(+), 44 deletions(-) diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx index a5c662ef33a7..518cff949cbb 100644 --- a/xmloff/source/style/XMLFontAutoStylePool.cxx +++ b/xmloff/source/style/XMLFontAutoStylePool.cxx @@ -30,18 +30,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" + #include #include #include + #include "xmlnmspe.hxx" #include #include -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include "fonthdl.hxx" -#endif #include #include + using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/XMLFontStylesContext.cxx b/xmloff/source/style/XMLFontStylesContext.cxx index 4de58bbf232e..faf003a72253 100644 --- a/xmloff/source/style/XMLFontStylesContext.cxx +++ b/xmloff/source/style/XMLFontStylesContext.cxx @@ -31,25 +31,20 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#ifndef _COM_SUN_STAR_AWT_FONTFAMILY_HPP #include -#endif -#ifndef _COM_SUN_STAR_AWT_FONTPITCH_HPP #include -#endif + +#include + #include #include "xmlnmspe.hxx" #include -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include "fonthdl.hxx" -#endif #include #include - -#ifndef _XMLOFF_XMLFONTSTYLESCONTEXT_HXX #include -#endif -#include + + using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/fonthdl.cxx b/xmloff/source/style/fonthdl.cxx index acfc846883e7..0c711ef590eb 100644 --- a/xmloff/source/style/fonthdl.cxx +++ b/xmloff/source/style/fonthdl.cxx @@ -31,9 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include -#endif #include #include #include diff --git a/xmloff/source/style/fonthdl.hxx b/xmloff/source/style/fonthdl.hxx index d5543c471cc1..177be725bc1b 100644 --- a/xmloff/source/style/fonthdl.hxx +++ b/xmloff/source/style/fonthdl.hxx @@ -28,8 +28,8 @@ * ************************************************************************/ -#ifndef _XMLOFF_PROPERTYHANDLER_FONTYPES_HXX -#define _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX +#ifndef XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX +#define XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include @@ -82,4 +82,4 @@ public: }; -#endif // _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX +#endif // XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX diff --git a/xmloff/source/style/prhdlfac.cxx b/xmloff/source/style/prhdlfac.cxx index b328f3dddc3e..173e3ac3b997 100644 --- a/xmloff/source/style/prhdlfac.cxx +++ b/xmloff/source/style/prhdlfac.cxx @@ -30,10 +30,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" + #include #include #include + #include + #include #include #include @@ -42,9 +45,7 @@ #include #include "cdouthdl.hxx" #include "csmaphdl.hxx" -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include "fonthdl.hxx" -#endif #include "kernihdl.hxx" #include #include "shadwhdl.hxx" diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx index 7233c0f7da8f..f84a67f23697 100644 --- a/xmloff/source/style/xmlnume.cxx +++ b/xmloff/source/style/xmlnume.cxx @@ -30,15 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#include -#include -#include -#include "xmlnmspe.hxx" -#include -#include -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX -#include "fonthdl.hxx" -#endif + #include #include #include @@ -55,11 +47,22 @@ // <-- #include #include + +#include + +#include + +#include +#include "xmlnmspe.hxx" +#include +#include +#include "fonthdl.hxx" #include "XMLTextListAutoStylePool.hxx" #include #include #include + using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx index 66f10e7274c6..c7df4da6cad4 100644 --- a/xmloff/source/style/xmlnumi.cxx +++ b/xmloff/source/style/xmlnumi.cxx @@ -30,16 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#include -#include -#include -#include -#include -#include -#include "xmlnmspe.hxx" -#include -#include #include #include #include @@ -54,26 +45,33 @@ #include #include #include + +#include + +#include +#include +#include + +#include +#include +#include "xmlnmspe.hxx" +#include +#include #include #include "i18nmap.hxx" #include -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include "fonthdl.hxx" -#endif -#ifndef _XMLOFF_XMLFONTSTYLESCONTEXT_HXX #include -#endif -#ifndef _XMLOFF_FAMILIES_HXX #include -#endif #include - #include #define _SVSTDARR_USHORTS #include + + using ::rtl::OUString; using ::rtl::OUStringBuffer; -- cgit From 80fcc2da523bfae04094b105e67493f9d7679f8f Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 18:27:16 +0200 Subject: sw33bf03: #i110691#: import/export xml:id and {anim,draw,form,text}:id: in ODF 1.2, the ID attributes on many elements are deprecated, and must be used only in conjunction with xml:id. new method SvXMLExport::AddAttributeIdLegacy() should fix the export. --- xmloff/inc/xmloff/txtimp.hxx | 2 +- xmloff/inc/xmloff/xmlexp.hxx | 6 ++++ xmloff/source/chart/SchXMLExport.cxx | 21 ++++++++----- xmloff/source/chart/SchXMLParagraphContext.cxx | 18 +++++++++--- xmloff/source/core/xmlexp.cxx | 16 ++++++++++ xmloff/source/draw/animationexport.cxx | 22 +++----------- xmloff/source/draw/animationimport.cxx | 34 +++++++++++++--------- xmloff/source/draw/sdxmlexp.cxx | 4 ++- xmloff/source/draw/sdxmlimp.cxx | 4 +-- xmloff/source/draw/sdxmlimp_impl.hxx | 3 +- xmloff/source/draw/shapeexport.cxx | 6 ++-- xmloff/source/draw/ximpbody.cxx | 23 +++++++++++---- xmloff/source/draw/ximpshap.cxx | 4 ++- xmloff/source/forms/elementexport.cxx | 6 ++-- xmloff/source/forms/elementimport.cxx | 15 ++++++++-- xmloff/source/forms/formattributes.cxx | 2 +- .../source/text/XMLChangedRegionImportContext.cxx | 13 +++++++-- xmloff/source/text/XMLRedlineExport.cxx | 2 +- xmloff/source/text/txtimp.cxx | 2 +- xmloff/source/text/txtparae.cxx | 13 ++++++++- xmloff/source/text/txtparai.cxx | 15 ++++++---- xmloff/source/text/txtparai.hxx | 1 - 22 files changed, 157 insertions(+), 75 deletions(-) diff --git a/xmloff/inc/xmloff/txtimp.hxx b/xmloff/inc/xmloff/txtimp.hxx index 7e041d0bdc91..697c535d79fd 100644 --- a/xmloff/inc/xmloff/txtimp.hxx +++ b/xmloff/inc/xmloff/txtimp.hxx @@ -257,11 +257,11 @@ enum XMLTextPAttrTokens XML_TOK_TEXT_P_PROPERTY, XML_TOK_TEXT_P_CONTENT, XML_TOK_TEXT_P_DATATYPE, + XML_TOK_TEXT_P_TEXTID, XML_TOK_TEXT_P_STYLE_NAME, XML_TOK_TEXT_P_COND_STYLE_NAME, XML_TOK_TEXT_P_LEVEL, XML_TOK_TEXT_P_CLASS_NAMES, - XML_TOK_TEXT_P_ID, XML_TOK_TEXT_P_IS_LIST_HEADER, XML_TOK_TEXT_P_RESTART_NUMBERING, XML_TOK_TEXT_P_START_VALUE, diff --git a/xmloff/inc/xmloff/xmlexp.hxx b/xmloff/inc/xmloff/xmlexp.hxx index 2133a108da78..7b6054c37b55 100644 --- a/xmloff/inc/xmloff/xmlexp.hxx +++ b/xmloff/inc/xmloff/xmlexp.hxx @@ -593,6 +593,12 @@ public: /// name of stream in package, e.g., "content.xml" ::rtl::OUString GetStreamName() const; + // FIXME: this is only for legacy stuff that has not yet been adapted + // to implement XMetadatable; this can write duplicate IDs! + /// add xml:id and legacy namespace id + void SAL_DLLPRIVATE AddAttributeIdLegacy( + sal_uInt16 const nLegacyPrefix, ::rtl::OUString const& rValue); + /// add xml:id attribute (for RDF metadata) void AddAttributeXmlId(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> const & i_xIfc); diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index f7cf82abe974..43ab0b458ab5 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -44,9 +44,7 @@ #include #include -#ifndef _SVTOOLS_NMSPMAP_HXX #include -#endif #include "xmlnmspe.hxx" #include #include @@ -1536,8 +1534,11 @@ void SchXMLExportHelper::exportTable() // to allow a correct re-association when copying via clipboard if( !bHasOwnData && aFirstRowRangeIter != aFirstRowRangeEndIter ) { - if( (*aFirstRowRangeIter).getLength()) - mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aFirstRowRangeIter ); + if ((*aFirstRowRangeIter).getLength()) + { + mrExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT, + *aFirstRowRangeIter); + } ++aFirstRowRangeIter; } exportText( *aIt ); @@ -1561,7 +1562,10 @@ void SchXMLExportHelper::exportTable() // write the original range name as id into the local table // to allow a correct re-association when copying via clipboard if( !bHasOwnData && aFirstColumnRangeIter != aFirstColumnRangeEndIter ) - mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aFirstColumnRangeIter++ ); + { + mrExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT, + *aFirstColumnRangeIter++); + } exportText( *aFirstColIt ); ++aFirstColIt; } @@ -1579,8 +1583,11 @@ void SchXMLExportHelper::exportTable() if( ( !bHasOwnData && aDataRangeIter != aDataRangeEndIter ) && ( mbRowSourceColumns || (aInnerIt == aColIt->begin())) ) { - if( (*aDataRangeIter).getLength()) - mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aDataRangeIter ); + if ((*aDataRangeIter).getLength()) + { + mrExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT, + *aDataRangeIter); + } ++aDataRangeIter; } exportText( msString, false ); // do not convert tabs and lfs diff --git a/xmloff/source/chart/SchXMLParagraphContext.cxx b/xmloff/source/chart/SchXMLParagraphContext.cxx index 1d8a4e16bb8c..9e19c02437b8 100644 --- a/xmloff/source/chart/SchXMLParagraphContext.cxx +++ b/xmloff/source/chart/SchXMLParagraphContext.cxx @@ -63,6 +63,7 @@ void SchXMLParagraphContext::StartElement( const uno::Reference< xml::sax::XAttr { sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; rtl::OUString aValue; + bool bHaveXmlId( false ); for( sal_Int16 i = 0; i < nAttrCount; i++ ) { @@ -70,11 +71,20 @@ void SchXMLParagraphContext::StartElement( const uno::Reference< xml::sax::XAttr rtl::OUString aLocalName; USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - if( nPrefix == XML_NAMESPACE_TEXT && - IsXMLToken( aLocalName, XML_ID ) ) + if (IsXMLToken(aLocalName, XML_ID)) { - (*mpId) = xAttrList->getValueByIndex( i ); - break; // we only need this attribute + if (nPrefix == XML_NAMESPACE_XML) + { + (*mpId) = xAttrList->getValueByIndex( i ); + bHaveXmlId = true; + } + if (nPrefix == XML_NAMESPACE_TEXT) + { // text:id shall be ignored if xml:id exists + if (!bHaveXmlId) + { + (*mpId) = xAttrList->getValueByIndex( i ); + } + } } } } diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index e96759c3e470..ab91e2e19ab6 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -2454,6 +2454,22 @@ SvtSaveOptions::ODFDefaultVersion SvXMLExport::getDefaultVersion() const return mpImpl->mStreamName; } +void +SvXMLExport::AddAttributeIdLegacy( + sal_uInt16 const nLegacyPrefix, ::rtl::OUString const& rValue) +{ + switch (getDefaultVersion()) { + case SvtSaveOptions::ODFVER_011: // fall thru + case SvtSaveOptions::ODFVER_010: break; + default: // ODF 1.2: xml:id + AddAttribute(XML_NAMESPACE_XML, XML_ID, rValue); + } + // in ODF 1.1 this was form:id, anim:id, draw:id, or text:id + // backward compatibility: in ODF 1.2 write _both_ id attrs + AddAttribute(nLegacyPrefix, XML_ID, rValue); + // FIXME: this function simply assumes that rValue is unique +} + void SvXMLExport::AddAttributeXmlId(uno::Reference const & i_xIfc) { diff --git a/xmloff/source/draw/animationexport.cxx b/xmloff/source/draw/animationexport.cxx index 4d7a8af1a1e9..03bda0108b5c 100644 --- a/xmloff/source/draw/animationexport.cxx +++ b/xmloff/source/draw/animationexport.cxx @@ -31,24 +31,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateColor_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateSet_HPP_ #include -#endif #include #include #include -#ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateMotion_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateTransform_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_ANIMATIONS_XTransitionFilter_HPP_ #include -#endif #include #include #include @@ -67,19 +57,12 @@ #include #include #include -#ifndef _COM_SUN_STAR_PRESENTATION_EffectPresetClass_HPP_ #include -#endif -#ifndef _COM_SUN_STAR_PRESENTATION_ParagraphTarget_HPP_ #include -#endif #include #include #include - -#ifndef _COM_SUN_STAR_DRAWING_XShape_HPP_ #include -#endif #include #include @@ -783,7 +766,10 @@ void AnimationsExporterImpl::exportNode( const Reference< XAnimationNode >& xNod const OUString& rExportIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xNode ); if( rExportIdentifier.getLength() ) - mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_ID, rExportIdentifier ); + { + mrExport.AddAttributeIdLegacy( + XML_NAMESPACE_ANIMATION, rExportIdentifier); + } Any aTemp( xNode->getBegin() ); if( aTemp.hasValue() ) diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx index 6569c9d5408d..e151d2752358 100644 --- a/xmloff/source/draw/animationimport.cxx +++ b/xmloff/source/draw/animationimport.cxx @@ -50,18 +50,14 @@ #include #include #include -#ifndef _COM_SUN_STAR_PRESENTATION_EffectPresetClass_HPP_ #include -#endif #include #include #include #include #include #include -#ifndef _COM_SUN_STAR_PRESENTATION_ParagraphTarget_HPP_ #include -#endif #include #include #include @@ -240,7 +236,8 @@ enum AnimationNodeAttributes ANA_IterateType, ANA_IterateInterval, ANA_Formula, - ANA_ID, + ANA_ANIMID, + ANA_XMLID, ANA_Group_Id, ANA_Command, ANA_Volume @@ -297,8 +294,8 @@ const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeAttributeTokenM { XML_NAMESPACE_ANIMATION, XML_ITERATE_TYPE, (sal_uInt16)ANA_IterateType }, { XML_NAMESPACE_ANIMATION, XML_ITERATE_INTERVAL, (sal_uInt16)ANA_IterateInterval }, { XML_NAMESPACE_ANIMATION, XML_FORMULA, (sal_uInt16)ANA_Formula }, - { XML_NAMESPACE_ANIMATION, XML_ID, (sal_uInt16)ANA_ID }, - { XML_NAMESPACE_XML, XML_ID, (sal_uInt16)ANA_ID }, + { XML_NAMESPACE_ANIMATION, XML_ID, (sal_uInt16)ANA_ANIMID }, + { XML_NAMESPACE_XML, XML_ID, (sal_uInt16)ANA_XMLID }, { XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, (sal_uInt16)ANA_Group_Id }, { XML_NAMESPACE_ANIMATION, XML_AUDIO_LEVEL, (sal_uInt16)ANA_Volume }, { XML_NAMESPACE_ANIMATION, XML_COMMAND, (sal_uInt16)ANA_Command }, @@ -811,6 +808,8 @@ void AnimationNodeContext::init_node( const ::com::sun::star::uno::Reference< : std::list< NamedValue > aUserData; XMLTokenEnum meAttributeName = XML_TOKEN_INVALID; OUString aFrom, aBy, aTo, aValues; + bool bHaveXmlId( false ); + OUString sXmlId; const sal_Int16 nCount = xAttrList.is() ? xAttrList->getLength() : 0; sal_uInt16 nEnum; @@ -1057,13 +1056,15 @@ void AnimationNodeContext::init_node( const ::com::sun::star::uno::Reference< : } break; - case ANA_ID: + case ANA_ANIMID: { - if( rValue.getLength() ) - { - Reference< XInterface > xRef( mxNode, UNO_QUERY ); - GetImport().getInterfaceToIdentifierMapper().registerReference( rValue, xRef ); - } + if (!bHaveXmlId) { sXmlId = rValue; } + } + break; + case ANA_XMLID: + { + sXmlId = rValue; + bHaveXmlId = true; } break; @@ -1254,6 +1255,13 @@ void AnimationNodeContext::init_node( const ::com::sun::star::uno::Reference< : } } + if (sXmlId.getLength()) + { + Reference< XInterface > const xRef( mxNode, UNO_QUERY ); + GetImport().getInterfaceToIdentifierMapper().registerReference( + sXmlId, xRef ); + } + sal_Int32 nUserDataCount = aUserData.size(); if( nUserDataCount ) { diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index 1d7414d4ca23..c9e8ec821f82 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -2014,7 +2014,9 @@ void SdXMLExport::_ExportContent() // write draw:id const OUString aPageId = getInterfaceToIdentifierMapper().getIdentifier( xDrawPage ); if( aPageId.getLength() != 0 ) - AddAttribute ( XML_NAMESPACE_DRAW, XML_ID, aPageId ); + { + AddAttributeIdLegacy(XML_NAMESPACE_DRAW, aPageId); + } // write page SvXMLElementExport aDPG(*this, XML_NAMESPACE_DRAW, XML_PAGE, sal_True, sal_True); diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index 47e1e0f5810b..7f85a69fa5ed 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -668,8 +668,8 @@ const SvXMLTokenMap& SdXMLImport::GetDrawPageAttrTokenMap() { XML_NAMESPACE_DRAW, XML_STYLE_NAME, XML_TOK_DRAWPAGE_STYLE_NAME }, { XML_NAMESPACE_DRAW, XML_MASTER_PAGE_NAME, XML_TOK_DRAWPAGE_MASTER_PAGE_NAME }, { XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME }, - { XML_NAMESPACE_DRAW, XML_ID, XML_TOK_DRAWPAGE_ID }, - { XML_NAMESPACE_XML, XML_ID, XML_TOK_DRAWPAGE_ID }, + { XML_NAMESPACE_DRAW, XML_ID, XML_TOK_DRAWPAGE_DRAWID }, + { XML_NAMESPACE_XML, XML_ID, XML_TOK_DRAWPAGE_XMLID }, { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_DRAWPAGE_HREF }, { XML_NAMESPACE_PRESENTATION, XML_USE_HEADER_NAME, XML_TOK_DRAWPAGE_USE_HEADER_NAME }, { XML_NAMESPACE_PRESENTATION, XML_USE_FOOTER_NAME, XML_TOK_DRAWPAGE_USE_FOOTER_NAME }, diff --git a/xmloff/source/draw/sdxmlimp_impl.hxx b/xmloff/source/draw/sdxmlimp_impl.hxx index 11b618cae126..825936d4caa0 100644 --- a/xmloff/source/draw/sdxmlimp_impl.hxx +++ b/xmloff/source/draw/sdxmlimp_impl.hxx @@ -133,7 +133,8 @@ enum SdXMLDrawPageAttrTokenMap XML_TOK_DRAWPAGE_STYLE_NAME, XML_TOK_DRAWPAGE_MASTER_PAGE_NAME, XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME, - XML_TOK_DRAWPAGE_ID, + XML_TOK_DRAWPAGE_DRAWID, + XML_TOK_DRAWPAGE_XMLID, XML_TOK_DRAWPAGE_HREF, XML_TOK_DRAWPAGE_USE_HEADER_NAME, XML_TOK_DRAWPAGE_USE_FOOTER_NAME, diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 3a0e01631f28..9f971de54ab2 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -46,9 +46,7 @@ #include #include "PropertySetMerger.hxx" -#ifndef _XMLOFF_SHAPEEXPORT_HXX #include -#endif #include "sdpropls.hxx" #include "sdxmlexp_impl.hxx" #include @@ -642,7 +640,9 @@ void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape uno::Reference< uno::XInterface > xRef( xShape, uno::UNO_QUERY ); const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRef ); if( rShapeId.getLength() ) - mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_ID, rShapeId ); + { + mrExport.AddAttributeIdLegacy(XML_NAMESPACE_DRAW, rShapeId); + } } // -------------------------- diff --git a/xmloff/source/draw/ximpbody.cxx b/xmloff/source/draw/ximpbody.cxx index 8a226a008251..9909c3d113ce 100644 --- a/xmloff/source/draw/ximpbody.cxx +++ b/xmloff/source/draw/ximpbody.cxx @@ -65,6 +65,9 @@ SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport, : SdXMLGenericPageContext( rImport, nPrfx, rLocalName, xAttrList, rShapes ) , mbHadSMILNodes( false ) { + bool bHaveXmlId( false ); + OUString sXmlId; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; for(sal_Int16 i=0; i < nAttrCount; i++) @@ -112,13 +115,17 @@ SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport, maUseDateTimeDeclName = sValue; break; } - - case XML_TOK_DRAWPAGE_ID: + case XML_TOK_DRAWPAGE_DRAWID: { - uno::Reference< uno::XInterface > xRef( rShapes.get() ); - GetImport().getInterfaceToIdentifierMapper().registerReference( sValue, xRef ); - break; + if (!bHaveXmlId) { sXmlId = sValue; } } + break; + case XML_TOK_DRAWPAGE_XMLID: + { + sXmlId = sValue; + bHaveXmlId = true; + } + break; case XML_TOK_DRAWPAGE_HREF: { maHREF = sValue; @@ -127,6 +134,12 @@ SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport, } } + if (sXmlId.getLength()) + { + uno::Reference< uno::XInterface > const xRef( rShapes.get() ); + GetImport().getInterfaceToIdentifierMapper().registerReference( + sXmlId, xRef ); + } GetImport().GetShapeImport()->startPage( rShapes ); uno::Reference< drawing::XDrawPage > xShapeDrawPage(rShapes, uno::UNO_QUERY); diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index c4c86abb7eef..0c78d0d58e4b 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -764,6 +764,7 @@ void SdXMLShapeContext::SetThumbnail() // this is called from the parent group for each unparsed attribute in the attribute list void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) { + bool bHaveXmlId( false ); if( XML_NAMESPACE_DRAW == nPrefix ) { if( IsXMLToken( rLocalName, XML_ZINDEX ) ) @@ -772,7 +773,7 @@ void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUStr } else if( IsXMLToken( rLocalName, XML_ID ) ) { - maShapeId = rValue; + if (!bHaveXmlId) { maShapeId = rValue; }; } else if( IsXMLToken( rLocalName, XML_NAME ) ) { @@ -865,6 +866,7 @@ void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUStr if( IsXMLToken( rLocalName, XML_ID ) ) { maShapeId = rValue; + bHaveXmlId = true; } } } diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index a17138654730..f28eab48e428 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -316,10 +316,8 @@ namespace xmloff if (CCA_CONTROL_ID & m_nIncludeCommon) { OSL_ENSURE(m_sControlId.getLength(), "OControlExport::exportInnerAttributes: have no control id for the control!"); - AddAttribute( - OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CONTROL_ID), - OAttributeMetaData::getCommonControlAttributeName(CCA_CONTROL_ID), - m_sControlId); + m_rContext.getGlobalContext().AddAttributeIdLegacy( + XML_NAMESPACE_FORM, m_sControlId); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking m_nIncludeCommon = m_nIncludeCommon & ~CCA_CONTROL_ID; diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 7bdb61ff86fd..cb1388c47386 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -589,12 +589,21 @@ namespace xmloff //--------------------------------------------------------------------- void OControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) { - static const sal_Char* pControlIdAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CONTROL_ID); static const sal_Char* pLinkedCellAttributeName = OAttributeMetaData::getBindingAttributeName(BA_LINKED_CELL); - if ( !m_sControlId.getLength() && _rLocalName.equalsAscii( pControlIdAttributeName ) ) + if (IsXMLToken(_rLocalName, XML_ID)) { // it's the control id - m_sControlId = _rValue; + if (XML_NAMESPACE_XML == _nNamespaceKey) + { + m_sControlId = _rValue; + } + else if (XML_NAMESPACE_FORM == _nNamespaceKey) + { + if (!m_sControlId.getLength()) + { + m_sControlId = _rValue; + } + } } else if ( _rLocalName.equalsAscii( pLinkedCellAttributeName ) ) { // it's the address of a spreadsheet cell diff --git a/xmloff/source/forms/formattributes.cxx b/xmloff/source/forms/formattributes.cxx index 0c2431590b63..e21786e376d2 100644 --- a/xmloff/source/forms/formattributes.cxx +++ b/xmloff/source/forms/formattributes.cxx @@ -56,7 +56,7 @@ namespace xmloff case CCA_NAME: return "name"; case CCA_SERVICE_NAME: return "control-implementation"; case CCA_BUTTON_TYPE: return "button-type"; - case CCA_CONTROL_ID: return "id"; +// disabled(AddAttributeIdLegacy) case CCA_CONTROL_ID: return "id"; case CCA_CURRENT_SELECTED: return "current-selected"; case CCA_CURRENT_VALUE: return "current-value"; case CCA_DISABLED: return "disabled"; diff --git a/xmloff/source/text/XMLChangedRegionImportContext.cxx b/xmloff/source/text/XMLChangedRegionImportContext.cxx index 220f235d9ddd..347590a6e5b6 100644 --- a/xmloff/source/text/XMLChangedRegionImportContext.cxx +++ b/xmloff/source/text/XMLChangedRegionImportContext.cxx @@ -71,6 +71,7 @@ void XMLChangedRegionImportContext::StartElement( const Reference & xAttrList) { // process attributes: id + bool bHaveXmlId( false ); sal_Int16 nLength = xAttrList->getLength(); for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) { @@ -80,11 +81,19 @@ void XMLChangedRegionImportContext::StartElement( &sLocalName ); const OUString sValue = xAttrList->getValueByIndex(nAttr); - if ( XML_NAMESPACE_TEXT == nPrefix ) + if (XML_NAMESPACE_XML == nPrefix) { - if( IsXMLToken( sLocalName, XML_ID ) ) + if (IsXMLToken(sLocalName, XML_ID)) { sID = sValue; + bHaveXmlId = true; + } + } + else if (XML_NAMESPACE_TEXT == nPrefix) + { + if (IsXMLToken(sLocalName, XML_ID)) + { + if (!bHaveXmlId) { sID = sValue; } } else if( IsXMLToken( sLocalName, XML_MERGE_LAST_PARAGRAPH ) ) { diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx index 2cb0f24eab2a..1ad405a27969 100644 --- a/xmloff/source/text/XMLRedlineExport.cxx +++ b/xmloff/source/text/XMLRedlineExport.cxx @@ -377,7 +377,7 @@ void XMLRedlineExport::ExportChangedRegion( const Reference & rPropSet) { // Redline-ID - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_ID, GetRedlineID(rPropSet) ); + rExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT, GetRedlineID(rPropSet)); // merge-last-paragraph Any aAny = rPropSet->getPropertyValue(sMergeLastPara); diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index af20bfbb23dc..0fcc326982b8 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -332,11 +332,11 @@ static __FAR_DATA SvXMLTokenMapEntry aTextPAttrTokenMap[] = { XML_NAMESPACE_XHTML, XML_PROPERTY, XML_TOK_TEXT_P_PROPERTY }, { XML_NAMESPACE_XHTML, XML_CONTENT, XML_TOK_TEXT_P_CONTENT }, { XML_NAMESPACE_XHTML, XML_DATATYPE, XML_TOK_TEXT_P_DATATYPE }, + { XML_NAMESPACE_TEXT, XML_ID, XML_TOK_TEXT_P_TEXTID }, { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_P_STYLE_NAME }, { XML_NAMESPACE_TEXT, XML_COND_STYLE_NAME, XML_TOK_TEXT_P_COND_STYLE_NAME }, { XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,XML_TOK_TEXT_P_LEVEL }, - { XML_NAMESPACE_TEXT, XML_ID, XML_TOK_TEXT_P_ID }, { XML_NAMESPACE_TEXT, XML_IS_LIST_HEADER,XML_TOK_TEXT_P_IS_LIST_HEADER }, { XML_NAMESPACE_TEXT, XML_RESTART_NUMBERING,XML_TOK_TEXT_P_RESTART_NUMBERING }, { XML_NAMESPACE_TEXT, XML_START_VALUE,XML_TOK_TEXT_P_START_VALUE }, diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index f07d8a89c5ef..4e0702b94388 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -1937,7 +1937,18 @@ void XMLTextParagraphExport::exportParagraph( { const OUString& rIdentifier = GetExport().getInterfaceToIdentifierMapper().getIdentifier( xRef ); if( rIdentifier.getLength() ) - GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_ID, rIdentifier ); + { + // FIXME: this is just temporary until EditEngine + // paragraphs implement XMetadatable. + // then that must be used and not the mapper, because + // when both can be used we get two xml:id! + uno::Reference const xMeta(xRef, + uno::UNO_QUERY); + OSL_ENSURE(!xMeta.is(), "paragraph that implements " + "XMetadatable used in interfaceToIdentifierMapper?"); + GetExport().AddAttributeIdLegacy(XML_NAMESPACE_TEXT, + rIdentifier); + } } OUString sAutoStyle( sStyle ); diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index aaac42d14597..0d7661ac2c1c 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -1920,6 +1920,7 @@ XMLParaContext::XMLParaContext( const SvXMLTokenMap& rTokenMap = GetImport().GetTextImport()->GetTextPAttrTokenMap(); + bool bHaveXmlId( false ); OUString aCondStyleName, sClassNames; sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; @@ -1936,6 +1937,7 @@ XMLParaContext::XMLParaContext( { case XML_TOK_TEXT_P_XMLID: m_sXmlId = rValue; + bHaveXmlId = true; break; case XML_TOK_TEXT_P_ABOUT: m_sAbout = rValue; @@ -1950,6 +1952,9 @@ XMLParaContext::XMLParaContext( case XML_TOK_TEXT_P_DATATYPE: m_sDatatype = rValue; break; + case XML_TOK_TEXT_P_TEXTID: + if (!bHaveXmlId) { m_sXmlId = rValue; } + break; case XML_TOK_TEXT_P_STYLE_NAME: sStyleName = rValue; break; @@ -1982,9 +1987,6 @@ XMLParaContext::XMLParaContext( } } break; - case XML_TOK_TEXT_P_ID: - sId = rValue; - break; case XML_TOK_TEXT_P_RESTART_NUMBERING: { sal_Bool bBool; @@ -2023,14 +2025,17 @@ XMLParaContext::~XMLParaContext() // if we have an id set for this paragraph, get a cursor for this // paragraph and register it with the given identifier - if( sId.getLength() ) + // FIXME: this is just temporary, and should be removed when + // EditEngine paragraphs implement XMetadatable! + if (m_sXmlId.getLength()) { Reference < XTextCursor > xIdCursor( xTxtImport->GetText()->createTextCursorByRange( xStart ) ); if( xIdCursor.is() ) { xIdCursor->gotoRange( xEnd, sal_True ); Reference< XInterface > xRef( xIdCursor, UNO_QUERY ); - GetImport().getInterfaceToIdentifierMapper().registerReference( sId, xRef ); + GetImport().getInterfaceToIdentifierMapper().registerReference( + m_sXmlId, xRef); } } diff --git a/xmloff/source/text/txtparai.hxx b/xmloff/source/text/txtparai.hxx index 6eaeeee1ee46..af8296fd1b07 100644 --- a/xmloff/source/text/txtparai.hxx +++ b/xmloff/source/text/txtparai.hxx @@ -49,7 +49,6 @@ class XMLParaContext : public SvXMLImportContext ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextRange > xStart; // xub_StrLen nStart; ::rtl::OUString sStyleName; - ::rtl::OUString sId; ::rtl::OUString m_sXmlId; ::rtl::OUString m_sAbout; ::rtl::OUString m_sProperty; -- cgit From 52efbb2a0a17eacdcce9a1c034a4077f977b75d0 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 19 Apr 2010 18:28:13 +0200 Subject: sw33bf03: #i110694#: exportLevelStyle: no style-name on list-level-style-image --- xmloff/source/style/xmlnume.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx index f84a67f23697..9b6fe97badd8 100644 --- a/xmloff/source/style/xmlnume.cxx +++ b/xmloff/source/style/xmlnume.cxx @@ -300,9 +300,12 @@ void SvxXMLNumRuleExport::exportLevelStyle( INT32 nLevel, OUStringBuffer sTmp; sTmp.append( nLevel + 1 ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_LEVEL, sTmp.makeStringAndClear() ); - if( sTextStyleName.getLength() > 0 ) + // #i110694#: no style-name on list-level-style-image + if ((sTextStyleName.getLength() > 0) && (NumberingType::BITMAP != eType)) + { GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( sTextStyleName ) ); + } if( sPrefix.getLength() > 0 ) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NUM_PREFIX, sPrefix ); if( sSuffix.getLength() > 0 ) -- cgit From a48f33596d08f23f1f1358414bdcadd200ac0e5f Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 19 Apr 2010 20:29:31 +0100 Subject: ab75: #i10417# make sure substituted Err object only returned for vba mode --- basic/source/runtime/stdobj.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index d2585501c826..fd4cacc646d5 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -656,7 +656,7 @@ SbxVariable* SbiStdObject::Find( const String& rName, SbxClassType t ) // #TODO #FIXME hack for substituting ooo-basic Err with vba-ish // ErrObject object static String sErr( RTL_CONSTASCII_USTRINGPARAM("Err") ); - if ( rName.EqualsIgnoreCaseAscii( sErr ) ) + if ( SbiRuntime::isVBAEnabled() && rName.EqualsIgnoreCaseAscii( sErr ) ) return SbxErrObject::getErrObject(); // Bereits eingetragen? SbxVariable* pVar = SbxObject::Find( rName, t ); -- cgit From cb2bcac3474ca249546e474134f1802b02631f64 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 20 Apr 2010 10:31:03 +0100 Subject: remove some stray instances of lcl_getObject ( now implemented in ModuleInfoHelper::getObjectName ) --- basctl/source/basicide/baside2.cxx | 4 +--- basctl/source/basicide/basides2.cxx | 25 +------------------------ 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 0fa09a00f255..71dcd25ed51a 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -108,8 +108,6 @@ DBG_NAME( ModulWindow ) TYPEINIT1( ModulWindow , IDEBaseWindow ); -void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName ); - void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle, bool bOutput ) { short nLeftMargin = LMARGPRN; @@ -1417,7 +1415,7 @@ BasicEntryDescriptor ModulWindow::CreateEntryDescriptor() if( xLib.is() ) { String sObjName; - lcl_getObjectName( xLib, aModName, sObjName ); + ModuleInfoHelper::getObjectName( xLib, aModName, sObjName ); if( sObjName.Len() ) { aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")"); diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index c6f6a77a9446..831233e78068 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -60,29 +60,6 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; namespace css = ::com::sun::star; -void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName ) -{ - try - { - uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); - if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) ) - { - script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName ); - uno::Any aObject( aModuleInfo.ModuleObject ); - uno::Reference< lang::XServiceInfo > xServiceInfo( aObject, uno::UNO_QUERY ); - if( xServiceInfo.is() && xServiceInfo->supportsService( rtl::OUString::createFromAscii( "ooo.vba.excel.Worksheet" ) ) ) - { - uno::Reference< container::XNamed > xNamed( aObject, uno::UNO_QUERY ); - if( xNamed.is() ) - rObjName = xNamed->getName(); - } - } - } - catch( uno::Exception& ) - { - } -} - IMPL_LINK_INLINE_START( BasicIDEShell, ObjectDialogCancelHdl, ObjectCatalog *, EMPTYARG ) { ShowObjectDialog( FALSE, TRUE ); @@ -306,7 +283,7 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const // display a nice friendly name in the ObjectModule tab, // combining the objectname and module name, e.g. Sheet1 ( Financials ) String sObjName; - lcl_getObjectName( xLib, rModName, sObjName ); + ModuleInfoHelper::getObjectName( xLib, rModName, sObjName ); if( sObjName.Len() ) { aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")"); -- cgit From 72a7c8ea482842a63311bf00e39ff077776cc6a6 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 20 Apr 2010 13:11:25 +0100 Subject: ab75: #i110417# improve ErrObj behaviour --- basic/source/classes/errobject.cxx | 12 ++++++++---- basic/source/classes/sb.cxx | 32 ++++++++++++++++++++++++++++++++ basic/source/classes/sb.src | 4 ++-- basic/source/runtime/methods.cxx | 16 ++++++++++++++-- basic/source/runtime/runtime.cxx | 16 +++++++--------- 5 files changed, 63 insertions(+), 17 deletions(-) diff --git a/basic/source/classes/errobject.cxx b/basic/source/classes/errobject.cxx index dc62e65b6945..c34fa0a49aec 100644 --- a/basic/source/classes/errobject.cxx +++ b/basic/source/classes/errobject.cxx @@ -19,6 +19,7 @@ class ErrObject : public ErrObjectImpl_BASE rtl::OUString m_sDescription; sal_Int32 m_nNumber; sal_Int32 m_nHelpContext; + bool mbIsInError; public: ErrObject(); @@ -47,7 +48,7 @@ ErrObject::~ErrObject() { } -ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0) +ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0), mbIsInError(false) { } @@ -60,9 +61,9 @@ ErrObject::getNumber() throw (uno::RuntimeException) void SAL_CALL ErrObject::setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException) { - m_nNumber = _number; - - +// m_nNumber = _number; + if ( !mbIsInError ) + Raise( uno::makeAny( _number ), uno::Any(), uno::Any(), uno::Any(), uno::Any() ); } ::sal_Int32 SAL_CALL @@ -128,6 +129,8 @@ ErrObject::Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any { if ( !Number.hasValue() ) throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference< uno::XInterface >() ); + mbIsInError = true; + Clear(); Description >>= m_sDescription; Source >>= m_sSource; HelpFile >>= m_sHelpFile; @@ -140,6 +143,7 @@ ErrObject::Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any n = m_nNumber; // force orig number, probably should have a specific table of vb ( localized ) errors pINST->Error( n, m_sDescription ); } + mbIsInError = false; } // XDefaultProperty diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 60f4de70c2be..b76453999212 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -54,6 +54,7 @@ #include "sb.hrc" #include #include +#include "errobject.hxx" // #pragma SW_SEGMENT_CLASS( SBASIC, SBASIC_CODE ) @@ -1330,6 +1331,7 @@ void StarBASIC::MakeErrorText( SbError nId, const String& aMsg ) } else GetSbData()->aErrMsg = String::EmptyString(); + } BOOL StarBASIC::CError @@ -1356,7 +1358,22 @@ BOOL StarBASIC::CError // Umsetzung des Codes fuer String-Transport in SFX-Error if( rMsg.Len() ) + { + // very confusing, even though MakeErrorText sets up the error text + // seems that this is not used ( if rMsg already has content ) + // In the case of VBA MakeErrorText also formats the error to be alittle more + // like vba ( adds an error number etc ) + if ( SbiRuntime::isVBAEnabled() && ( code == SbERR_BASIC_COMPAT ) ) + { + String aTmp = '\''; + aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() ); + aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") ); + aTmp += GetSbData()->aErrMsg.Len() ? GetSbData()->aErrMsg : rMsg; + code = (ULONG)*new StringErrorInfo( code, aTmp ); + } + else code = (ULONG)*new StringErrorInfo( code, String(rMsg) ); + } SetErrorData( code, l, c1, c2 ); GetSbData()->bCompiler = TRUE; @@ -1386,7 +1403,22 @@ BOOL StarBASIC::RTError( SbError code, const String& rMsg, USHORT l, USHORT c1, // Umsetzung des Codes fuer String-Transport in SFX-Error if( rMsg.Len() ) + { + // very confusing, even though MakeErrorText sets up the error text + // seems that this is not used ( if rMsg already has content ) + // In the case of VBA MakeErrorText also formats the error to be alittle more + // like vba ( adds an error number etc ) + if ( SbiRuntime::isVBAEnabled() && ( code == SbERR_BASIC_COMPAT ) ) + { + String aTmp = '\''; + aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() ); + aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") ); + aTmp += GetSbData()->aErrMsg.Len() ? GetSbData()->aErrMsg : rMsg; + code = (ULONG)*new StringErrorInfo( code, aTmp ); + } + else code = (ULONG)*new StringErrorInfo( code, String(rMsg) ); + } SetErrorData( code, l, c1, c2 ); if( GetSbData()->aErrHdl.IsSet() ) diff --git a/basic/source/classes/sb.src b/basic/source/classes/sb.src index 41ae03d9934f..4e0eacf10d2f 100644 --- a/basic/source/classes/sb.src +++ b/basic/source/classes/sb.src @@ -590,8 +590,8 @@ Resource RID_BASIC_START }; String ERRCODE_BASIC_COMPAT & ERRCODE_RES_MASK { - Text [ de ] = "$(ARG1)." ; - Text [ en-US ] = "$(ARG1)." ; + Text [ de ] = "$(ARG1)" ; + Text [ en-US ] = "$(ARG1)" ; Text [ x-comment ] = " "; }; }; diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 9a21e488d4aa..0a5a2b1736dd 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -61,6 +61,7 @@ #else #include #endif +#include "errobject.hxx" #ifdef _USE_UNO #include @@ -256,6 +257,7 @@ RTLFUNC(Error) { String aErrorMsg; SbError nErr = 0L; + INT32 nCode = 0; if( rPar.Count() == 1 ) { nErr = StarBASIC::GetErrBasic(); @@ -263,14 +265,24 @@ RTLFUNC(Error) } else { - INT32 nCode = rPar.Get( 1 )->GetLong(); + nCode = rPar.Get( 1 )->GetLong(); if( nCode > 65535L ) StarBASIC::Error( SbERR_CONVERSION ); else nErr = StarBASIC::GetSfxFromVBError( (USHORT)nCode ); } pBasic->MakeErrorText( nErr, aErrorMsg ); - rPar.Get( 0 )->PutString( pBasic->GetErrorText() ); + String tmpErrMsg( pBasic->GetErrorText() ); + // If this rtlfunc 'Error' passed a errcode the same as the active Err Objects's + // current err then return the description for the error message if it is set + // ( complicated isn't it ? ) + if ( SbiRuntime::isVBAEnabled() && rPar.Count() > 1 ); + { + com::sun::star::uno::Reference< ooo::vba::XErrObject > xErrObj( SbxErrObject::getUnoErrObject() ); + if ( xErrObj.is() && xErrObj->getNumber() == nCode && xErrObj->getDescription().getLength() ) + tmpErrMsg = xErrObj->getDescription(); + } + rPar.Get( 0 )->PutString( tmpErrMsg ); } } diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 75ff47c73486..59129d0db9b9 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -807,7 +807,11 @@ void SbiRuntime::Error( SbError n ) // we really need a new vba compatible error list if ( !aMsg.Len() ) { - StarBASIC::MakeErrorText( n, aMsg ); + // is the error number vb or ( sb ) + SbError nTmp = StarBASIC::GetSfxFromVBError( n ); + if ( !nTmp ) + nTmp = n; + StarBASIC::MakeErrorText( nTmp, aMsg ); aMsg = StarBASIC::GetErrorText(); if ( !aMsg.Len() ) // no message for err no. // need localized resource here @@ -815,14 +819,8 @@ void SbiRuntime::Error( SbError n ) } // no num? most likely then it *is* really a vba err SbxErrObject::getUnoErrObject()->setNumber( ( StarBASIC::GetVBErrorCode( n ) == 0 ) ? n : StarBASIC::GetVBErrorCode( n ) ); - SbxErrObject::getUnoErrObject()->setDescription( aMsg ); - - // prepend an error number to the message. - String aTmp = '\''; - aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() ); - aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") ); - aTmp += aMsg; - + //SbxErrObject::getUnoErrObject()->setDescription( aMsg ); + String aTmp = aMsg; pInst->aErrorMsg = aTmp; nError = SbERR_BASIC_COMPAT; } -- cgit From a29c2768c22e4d47d527d754ef8285aed7a58de4 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 20 Apr 2010 13:11:25 +0100 Subject: ab75: #i110417# improve ErrObj behaviour --- sc/source/ui/vba/testvba/runTests.pl | 2 +- sc/source/ui/vba/testvba/testclient | Bin 39390 -> 50595 bytes 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 sc/source/ui/vba/testvba/runTests.pl diff --git a/sc/source/ui/vba/testvba/runTests.pl b/sc/source/ui/vba/testvba/runTests.pl old mode 100644 new mode 100755 index f5051516a9c4..e686a1d4cb89 --- a/sc/source/ui/vba/testvba/runTests.pl +++ b/sc/source/ui/vba/testvba/runTests.pl @@ -20,7 +20,7 @@ my $theResult; my $officepath = shift || die "please specify path to office installation program dir"; my $DocName = shift || ""; my $programpath = "$officepath"."3/program:$officepath/program:"; -my $basiclibrarypath = "$officepath/basis3.2/program"; +my $basiclibrarypath = "$officepath/basis3.3/program"; my $urelibpath = "$officepath/ure/lib"; my $binext = ""; my $testDocDir = "$binDir/TestDocuments"; diff --git a/sc/source/ui/vba/testvba/testclient b/sc/source/ui/vba/testvba/testclient index 12e9ca1659f4..c9cde8c5b052 100755 Binary files a/sc/source/ui/vba/testvba/testclient and b/sc/source/ui/vba/testvba/testclient differ -- cgit From b9840e950dfbba863080dd0de76c75364261ecf9 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 20 Apr 2010 13:21:03 +0100 Subject: ab75: #i110417# get rid of unnecessary tmp string --- basic/source/runtime/runtime.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 59129d0db9b9..761955f6e877 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -819,9 +819,7 @@ void SbiRuntime::Error( SbError n ) } // no num? most likely then it *is* really a vba err SbxErrObject::getUnoErrObject()->setNumber( ( StarBASIC::GetVBErrorCode( n ) == 0 ) ? n : StarBASIC::GetVBErrorCode( n ) ); - //SbxErrObject::getUnoErrObject()->setDescription( aMsg ); - String aTmp = aMsg; - pInst->aErrorMsg = aTmp; + pInst->aErrorMsg = aMsg; nError = SbERR_BASIC_COMPAT; } } -- cgit From eea019398f2c849b702c49d9e55bdbd059a34c7b Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Wed, 21 Apr 2010 11:08:13 +0200 Subject: gridcontrol_03:fix for #i110947# --- svtools/inc/svtools/table/abstracttablecontrol.hxx | 2 +- svtools/source/uno/svtxgridcontrol.cxx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx index 849c2cd23905..ba9bec8e0e2e 100644 --- a/svtools/inc/svtools/table/abstracttablecontrol.hxx +++ b/svtools/inc/svtools/table/abstracttablecontrol.hxx @@ -121,7 +121,7 @@ namespace svt { namespace table virtual void resizeColumn(const Point& rPoint ) = 0; virtual bool startResizeColumn(const Point& rPoint) = 0; virtual bool endResizeColumn(const Point& rPoint) = 0; - virtual bool isRowSelected(RowPos _nRow); + virtual bool isRowSelected(RowPos _nRow) = 0; virtual ~IAbstractTableControl() {}; }; diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 8d3edad11be5..f29273b1ec65 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -127,7 +127,6 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An ::vos::OGuard aGuard( GetMutex() ); TableControl* pTable = (TableControl*)GetWindow(); - sal_Int32 fontHeight = GetWindow()->GetTextHeight(); switch( GetPropertyId( PropertyName ) ) { case BASEPROPERTY_GRID_SELECTIONMODE: @@ -291,6 +290,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } else throw GridInvalidDataException(rtl::OUString::createFromAscii("The data model isn't set!"), m_xDataModel); + sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() ), MAP_APPFONT ).Height(); if(m_xDataModel->getRowHeight() == 0) m_pTableModel->setRowHeight(fontHeight); else @@ -309,6 +309,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An Sequence > columns = m_xColumnModel->getColumns(); std::vector > aNewColumns( comphelper::sequenceToContainer > >(columns)); + sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() ), MAP_APPFONT ).Height(); if(m_xColumnModel->getColumnHeaderHeight() == 0) m_pTableModel->setColumnHeaderHeight(fontHeight); else -- cgit From ee14cea9dcc4fb1ec3ec261b5fca38d45c43ed09 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 21 Apr 2010 15:17:52 +0200 Subject: sw33bf03: #i111035#: fix ODF 1.2 export of href on form:form (patch by fs) --- xmloff/source/forms/elementexport.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index f28eab48e428..93a80ad5133b 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -2036,6 +2036,12 @@ namespace xmloff OAttributeMetaData::getFormAttributeNamespace(eStringPropertyIds[i]), OAttributeMetaData::getFormAttributeName(eStringPropertyIds[i]), aStringPropertyNames[i]); + + // Since as per ODF 1.2, xlink:href and xlink:type need to exist either both or none, + // we need to write xlink:type, too, even if it carries no information. + // #i111035# / 2010-04-141/ frank.schoenheit@sun.com + AddAttributeASCII( XML_NAMESPACE_XLINK, "type", "simple" ); + // now export the data source name or databaselocation or connection resource ::rtl::OUString sPropValue; m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue; -- cgit From 5c737d12c11c1ef5b758e2045098e7037c3b56cc Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 23 Apr 2010 17:41:32 +0200 Subject: gridcontrol_03:bug fix for #i111107#, added update methods to xgriddatamodel --- svtools/inc/svtools/table/abstracttablecontrol.hxx | 2 +- svtools/inc/svtools/table/tabledatawindow.hxx | 2 +- svtools/source/table/gridtablerenderer.cxx | 6 +- svtools/source/table/tablecontrol.cxx | 7 +- svtools/source/table/tablecontrol_impl.cxx | 84 ++++++--- svtools/source/table/tablecontrol_impl.hxx | 4 +- svtools/source/table/tabledatawindow.cxx | 32 +++- svtools/source/uno/svtxgridcontrol.cxx | 195 ++++++++++++++++----- .../source/controls/grid/defaultgriddatamodel.cxx | 41 ++++- .../source/controls/grid/defaultgriddatamodel.hxx | 4 +- toolkit/source/controls/grid/gridcontrol.hxx | 2 - 11 files changed, 288 insertions(+), 91 deletions(-) diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx index ba9bec8e0e2e..2b3951f6aaf3 100644 --- a/svtools/inc/svtools/table/abstracttablecontrol.hxx +++ b/svtools/inc/svtools/table/abstracttablecontrol.hxx @@ -116,7 +116,7 @@ namespace svt { namespace table /** returns selection engine*/ virtual SelectionEngine* getSelEngine() = 0; virtual void setCursorAtCurrentCell(const Point& rPoint) = 0; - virtual void setTooltip(const Point& rPoint ) = 0; + virtual rtl::OUString& setTooltip(const Point& rPoint ) = 0; virtual RowPos getCurrentRow(const Point& rPoint ) = 0; virtual void resizeColumn(const Point& rPoint ) = 0; virtual bool startResizeColumn(const Point& rPoint) = 0; diff --git a/svtools/inc/svtools/table/tabledatawindow.hxx b/svtools/inc/svtools/table/tabledatawindow.hxx index 0e65f9847816..c9f96483d943 100644 --- a/svtools/inc/svtools/table/tabledatawindow.hxx +++ b/svtools/inc/svtools/table/tabledatawindow.hxx @@ -73,7 +73,7 @@ namespace svt { namespace table virtual void SetPointer( const Pointer& rPointer ); virtual void CaptureMouse(); virtual void ReleaseMouse(); - + virtual long Notify(NotifyEvent& rNEvt); }; //........................................................................ } } // namespace svt::table diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 77db8fc30904..a3f954e0bef5 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -122,7 +122,7 @@ namespace svt { namespace table nHorFlag = TEXT_DRAW_RIGHT; Rectangle aRect(_rArea); aRect.Left()+=4; aRect.Right()-=4; - aRect.Top()+=2; aRect.Bottom()-=2; + aRect.Bottom()-=2; _rDevice.DrawText( aRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); _rDevice.Pop(); @@ -208,7 +208,7 @@ namespace svt { namespace table nHorFlag = TEXT_DRAW_RIGHT; Rectangle aRect(_rArea); aRect.Left()+=4; aRect.Right()-=4; - aRect.Top()+=2; aRect.Bottom()-=2; + aRect.Bottom()-=2; _rDevice.DrawText( aRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); // TODO: active? selected? (void)_bActive; @@ -347,7 +347,7 @@ namespace svt { namespace table nHorFlag = TEXT_DRAW_RIGHT; Rectangle textRect(_rArea); textRect.Left()+=4; textRect.Right()-=4; - textRect.Top()+=2; textRect.Bottom()-=2; + textRect.Bottom()-=2; _rDevice.DrawText( textRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); } _rDevice.Pop(); diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 12def82d3ecf..418348c81b7d 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -71,9 +71,10 @@ namespace svt { namespace table ,m_pImpl( new TableControl_Impl( *this ) ) ,m_bSelectionChanged(false) { - m_pImpl->getDataWindow()->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) ); - m_pImpl->getDataWindow()->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) ); - m_pImpl->getDataWindow()->SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) ); + TableDataWindow* aTableData = m_pImpl->getDataWindow(); + aTableData->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) ); + aTableData->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) ); + aTableData->SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) ); m_pAccessTable.reset(new ::svt::table::AccessibleTableControl_Impl()); } diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 4057be745097..37717c5c1833 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -456,8 +455,8 @@ namespace svt { namespace table DELETEZ( m_pVScroll ); DELETEZ( m_pHScroll ); DELETEZ( m_pScrollCorner ); - DELETEZ( m_pTableFunctionSet ); - DELETEZ( m_pSelEngine ); + DELETEZ( m_pTableFunctionSet ); + DELETEZ( m_pSelEngine ); DELETEZ( m_pDataWindow ); } @@ -579,7 +578,9 @@ namespace svt { namespace table m_aColumnWidthsPixel.reserve( colCount ); m_aAccColumnWidthsPixel.reserve( colCount ); + std::vector aPrePixelWidths(0); long accumulatedPixelWidth = 0; + int lastResizableCol = -1; double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width(); if(m_pModel->hasRowHeaders()) { @@ -627,22 +628,26 @@ namespace svt { namespace table colWidth = pColumn->getWidth(); long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); if(bResizable && colPrefWidth == 0) + { colWithoutFixedWidthsSum+=pixelWidth; + lastResizableCol = col; + } colWidthsSum+=pixelWidth; + aPrePixelWidths.push_back(pixelWidth); } - gridWidth = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; + double gridWidthWithoutFixed = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; double scalingFactor = 1.0; if(m_bResizingGrid) { - if(gridWidth > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum)) - scalingFactor = gridWidth/colWithoutFixedWidthsSum; + if(gridWidthWithoutFixed > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum)) + scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; } else { - if(colWidthsSum < gridWidth) + if(colWidthsSum < gridWidthWithoutFixed) { if(colWithoutFixedWidthsSum>0) - scalingFactor = gridWidth/colWithoutFixedWidthsSum; + scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; } } long pixelWidth = 0; @@ -652,16 +657,32 @@ namespace svt { namespace table DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); if ( !pColumn ) continue; - TableMetrics colWidth = pColumn->getWidth(); if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) { - colWidth*=scalingFactor; - //colWidth+=1; - pColumn->setWidth(colWidth); + aPrePixelWidths[i]*=scalingFactor; + TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width(); + pColumn->setWidth(logicColWidth); + } + m_aColumnWidthsPixel.push_back( aPrePixelWidths[i] ); + m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += aPrePixelWidths[i] ); + } + if(gridWidth > m_aAccColumnWidthsPixel[colCount-1]) + { + if(lastResizableCol >= 0) + { + PColumnModel pColumn = m_pModel->getColumnModel(lastResizableCol); + m_aColumnWidthsPixel[lastResizableCol]+=gridWidth-m_aAccColumnWidthsPixel[colCount-1]; + TableMetrics logicColWidth1 = m_rAntiImpl.PixelToLogic( Size( m_aColumnWidthsPixel[lastResizableCol], 0 ), MAP_APPFONT ).Width(); + pColumn->setWidth(logicColWidth1); + while(lastResizableCol < colCount) + { + if(lastResizableCol == 0) + m_aAccColumnWidthsPixel[0] = m_aColumnWidthsPixel[lastResizableCol]; + else + m_aAccColumnWidthsPixel[lastResizableCol]=m_aAccColumnWidthsPixel[lastResizableCol-1]+m_aColumnWidthsPixel[lastResizableCol]; + ++lastResizableCol; + } } - pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - m_aColumnWidthsPixel.push_back( pixelWidth ); - m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += pixelWidth ); } } @@ -1068,7 +1089,6 @@ namespace svt { namespace table ) { bool isSelectedColumn = false; - // Size siz = m_rAntiImpl.GetSizePixel(); ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; ::com::sun::star::uno::Any rCellData = aCellContent[aRowIterator.getRow()][aCell.getColumn()]; if(rCellData>>=xGraphic) @@ -1852,6 +1872,16 @@ namespace svt { namespace table return m_pDataWindow; } //------------------------------------------------------------------------------- + ScrollBar* TableControl_Impl::getHorzScrollbar() + { + return m_pHScroll; + } + //------------------------------------------------------------------------------- + ScrollBar* TableControl_Impl::getVertScrollbar() + { + return m_pVScroll; + } + //------------------------------------------------------------------------------- BOOL TableControl_Impl::isRowSelected(const ::std::vector& selectedRows, RowPos current) { return ::std::find(selectedRows.begin(),selectedRows.end(),current) != selectedRows.end(); @@ -1872,13 +1902,18 @@ namespace svt { namespace table return -1; } //------------------------------------------------------------------------------- - void TableControl_Impl::setTooltip(const Point& rPoint ) + ::rtl::OUString& TableControl_Impl::setTooltip(const Point& rPoint ) { - ::rtl::OUString aTooltipText; + ::rtl::OUString& aTooltipText(::rtl::OUString::createFromAscii("")); RowPos current = getCurrentRow(rPoint); com::sun::star::uno::Sequence< sal_Int32 > cols = m_rAntiImpl.getColumnsForTooltip(); com::sun::star::uno::Sequence< ::rtl::OUString > text = m_rAntiImpl.getTextForTooltip(); - if(text.getLength() == 0) + if(text.getLength()==0 && cols.getLength()==0) + { + ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][m_nCurColumn]; + aTooltipText = convertToString(content); + } + else if(text.getLength() == 0) { for(int i=0; igetRowHeaderWidth(), 0 ), MAP_APPFONT ).Width(); int resizingColumn=m_nCurColumn-m_nLeftColumn; PColumnModel pColumn = m_pModel->getColumnModel(m_nCurColumn); - sal_Int32 colWidth = pColumn->getWidth(); impl_ni_getAccVisibleColWidths(); - int newColWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + int newColWidth = m_aColumnWidthsPixel[m_nCurColumn]; //subtract 1 from m_aAccColumnWidthPixel because right border should be part of the current cell if(m_aVisibleColumnWidthsPixel[resizingColumn]-1 == rPoint.X() && pColumn->isResizable()) aNewPointer = Pointer( POINTER_HSPLIT ); @@ -2059,9 +2093,9 @@ namespace svt { namespace table int col = m_nLeftColumn; while(nVisCols) { - PColumnModel pColumn = m_pModel->getColumnModel(col); - pixelWidth = m_rAntiImpl.LogicToPixel( Size( pColumn->getWidth(), 0 ), MAP_APPFONT ).Width(); - m_aVisibleColumnWidthsPixel.push_back(widthsPixel+=pixelWidth); + // PColumnModel pColumn = m_pModel->getColumnModel(col); + // pixelWidth = m_rAntiImpl.LogicToPixel( Size( pColumn->getWidth(), 0 ), MAP_APPFONT ).Width(); + m_aVisibleColumnWidthsPixel.push_back(widthsPixel+=m_aColumnWidthsPixel[col]); col++; nVisCols--; } diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index da4108e3af09..6e009ffd6fd9 100644 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -208,12 +208,14 @@ namespace svt { namespace table virtual void showCursor(); virtual bool dispatchAction( TableControlAction _eAction ); virtual SelectionEngine* getSelEngine(); - virtual void setTooltip(const Point& rPoint ); + virtual rtl::OUString& setTooltip(const Point& rPoint ); virtual void resizeColumn(const Point& rPoint); virtual bool startResizeColumn(const Point& rPoint); virtual bool endResizeColumn(const Point& rPoint); TableDataWindow* getDataWindow(); + ScrollBar* getHorzScrollbar(); + ScrollBar* getVertScrollbar(); ::rtl::OUString convertToString(const ::com::sun::star::uno::Any& _value); Rectangle calcHeaderRect(bool bColHeader); diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index e602f0418cfe..e307071e2699 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -30,6 +30,7 @@ #include "svtools/table/tablecontrol.hxx" #include "svtools/table/tabledatawindow.hxx" #include "tablecontrol_impl.hxx" +#include //........................................................................ namespace svt { namespace table @@ -59,18 +60,25 @@ namespace svt { namespace table Point aPoint = rMEvt.GetPosPixel(); if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) ) { - if(m_rTableControl.getCurrentRow(aPoint)>=0 && - (!m_rTableControl.getAntiImpl().getColumnsForTooltip().getLength()==0 || !m_rTableControl.getAntiImpl().getTextForTooltip().getLength()==0)) + if(m_rTableControl.getCurrentRow(aPoint)>=0 ) { - m_rTableControl.setTooltip(aPoint); SetPointer(POINTER_ARROW); + rtl::OUString& rHelpText = m_rTableControl.setTooltip(aPoint); + Help::EnableBalloonHelp(); + Window::SetHelpText( rHelpText.getStr()); } else if(m_rTableControl.getCurrentRow(aPoint) == -1) { + if(Help::IsBalloonHelpEnabled()) + Help::DisableBalloonHelp(); m_rTableControl.resizeColumn(aPoint); } else + { + if(Help::IsBalloonHelpEnabled()) + Help::DisableBalloonHelp(); Window::MouseMove( rMEvt ); + } } } //-------------------------------------------------------------------- @@ -121,6 +129,24 @@ namespace svt { namespace table { Window::ReleaseMouse(); } + // ----------------------------------------------------------------------- + long TableDataWindow::Notify(NotifyEvent& rNEvt ) + { + long nDone = 0; + if ( rNEvt.GetType() == EVENT_COMMAND ) + { + const CommandEvent& rCEvt = *rNEvt.GetCommandEvent(); + if ( rCEvt.GetCommand() == COMMAND_WHEEL ) + { + const CommandWheelData* pData = rCEvt.GetWheelData(); + if( !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) ) + { + nDone = HandleScrollCommand( rCEvt, m_rTableControl.getHorzScrollbar(), m_rTableControl.getVertScrollbar() ); + } + } + } + return nDone ? nDone : Window::Notify( rNEvt ); + } //........................................................................ } } // namespace svt::table //........................................................................ diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index f29273b1ec65..b411181c2aab 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -271,8 +271,9 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } m_xColumnModel->setDefaultColumns(rawRowData.getLength()); } - if((unsigned int)rawRowData.getLength()!=(unsigned)m_pTableModel->getColumnCount()) - throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel); + else + if((unsigned int)rawRowData.getLength()!=(unsigned)m_pTableModel->getColumnCount()) + throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel); for ( int k = 0; k < rawRowData.getLength(); k++) { @@ -290,9 +291,12 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } else throw GridInvalidDataException(rtl::OUString::createFromAscii("The data model isn't set!"), m_xDataModel); - sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() ), MAP_APPFONT ).Height(); + sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height(); if(m_xDataModel->getRowHeight() == 0) + { m_pTableModel->setRowHeight(fontHeight); + m_xDataModel->setRowHeight(fontHeight); + } else m_pTableModel->setRowHeight(m_xDataModel->getRowHeight()); m_pTableModel->setRowHeaderWidth(m_xDataModel->getRowHeaderWidth()); @@ -309,18 +313,28 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An Sequence > columns = m_xColumnModel->getColumns(); std::vector > aNewColumns( comphelper::sequenceToContainer > >(columns)); - sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() ), MAP_APPFONT ).Height(); + sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height(); if(m_xColumnModel->getColumnHeaderHeight() == 0) + { m_pTableModel->setColumnHeaderHeight(fontHeight); + m_xColumnModel->setColumnHeaderHeight(fontHeight); + } else m_pTableModel->setColumnHeaderHeight(m_xColumnModel->getColumnHeaderHeight()); for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) { UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]); + Reference< XGridColumn > xGridColumn = m_xColumnModel->getColumn(col); m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); - m_pTableModel->getColumnModel()[col]->setHorizontalAlign(m_xColumnModel->getColumn(col)->getHorizontalAlign()); - m_pTableModel->getColumnModel()[col]->setWidth(m_xColumnModel->getColumn(col)->getColumnWidth()); - m_pTableModel->getColumnModel()[col]->setResizable(m_xColumnModel->getColumn(col)->getResizeable()); + tableColumn->setHorizontalAlign(xGridColumn->getHorizontalAlign()); + tableColumn->setWidth(xGridColumn->getColumnWidth()); + if(xGridColumn->getPreferredWidth() != 0) + tableColumn->setPreferredWidth(xGridColumn->getPreferredWidth()); + if(xGridColumn->getMaxWidth() != 0) + tableColumn->setMaxWidth(xGridColumn->getMaxWidth()); + if(xGridColumn->getMinWidth() != 0) + tableColumn->setMinWidth(xGridColumn->getMinWidth()); + tableColumn->setResizable(xGridColumn->getResizeable()); } } } @@ -544,7 +558,53 @@ void SAL_CALL SVTXGridControl::columnChanged(const ::com::sun::star::awt::grid: } void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { - (void) Event; + TableControl* pTable = (TableControl*)GetWindow(); + if(Event.valueName == rtl::OUString::createFromAscii("RowHeight")) + { + sal_Int32 rowHeight = m_pTableModel->getRowHeight(); + Event.newValue>>=rowHeight; + m_pTableModel->setRowHeight(rowHeight); + pTable->Invalidate(); + } + else if(Event.valueName == rtl::OUString::createFromAscii("RowHeaderWidth")) + { + sal_Int32 rowHeaderWidth = m_pTableModel->getRowHeaderWidth(); + Event.newValue>>=rowHeaderWidth; + m_pTableModel->setRowHeaderWidth(rowHeaderWidth); + pTable->Invalidate(); + } + else if(Event.valueName == rtl::OUString::createFromAscii("RowHeaders")) + { + Sequence< rtl::OUString > headers(0); + Event.newValue>>=headers; + std::vector< rtl::OUString > headerNames( comphelper::sequenceToContainer >(headers) ); + m_pTableModel->setRowHeaderName(headerNames); + pTable->Invalidate(); + } + else if(Event.valueName == rtl::OUString::createFromAscii("CellUpdated")) + { + std::vector< std::vector< Any > >& rowContent = m_pTableModel->getCellContent(); + sal_Int32 col = -1; + Event.oldValue>>=col; + rowContent[Event.index][col] = Event.newValue; + pTable->InvalidateDataWindow(Event.index, Event.index, false); + } + else if(Event.valueName == rtl::OUString::createFromAscii("RowUpdated")) + { + std::vector >& rowContent = m_pTableModel->getCellContent(); + Sequence< sal_Int32 > cols(0); + Sequence< Any > values(0); + Event.oldValue>>=cols; + Event.newValue>>=values; + for(int i = 0; i< cols.getLength(); i++) + { + if(cols[i]>=0 && cols[i]getColumnCount()) + rowContent[Event.index][cols[i]]=values[i]; + else + break; + } + pTable->InvalidateDataWindow(Event.index, Event.index, false); + } } void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) @@ -583,34 +643,54 @@ void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObj void SAL_CALL SVTXGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) { TableControl* pTable = (TableControl*)GetWindow(); - std::vector& selectedRows = pTable->GetSelectedRows(); - if(!selectedRows.empty()) - selectedRows.clear(); - sal_Int32 start = rangeOfRows[0]; - int seqSize = rangeOfRows.getLength(); - sal_Int32 end = rangeOfRows[seqSize-1]; - for(int i=0;iselectionChanged(true); - pTable->InvalidateDataWindow(start, end, false); - SetSynthesizingVCLEvent( sal_True ); - pTable->Select(); - SetSynthesizingVCLEvent( sal_False ); - + SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); + if(eSelMode != NO_SELECTION) + { + sal_Int32 start = rangeOfRows[0]; + int seqSize = rangeOfRows.getLength(); + sal_Int32 end = rangeOfRows[seqSize-1]; + if((start >= 0 && start < m_pTableModel->getRowCount()) && (end >= 0 && end < m_pTableModel->getRowCount())) + { + std::vector& selectedRows = pTable->GetSelectedRows(); + if(!selectedRows.empty()) + selectedRows.clear(); + if(eSelMode == SINGLE_SELECTION) + { + if(rangeOfRows.getLength() == 1) + selectedRows.push_back(start); + else + return; + } + else + { + for(int i=0;iselectionChanged(true); + pTable->InvalidateDataWindow(start, end, false); + SetSynthesizingVCLEvent( sal_True ); + pTable->Select(); + SetSynthesizingVCLEvent( sal_False ); + } + } } void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException) { TableControl* pTable = (TableControl*)GetWindow(); - std::vector& selectedRows = pTable->GetSelectedRows(); - if(!selectedRows.empty()) - selectedRows.clear(); - for(int i=0;igetRowCount();i++) - selectedRows.push_back(i); - pTable->Invalidate(); - SetSynthesizingVCLEvent( sal_True ); - pTable->Select(); - SetSynthesizingVCLEvent( sal_False ); + SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); + if(eSelMode != NO_SELECTION) + { + std::vector& selectedRows = pTable->GetSelectedRows(); + if(!selectedRows.empty()) + selectedRows.clear(); + for(int i=0;igetRowCount();i++) + selectedRows.push_back(i); + pTable->Invalidate(); + SetSynthesizingVCLEvent( sal_True ); + pTable->Select(); + SetSynthesizingVCLEvent( sal_False ); + } } void SAL_CALL SVTXGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) { @@ -620,13 +700,16 @@ void SAL_CALL SVTXGridControl::deselectRows(const ::com::sun::star::uno::Sequenc std::vector::iterator itEnd = selectedRows.end(); sal_Int32 start = rangeOfRows[0]; sal_Int32 end = rangeOfRows[rangeOfRows.getLength()-1]; - std::vector::iterator iter = std::find(itStart, itEnd, start); - selectedRows.erase(iter, iter+(end-start)+1); - pTable->selectionChanged(true); - pTable->InvalidateDataWindow(start, end, false); - SetSynthesizingVCLEvent( sal_True ); - pTable->Select(); - SetSynthesizingVCLEvent( sal_False ); + if((start >= 0 && start < m_pTableModel->getRowCount()) && (end >= 0 && end < m_pTableModel->getRowCount())) + { + std::vector::iterator iter = std::find(itStart, itEnd, start); + selectedRows.erase(iter, iter+(end-start)+1); + pTable->selectionChanged(true); + pTable->InvalidateDataWindow(start, end, false); + SetSynthesizingVCLEvent( sal_True ); + pTable->Select(); + SetSynthesizingVCLEvent( sal_False ); + } } void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException) @@ -676,14 +759,34 @@ void SAL_CALL SVTXGridControl::selectRow(::sal_Int32 index) throw (::com::sun::s if(index<0 || index>=m_pTableModel->getRowCount()) return; TableControl* pTable = (TableControl*)GetWindow(); - std::vector& selectedRows = pTable->GetSelectedRows(); - if(!isSelectedIndex(index)) - selectedRows.push_back(index); - pTable->selectionChanged(true); - pTable->InvalidateDataWindow(index, index, false); - SetSynthesizingVCLEvent( sal_True ); - pTable->Select(); - SetSynthesizingVCLEvent( sal_False ); + SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); + if(eSelMode != NO_SELECTION) + { + std::vector& selectedRows = pTable->GetSelectedRows(); + if(eSelMode == MULTIPLE_SELECTION) + { + if(!isSelectedIndex(index)) + selectedRows.push_back(index); + else + return; + } + else if(eSelMode == SINGLE_SELECTION) + { + if(!selectedRows.empty()) + { + if(!isSelectedIndex(index)) + deselectRows(getSelection()); + else + return; + } + selectedRows.push_back(index); + } + pTable->selectionChanged(true); + pTable->InvalidateDataWindow(index, index, false); + SetSynthesizingVCLEvent( sal_True ); + pTable->Select(); + SetSynthesizingVCLEvent( sal_False ); + } } void SAL_CALL SVTXGridControl::selectColumn(::sal_Int32 x) throw (::com::sun::star::uno::RuntimeException) diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 38e3ec694b96..7ffafdf0ddb6 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -41,6 +41,9 @@ using namespace ::com::sun::star::lang; #define ROWHEIGHT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeight" )) #define ROWHEADERS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaders" )) +#define CELLUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellUpdated" )) +#define ROWUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowUpdated" )) +#define ROWHEADERWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaderWidth" )) namespace toolkit { @@ -83,11 +86,10 @@ void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& //--------------------------------------------------------------------- -void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue ) throw (::com::sun::star::uno::RuntimeException) +void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, sal_Int32 index, Any oldValue, Any newValue) throw (::com::sun::star::uno::RuntimeException) { Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, name, oldValue, newValue, 0, ::rtl::OUString(), - Sequence< Any >() ); + GridDataEvent aEvent( xSource, name, oldValue, newValue, index, ::rtl::OUString(), Sequence< Any >()); broadcast( data_changed, aEvent); } @@ -128,7 +130,7 @@ void SAL_CALL DefaultGridDataModel::setRowHeight(::sal_Int32 value) throw (::com sal_Int32 oldValue = rowHeight; rowHeight = value; - broadcast_changed( ROWHEIGHT, Any(oldValue), Any(value) ); + broadcast_changed( ROWHEIGHT, 0, Any(oldValue), Any(value)); } //--------------------------------------------------------------------- @@ -164,7 +166,7 @@ void SAL_CALL DefaultGridDataModel::setRowHeaders(const ::com::sun::star::uno::S i++; } - broadcast_changed( ROWHEADERS, Any(oldValue), Any(comphelper::containerToSequence(rowHeaders)) ); + broadcast_changed( ROWHEADERS, 0, Any(oldValue), Any(comphelper::containerToSequence(rowHeaders)) ); } //--------------------------------------------------------------------- @@ -244,7 +246,9 @@ void SAL_CALL DefaultGridDataModel::removeAll() throw (RuntimeException) //--------------------------------------------------------------------- void SAL_CALL DefaultGridDataModel::setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) { + sal_Int32 oldValue = m_nRowHeaderWidth; m_nRowHeaderWidth = _value; + broadcast_changed( ROWHEADERWIDTH, 0, Any(oldValue), Any(_value) ); } //--------------------------------------------------------------------- sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException) @@ -252,6 +256,33 @@ sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeaderWidth() throw (::com::sun:: return m_nRowHeaderWidth; } //--------------------------------------------------------------------- +void SAL_CALL DefaultGridDataModel::updateCell(::sal_Int32 row, ::sal_Int32 column, const Any& value) throw (::com::sun::star::uno::RuntimeException) +{ + if(row >= 0 && row < (signed)data.size()) + { + if(column >= 0 && column < (signed)data[0].size()) + { + data[row][column] = value; + Sequence< Any >dataSeq(comphelper::containerToSequence(data[row])); + broadcast_changed( CELLUPDATED, row, Any(column), value ); + } + } +} +//--------------------------------------------------------------------- +void SAL_CALL DefaultGridDataModel::updateRow(::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 > & columns, const ::com::sun::star::uno::Sequence< Any > & values) throw (::com::sun::star::uno::RuntimeException) +{ + if(row >= 0 && row < (signed)data.size()) + { + if(columns.getLength() == values.getLength()) + { + for(int i = 0; i < columns.getLength(); i++) + data[row][i] = values[i]; + Sequence< Any >dataSeq(comphelper::containerToSequence(data[row])); + broadcast_changed( ROWUPDATED, row, Any(columns), Any(values) ); + } + } +} +//--------------------------------------------------------------------- // XComponent //--------------------------------------------------------------------- diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index 3c10a3e3cd73..ea11a8a9a00a 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -73,6 +73,8 @@ public: virtual void SAL_CALL removeAll() throw (RuntimeException); virtual void SAL_CALL setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCell( ::sal_Int32 row, ::sal_Int32 column, const ::com::sun::star::uno::Any& value ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRow( ::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& values ) throw (::com::sun::star::uno::RuntimeException); // XComponent virtual void SAL_CALL dispose( ) throw (RuntimeException); virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); @@ -86,7 +88,7 @@ public: private: void broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); - void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue ) throw (::com::sun::star::uno::RuntimeException); + void broadcast_changed( ::rtl::OUString name, sal_Int32 index, Any oldValue, Any newValue ) throw (::com::sun::star::uno::RuntimeException); void broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); void broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index e0f503a10aa9..0c8ddb1c02b6 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -91,8 +91,6 @@ public: virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException); - //virtual void SAL_CALL addMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException); - //virtual void SAL_CALL removeMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridSelection -- cgit From 69d62202d7bb82f9a5a60079bc64eacd1b2272f3 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 23 Apr 2010 17:41:32 +0200 Subject: gridcontrol_03:bug fix for #i111107#, added update methods to xgriddatamodel --- offapi/com/sun/star/awt/grid/XGridDataModel.idl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/offapi/com/sun/star/awt/grid/XGridDataModel.idl b/offapi/com/sun/star/awt/grid/XGridDataModel.idl index c2ce53c8931e..5cc4085807e1 100644 --- a/offapi/com/sun/star/awt/grid/XGridDataModel.idl +++ b/offapi/com/sun/star/awt/grid/XGridDataModel.idl @@ -89,6 +89,26 @@ interface XGridDataModel: ::com::sun::star::lang::XComponent */ void removeAll(); + /**Updates the content of a given cell. + @param row + the row index + @param column + the column index + @param value + the new value of the cell. + */ + void updateCell([in] long row, [in] long column, [in] any value ); + + /**Updates the content of a given row. + @param row + the row index + @param columns + column indexes of the cells, which should be updated + @param value + the new values of the cells. + */ + void updateRow([in] long row, [in] sequence< long > columns, [in] sequence< any > values); + //------------------------------------------------------------------------- /** Adds a listener for the GridDataEvent posted after the grid changes. -- cgit From e9345d741859149df169907cea1aeec99e1b8e22 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 26 Apr 2010 12:34:39 +0200 Subject: sw33bf03: #i110523#: work around raptor messing up libxslt (patch by cmc) --- unoxml/source/rdf/librdf_repository.cxx | 9 +++++++++ unoxml/source/rdf/makefile.mk | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/unoxml/source/rdf/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx index c42887a9cf9f..62caff524010 100644 --- a/unoxml/source/rdf/librdf_repository.cxx +++ b/unoxml/source/rdf/librdf_repository.cxx @@ -55,6 +55,7 @@ #include #include +#include #include #include @@ -1890,7 +1891,15 @@ librdf_world *librdf_TypeConverter::createWorld() const m_rRep); } //FIXME logger, digest, features? + xsltSecurityPrefsPtr origprefs = xsltGetDefaultSecurityPrefs(); librdf_world_open(pWorld); + xsltSecurityPrefsPtr newprefs = xsltGetDefaultSecurityPrefs(); + if (newprefs != origprefs) { + // #i110523# restore libxslt global configuration + // (gratuitously overwritten by raptor_init_parser_grddl_common) + // (this is the only reason unordf is linked against libxslt) + xsltSetDefaultSecurityPrefs(origprefs); + } return pWorld; } diff --git a/unoxml/source/rdf/makefile.mk b/unoxml/source/rdf/makefile.mk index 298c1dcdae25..b8593e52da46 100644 --- a/unoxml/source/rdf/makefile.mk +++ b/unoxml/source/rdf/makefile.mk @@ -45,6 +45,13 @@ ENABLE_EXCEPTIONS=TRUE CFLAGS+=-DSYSTEM_REDLAND $(REDLAND_CFLAGS) .ENDIF +.IF "$(SYSTEM_LIBXSLT)" == "YES" +CFLAGS+= $(LIBXSLT_CFLAGS) +.ELSE +LIBXSLTINCDIR=external$/libxslt +CFLAGS+= -I$(SOLARINCDIR)$/$(LIBXSLTINCDIR) +.ENDIF + # --- Files -------------------------------------------------------- .IF "$(L10N_framework)"=="" @@ -68,6 +75,7 @@ DEF1NAME=$(SHL1TARGET) SHL1STDLIBS= \ $(REDLANDLIB) \ + $(XSLTLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ $(SALLIB) \ -- cgit From 1d30ea43d0fd1353da7d4fb591dcbc1688bc07d8 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 26 Apr 2010 11:55:58 +0100 Subject: ab75: #i110417# add licence, remove unnecessary lines in resource and correct tweak in stepERROR so that in non-vba mode all is as it was before --- basic/source/classes/errobject.cxx | 27 +++++++++++++++++++++++++++ basic/source/classes/sb.src | 2 -- basic/source/inc/errobject.hxx | 27 +++++++++++++++++++++++++++ basic/source/runtime/step0.cxx | 5 ++++- 4 files changed, 58 insertions(+), 3 deletions(-) diff --git a/basic/source/classes/errobject.cxx b/basic/source/classes/errobject.cxx index c34fa0a49aec..406d6f9b1a0b 100644 --- a/basic/source/classes/errobject.cxx +++ b/basic/source/classes/errobject.cxx @@ -1,3 +1,30 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* +* for a copy of the LGPLv3 License. +* +************************************************************************/ + // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" #include "errobject.hxx" diff --git a/basic/source/classes/sb.src b/basic/source/classes/sb.src index 4e0eacf10d2f..73cc1c3a0b2c 100644 --- a/basic/source/classes/sb.src +++ b/basic/source/classes/sb.src @@ -590,9 +590,7 @@ Resource RID_BASIC_START }; String ERRCODE_BASIC_COMPAT & ERRCODE_RES_MASK { - Text [ de ] = "$(ARG1)" ; Text [ en-US ] = "$(ARG1)" ; - Text [ x-comment ] = " "; }; }; // Hinweis: IDS_SBERR_TERMINATED = IDS_SBERR_START+2000. diff --git a/basic/source/inc/errobject.hxx b/basic/source/inc/errobject.hxx index 51d4b6caa4f9..7a50d2435eb3 100644 --- a/basic/source/inc/errobject.hxx +++ b/basic/source/inc/errobject.hxx @@ -1,3 +1,30 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* +* for a copy of the LGPLv3 License. +* +************************************************************************/ + #ifndef ERROBJECT_HXX #define ERROBJECT_HXX #include "sbunoobj.hxx" diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index b432d1851ed5..39af5ea4adc3 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -1271,6 +1271,9 @@ void SbiRuntime::StepERROR() SbxVariableRef refCode = PopVar(); USHORT n = refCode->GetUShort(); SbError error = StarBASIC::GetSfxFromVBError( n ); - pInst->Error( error ); + if ( bVBAEnabled ) + pInst->Error( error ); + else + Error( error ); } -- cgit From cff39a2614347c6db8ae1a214947d90a3ea57000 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Mon, 26 Apr 2010 13:09:41 +0100 Subject: npower13_objectmodules: #i111097# fix for reset of vba mode for modules --- basic/source/classes/sbxmod.cxx | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 93705d05460e..83c0ae9e65f4 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -55,7 +55,10 @@ #include #include #include +#include +#include +using namespace com::sun::star; // for the bsearch #ifdef WNT @@ -98,6 +101,26 @@ SV_IMPL_VARARR(SbiBreakpoints,USHORT) SV_IMPL_VARARR(HighlightPortions, HighlightPortion) +bool getDefaultVBAMode( StarBASIC* pb ) +{ + bool bResult = false; + if ( pb && pb->IsDocBasic() ) + { + uno::Any aDoc; + if ( pb->GetUNOConstant( "ThisComponent", aDoc ) ) + { + uno::Reference< beans::XPropertySet > xProp( aDoc, uno::UNO_QUERY ); + if ( xProp.is() ) + { + uno::Reference< script::XVBACompat > xVBAMode( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY ); + if ( xVBAMode.is() ) + bResult = ( xVBAMode->getVBACompatModeOn() == sal_True ); + } + } + } + return bResult; +} + class AsyncQuitHandler { AsyncQuitHandler() {} @@ -443,10 +466,11 @@ void SbModule::SetSource( const String& r ) void SbModule::SetSource32( const ::rtl::OUString& r ) { + // Default basic mode to library container mode, but.. allow Option VBASupport 0/1 override + SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) ); aOUSource = r; StartDefinitions(); SbiTokenizer aTok( r ); - aTok.SetCompatible( IsVBACompat() ); while( !aTok.IsEof() ) { SbiToken eEndTok = NIL; @@ -471,6 +495,18 @@ void SbModule::SetSource32( const ::rtl::OUString& r ) { eEndTok = ENDPROPERTY; break; } + if( eCurTok == OPTION ) + { + eCurTok = aTok.Next(); + if( eCurTok == COMPATIBLE ) + aTok.SetCompatible( true ); + else if ( ( eCurTok == VBASUPPORT ) && ( aTok.Next() == NUMBER ) ) + { + BOOL bIsVBA = ( aTok.GetDbl()== 1 ); + SetVBACompat( bIsVBA ); + aTok.SetCompatible( bIsVBA ); + } + } } eLastTok = eCurTok; } -- cgit From caa1ed58b354fa289d4801d716b63c64f3bc495e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 26 Apr 2010 18:22:31 +0200 Subject: sw33bf03: #i108345#: SwpHintsArray::Check(): check for overlapping AUTOFMT --- sw/source/core/txtnode/ndhints.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx index ef165b010aea..ee05b1fe2180 100644 --- a/sw/source/core/txtnode/ndhints.cxx +++ b/sw/source/core/txtnode/ndhints.cxx @@ -372,7 +372,7 @@ bool SwpHintsArray::Check() const CHECK_ERR( !isCHRATR(nWhich), "HintsCheck: Character attribute in end array" ); - // 8) portion check + // 8) style portion check #if OSL_DEBUG_LEVEL > 1 const SwTxtAttr* pHtThis = m_HintStarts[i]; const SwTxtAttr* pHtLast = i > 0 ? m_HintStarts[i-1] : 0; @@ -380,11 +380,19 @@ bool SwpHintsArray::Check() const ( RES_TXTATR_CHARFMT != pHtLast->Which() && RES_TXTATR_AUTOFMT != pHtLast->Which() ) || ( RES_TXTATR_CHARFMT != pHtThis->Which() && RES_TXTATR_AUTOFMT != pHtThis->Which() ) || ( *pHtThis->GetStart() >= *pHtLast->GetEnd() ) || - ( *pHtThis->GetStart() == *pHtLast->GetStart() && *pHtThis->GetEnd() == *pHtLast->GetEnd() ) || - ( *pHtThis->GetStart() == *pHtThis->GetEnd() ), + ( ( ( (*pHtThis->GetStart() == *pHtLast->GetStart()) + && (*pHtThis->GetEnd() == *pHtLast->GetEnd()) + ) // same range + || (*pHtThis->GetStart() == *pHtThis->GetEnd()) + ) + && ( (pHtThis->Which() != RES_TXTATR_AUTOFMT) + || (pHtLast->Which() != RES_TXTATR_AUTOFMT) + ) // never two AUTOFMT on same range + ), "HintsCheck: Portion inconsistency. " "This can be temporarily ok during undo operations" ); + // 9) nesting portion check if (pHtThis->IsNesting()) { for ( USHORT j = 0; j < Count(); ++j ) @@ -402,7 +410,7 @@ bool SwpHintsArray::Check() const } } - // 9) dummy char check (unfortunately cannot check SwTxtNode::m_Text) + // 10) dummy char check (unfortunately cannot check SwTxtNode::m_Text) if (pHtThis->HasDummyChar()) { for ( USHORT j = 0; j < i; ++j ) -- cgit From 7ff8a504cfd11fc28e9e7b8ecd54509e16b19727 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 26 Apr 2010 18:25:01 +0200 Subject: sw33bf03: #i108345# SwTxtNode::FmtToTxtAttr(): apply patch by dtardon: create automatic char. styles correctly --- sw/inc/ndtxt.hxx | 2 + sw/source/core/txtnode/thints.cxx | 301 +++++++++++++++++++++++++++++--------- 2 files changed, 235 insertions(+), 68 deletions(-) diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 04f1fad3e660..513695313bc6 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -202,6 +202,8 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable inline void TryDeleteSwpHints(); + SW_DLLPRIVATE void impl_FmtToTxtAttr(const SfxItemSet& i_rAttrSet); + public: bool IsWordCountDirty() const; bool IsWrongDirty() const; diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 730e61c96c85..16b74a8a54e4 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -2063,25 +2063,202 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, return rSet.Count() ? TRUE : FALSE; } -int lcl_IsNewAttrInSet( const SwpHints& rHints, const SfxPoolItem& rItem, - const xub_StrLen nEnd ) + +namespace +{ + +typedef std::pair AttrSpan_t; +typedef std::multimap AttrSpanMap_t; + + +struct IsAutoStyle { - int bIns = TRUE; - for( USHORT i = 0; i < rHints.Count(); ++i ) + bool + operator()(const AttrSpanMap_t::value_type& i_rAttrSpan) + const { - const SwTxtAttr *pOther = rHints[ i ]; - if( *pOther->GetStart() ) - break; + return i_rAttrSpan.second && i_rAttrSpan.second->Which() == RES_TXTATR_AUTOFMT; + } +}; + + +/** Removes from io_rAttrSet all items that are set by style on the + given span. + */ +struct RemovePresentAttrs +{ + RemovePresentAttrs(SfxItemSet& io_rAttrSet) + : m_rAttrSet(io_rAttrSet) + { + } + + void + operator()(const AttrSpanMap_t::value_type& i_rAttrSpan) + const + { + if (!i_rAttrSpan.second) + { + return; + } - if( pOther->GetEnd() && - *pOther->GetEnd() == nEnd && - ( pOther->IsCharFmtAttr() || pOther->Which() == rItem.Which() ) ) + const SwTxtAttr* const pAutoStyle(i_rAttrSpan.second); + SfxItemIter aIter(m_rAttrSet); + const SfxPoolItem* pItem(aIter.GetCurItem()); + while (true) + { + const USHORT nWhich(pItem->Which()); + if (CharFmt::IsItemIncluded(nWhich, pAutoStyle)) + { + m_rAttrSet.ClearItem(nWhich); + } + + if (aIter.IsAtEnd()) + { + break; + } + pItem = aIter.NextItem(); + } + } + +private: + SfxItemSet& m_rAttrSet; +}; + + +/** Collects all style-covered spans from i_rHints to o_rSpanMap. In + addition inserts dummy spans with pointer to format equal to 0 for + all gaps (i.e. spans not covered by any style). This simplifies + creation of autostyles for all needed spans, but it means all code + that tries to access the pointer has to check if it's non-null! + */ +void +lcl_CollectHintSpans(const SwpHints& i_rHints, const USHORT nLength, + AttrSpanMap_t& o_rSpanMap) +{ + USHORT nLastEnd(0); + + for (USHORT i(0); i != i_rHints.Count(); ++i) + { + const SwTxtAttr* const pHint(i_rHints[i]); + const USHORT nWhich(pHint->Which()); + if (nWhich == RES_TXTATR_CHARFMT || nWhich == RES_TXTATR_AUTOFMT) + { + const AttrSpan_t aSpan(*pHint->GetStart(), *pHint->GetEnd()); + o_rSpanMap.insert(AttrSpanMap_t::value_type(aSpan, pHint)); + + if (aSpan.first != nLastEnd) + { + // insert dummy span covering the gap + o_rSpanMap.insert(AttrSpanMap_t::value_type( + AttrSpan_t(nLastEnd, aSpan.first), 0)); + } + + nLastEnd = aSpan.second; + } + } + + // no hints at the end (special case: no hints at all in i_rHints) + if (nLastEnd != nLength && nLength != 0) + { + o_rSpanMap.insert( + AttrSpanMap_t::value_type(AttrSpan_t(nLastEnd, nLength), 0)); + } +} + + +void +lcl_FillWhichIds(const SfxItemSet& i_rAttrSet, std::vector& o_rClearIds) +{ + o_rClearIds.reserve(i_rAttrSet.Count()); + SfxItemIter aIter(i_rAttrSet); + const SfxPoolItem* pItem(aIter.GetCurItem()); + while (true) + { + o_rClearIds.push_back(pItem->Which()); + + if (aIter.IsAtEnd()) { - bIns = FALSE; break; } + pItem = aIter.NextItem(); + } +} + +struct SfxItemSetClearer +{ + SfxItemSet & m_rItemSet; + SfxItemSetClearer(SfxItemSet & rItemSet) : m_rItemSet(rItemSet) { } + void operator()(USHORT const nWhich) { m_rItemSet.ClearItem(nWhich); } +}; + +} + + +/** Does the hard work of SwTxtNode::FmtToTxtAttr: the real conversion + of items to automatic styles. + */ +void +SwTxtNode::impl_FmtToTxtAttr(const SfxItemSet& i_rAttrSet) +{ + typedef AttrSpanMap_t::iterator AttrSpanMap_iterator_t; + AttrSpanMap_t aAttrSpanMap; + + if (i_rAttrSet.Count() == 0) + { + return; + } + + // 1. Identify all spans in hints' array + + lcl_CollectHintSpans(*m_pSwpHints, m_Text.Len(), aAttrSpanMap); + + // 2. Go through all spans and insert new attrs + + AttrSpanMap_iterator_t aCurRange(aAttrSpanMap.begin()); + const AttrSpanMap_iterator_t aEnd(aAttrSpanMap.end()); + while (aCurRange != aEnd) + { + typedef std::pair + AttrSpanMapRange_t; + AttrSpanMapRange_t aRange(aAttrSpanMap.equal_range(aCurRange->first)); + + // 2a. Collect attributes to insert + + SfxItemSet aCurSet(i_rAttrSet); + std::for_each(aRange.first, aRange.second, RemovePresentAttrs(aCurSet)); + + // 2b. Insert automatic style containing the collected attributes + + if (aCurSet.Count() != 0) + { + AttrSpanMap_iterator_t aAutoStyleIt( + std::find_if(aRange.first, aRange.second, IsAutoStyle())); + if (aAutoStyleIt != aRange.second) + { + // there already is an automatic style on that span: + // create new one and remove the original one + SwTxtAttr* const pAutoStyle(const_cast(aAutoStyleIt->second)); + const boost::shared_ptr pOldStyle( + static_cast( + pAutoStyle->GetAttr()).GetStyleHandle()); + aCurSet.Put(*pOldStyle); + + // remove the old hint + m_pSwpHints->Delete(pAutoStyle); + DestroyAttr(pAutoStyle); + } + m_pSwpHints->Insert( + MakeTxtAttr(*GetDoc(), aCurSet, + aCurRange->first.first, aCurRange->first.second)); + } + + aCurRange = aRange.second; } - return bIns; + + // 3. Clear items from the node + std::vector aClearedIds; + lcl_FillWhichIds(i_rAttrSet, aClearedIds); + ClearItemsFromAttrSet(aClearedIds); } void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) @@ -2094,91 +2271,79 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) if( pNd == this ) { - if( aThisSet.Count() ) - { - SfxItemIter aIter( aThisSet ); - const SfxPoolItem* pItem = aIter.GetCurItem(); - std::vector aClearWhichIds; - - while ( true ) - { - if (lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() )) - { - m_pSwpHints->SwpHintsArray::Insert( - MakeTxtAttr( *GetDoc(), - const_cast(*pItem), - 0, GetTxt().Len() ) ); - aClearWhichIds.push_back( pItem->Which() ); - } - - if( aIter.IsAtEnd() ) - break; - pItem = aIter.NextItem(); - } - - ClearItemsFromAttrSet( aClearWhichIds ); - } + impl_FmtToTxtAttr(aThisSet); } else { + // There are five possible combinations of items from this and + // pNd (pNd is the 'main' node): + // + // case pNd this action + // ---------------------------------------------------- + // 1 - - do nothing + // 2 - a convert item to attr of this + // 3 a - convert item to attr of pNd + // 4 a a clear item in this + // 5 a b convert item to attr of this + SfxItemSet aNdSet( pNd->GetDoc()->GetAttrPool(), aCharFmtSetRange ); if( pNd->HasSwAttrSet() && pNd->GetpSwAttrSet()->Count() ) aNdSet.Put( *pNd->GetpSwAttrSet() ); pNd->GetOrCreateSwpHints(); + std::vector aProcessedIds; + if( aThisSet.Count() ) { SfxItemIter aIter( aThisSet ); - const SfxPoolItem* pItem = aIter.GetCurItem(), *pNdItem; + const SfxPoolItem* pItem = aIter.GetCurItem(), *pNdItem = 0; + SfxItemSet aConvertSet( GetDoc()->GetAttrPool(), aCharFmtSetRange ); std::vector aClearWhichIds; - while( TRUE ) + while( true ) { - if( ( SFX_ITEM_SET != aNdSet.GetItemState( pItem->Which(), FALSE, - &pNdItem ) || *pItem != *pNdItem ) && - lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() ) ) + if( SFX_ITEM_SET == aNdSet.GetItemState( pItem->Which(), FALSE, &pNdItem ) ) { - m_pSwpHints->SwpHintsArray::Insert( MakeTxtAttr( *GetDoc(), - const_cast(*pItem), - 0, GetTxt().Len() ) ); - aClearWhichIds.push_back( pItem->Which() ); + if (*pItem == *pNdItem) // 4 + { + aClearWhichIds.push_back( pItem->Which() ); + } + else // 5 + { + aConvertSet.Put(*pItem); + } + aProcessedIds.push_back(pItem->Which()); + } + else // 2 + { + aConvertSet.Put(*pItem); } - aNdSet.ClearItem( pItem->Which() ); if( aIter.IsAtEnd() ) break; pItem = aIter.NextItem(); } + + // 4/ clear items of this that are set with the same value on pNd ClearItemsFromAttrSet( aClearWhichIds ); + + // 2, 5/ convert all other items to attrs + impl_FmtToTxtAttr(aConvertSet); } - if( aNdSet.Count() ) { - SfxItemIter aIter( aNdSet ); - const SfxPoolItem* pItem = aIter.GetCurItem(); - std::vector aClearWhichIds; + std::for_each(aProcessedIds.begin(), aProcessedIds.end(), + SfxItemSetClearer(aNdSet)); - while ( true ) - { - if ( lcl_IsNewAttrInSet( *pNd->m_pSwpHints, *pItem, - pNd->GetTxt().Len() ) ) - { - pNd->m_pSwpHints->SwpHintsArray::Insert( - MakeTxtAttr( *pNd->GetDoc(), - const_cast(*pItem), - 0, pNd->GetTxt().Len() ) ); - } - aClearWhichIds.push_back( pItem->Which() ); + // 3/ convert items to attrs + pNd->impl_FmtToTxtAttr(aNdSet); - if( aIter.IsAtEnd() ) - break; - pItem = aIter.NextItem(); + if( aNdSet.Count() ) + { + SwFmtChg aTmp1( pNd->GetFmtColl() ); + pNd->SwModify::Modify( &aTmp1, &aTmp1 ); } - - pNd->ClearItemsFromAttrSet( aClearWhichIds ); - SwFmtChg aTmp1( pNd->GetFmtColl() ); - pNd->SwModify::Modify( &aTmp1, &aTmp1 ); } } -- cgit From 5809451d5f0689d77302640083145a3071a4c5b2 Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Tue, 27 Apr 2010 09:01:23 +0200 Subject: npower13_objectmodules: #i111175 - Blind fix for changed nodecount and -position as well as enhanced string matching. --- .../framework/optional/f_basic_vba-compat.bas | 1 + .../includes/basic_vba-compat_import_disabled.inc | 30 ++++++----- .../includes/basic_vba-compat_import_enabled.inc | 63 ++++++++++------------ .../includes/basic_vba-compat_import_nothing.inc | 31 +++++++---- 4 files changed, 68 insertions(+), 57 deletions(-) diff --git a/testautomation/framework/optional/f_basic_vba-compat.bas b/testautomation/framework/optional/f_basic_vba-compat.bas index 363e59c70cb4..a4dc91b70aac 100755 --- a/testautomation/framework/optional/f_basic_vba-compat.bas +++ b/testautomation/framework/optional/f_basic_vba-compat.bas @@ -54,6 +54,7 @@ sub LoadIncludeFiles use "global\tools\includes\optional\t_basic_organizer_tools.inc" use "global\tools\includes\optional\t_treelist_tools.inc" + use "global\tools\includes\optional\t_stringtools.inc" use "framework\optional\includes\basic_vba_compat_tools.inc" diff --git a/testautomation/framework/optional/includes/basic_vba-compat_import_disabled.inc b/testautomation/framework/optional/includes/basic_vba-compat_import_disabled.inc index fea6742d5917..6a9f0f3f47a4 100644 --- a/testautomation/framework/optional/includes/basic_vba-compat_import_disabled.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_import_disabled.inc @@ -36,12 +36,23 @@ testcase tBasicVBACompatImportDisabled() printlog( "Test VBA compatibility switch / executable Microsoft(R) Excel(R) Macros" ) printlog( "Test case 2: Import macros but do not set the executable mode" ) - ' This test case is based on the use cases provided in issue #i88690 ' Spec: http://specs.openoffice.org/appwide/options_settings/Option_Dialog.odt + + const NODE_COUNT = 78 + + const DOCUMENT_POSITION_OFFSET = -7 + + const IMPORT_EXCEL_MACROS = TRUE + const EXEC_EXCEL_MACROS = FALSE + + const DOCUMENT_NAME = "vba-test.xls" + const MATCH_NONE = 0 + const MATCH_EXACT = 1 + const MATCH_PARTLY = 2 dim cTestFile as string - cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/vba-test.xls" + cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/" & DOCUMENT_NAME dim cNodeCount as integer @@ -59,12 +70,6 @@ testcase tBasicVBACompatImportDisabled() dim bFound as boolean ' Depending on the mode of macro import we have differtent basic libraries listed - const NODE_COUNT = 78 - - const DOCUMENT_POSITION_OFFSET = -7 - - const IMPORT_EXCEL_MACROS = TRUE - const EXEC_EXCEL_MACROS = FALSE printlog( "Set macro security to low" ) hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW ) @@ -89,9 +94,11 @@ testcase tBasicVBACompatImportDisabled() printlog( "Verify position of the document node" ) MakroAus.select( cNodeCount + DOCUMENT_POSITION_OFFSET ) - if ( MakroAus.getSelText() <> "vba-test.xls" ) then - qaerrorlog( "The document node is not at the expected position" ) - endif + select case( hCompareSubStrings( MakroAus.getSelText(), DOCUMENT_NAME ) ) + case MATCH_NONE : warnlog ( "The document is not listed at the expected position" ) + case MATCH_EXACT : printlog( "The document is at the expected position and writable" ) + case MATCH_PARTLY : printlog( "The document is at the expected position and write protected" ) + end select for iCurrentModule = 2 to 7 @@ -132,7 +139,6 @@ testcase tBasicVBACompatImportDisabled() hSetExcelImportModeDefault() hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT ) - endcase diff --git a/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc b/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc index f5e9c0c4f515..f9db06fb9a5d 100644 --- a/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc @@ -39,18 +39,34 @@ testcase tBasicVBACompatImportEnabled() ' This test case is based on the use cases provided in issue #i88690 ' Spec: http://specs.openoffice.org/appwide/options_settings/Option_Dialog.odt - - dim cFile as string : cFile = "vba-test.xls" + + ' Depending on the mode of macro import we have differtent basic libraries listed + const NODE_COUNT = 78 + + const DOCUMENT_POSITION_OFFSET = -7 + + const IMPORT_EXCEL_MACROS = TRUE + const EXEC_EXCEL_MACROS = TRUE + + const DOCUMENT_NAME = "vba-test.xls" + const MATCH_NONE = 0 + const MATCH_EXACT = 1 + const MATCH_PARTLY = 2 dim cTestFile as string - cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/" & cFile + cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/" & DOCUMENT_NAME dim cNodeCount as integer - ' note that index 0 and 1 are ommitted intentionally - dim caNodeData( 3 ) as string - caNodeData( 2 ) = "Modul1" - caNodeData( 3 ) = "Modul2" + dim caNodeData( 7 ) as string + caNodeData( 0 ) = DOCUMENT_NAME ' The document, not used + caNodeData( 1 ) = "Standard" ' The default library, not used + caNodeData( 2 ) = "DieseArbeitsmappe" + caNodeData( 3 ) = "Modul1" + caNodeData( 4 ) = "Modul2" + caNodeData( 5 ) = "Tabelle1" + caNodeData( 6 ) = "Tabelle2" + caNodeData( 7 ) = "Tabelle3" dim caScripts( 3 ) as string caScripts( 2 ) = "ConcatFct Ende" @@ -62,14 +78,6 @@ testcase tBasicVBACompatImportEnabled() dim cTempString as string dim bFound as boolean - ' Depending on the mode of macro import we have differtent basic libraries listed - const NODE_COUNT = 74 - - const DOCUMENT_POSITION_OFFSET = -3 - - const IMPORT_EXCEL_MACROS = TRUE - const EXEC_EXCEL_MACROS = TRUE - printlog( "Set macro security to low" ) hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW ) @@ -94,26 +102,13 @@ testcase tBasicVBACompatImportEnabled() printlog( "Verify position of the document node." ) MakroAus.select( cNodeCount + DOCUMENT_POSITION_OFFSET ) - cTempString = MakroAus.getSelText() - if ( cTempString <> cFile ) then - qaerrorlog( "The filename does not match. File may be read-only." ) - if ( instr( cTempString, cFile ) > 1 ) then - printlog( "Filename is contained in the UI string." ) - select case ( getAttr( cTestFile ) ) - case 0 : warnlog( "The file appears to be read-only but it is " & _ - "not write-protected on filesystem level." ) - case 1 : printlog( "The file is read-only on filesystem level. Ok." ) - case else - warnlog( "getAttr() returned unexpected value. 1 or 2 are allowed" ) - printlog( "RC from getAttr() is: " & getAttr( cTestFile ) ) - end select - else - qaerrorlog( "The document node is not at the expected position." ) - qaerrorlog( "Object at this position is: " & MakroAus.getSelText() ) - endif - endif + select case( hCompareSubStrings( MakroAus.getSelText(), DOCUMENT_NAME ) ) + case MATCH_NONE : warnlog ( "The document is not listed at the expected position" ) + case MATCH_EXACT : printlog( "The document is at the expected position and writable" ) + case MATCH_PARTLY : printlog( "The document is at the expected position and write protected" ) + end select - for iCurrentModule = 2 to 3 + for iCurrentModule = 2 to 7 printlog( "Look for: " & caNodeData( iCurrentModule ) ) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_import_nothing.inc b/testautomation/framework/optional/includes/basic_vba-compat_import_nothing.inc index f61064e28e0d..394ff08fc7a7 100644 --- a/testautomation/framework/optional/includes/basic_vba-compat_import_nothing.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_import_nothing.inc @@ -38,19 +38,26 @@ testcase tBasicVBACompatImportNothing() ' This test case is based on the use cases provided in issue #i88690 ' Spec: http://specs.openoffice.org/appwide/options_settings/Option_Dialog.odt - - dim cTestFile as string - cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/vba-test.xls" - - dim cNodeCount as integer - - ' Depending on the mode of macro import we have differtent basic libraries listed +' Depending on the mode of macro import we have differtent basic libraries listed const NODE_COUNT = 72 ' Do not import Microsoft(R) Excel(R) macros at all const MACRO_LIST = 0 ' The document library should have no scripts listed const DOCUMENT_POSITION_OFFSET = -1 - + const IMPORT_EXCEL_MACROS = FALSE const EXEC_EXCEL_MACROS = FALSE + + const DOCUMENT_NAME = "vba-test.xls" + const MATCH_NONE = 0 + const MATCH_EXACT = 1 + const MATCH_PARTLY = 2 + + dim cTestFile as string + cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/" & DOCUMENT_NAME + + dim cNodeCount as integer + + + printlog( "Set macro security to low" ) hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW ) @@ -75,9 +82,11 @@ testcase tBasicVBACompatImportNothing() printlog( "Verify position of the document node" ) MakroAus.select( cNodeCount + DOCUMENT_POSITION_OFFSET ) - if ( MakroAus.getSelText() <> "vba-test.xls" ) then - qaerrorlog( "The document node is not at the expected position" ) - endif + select case( hCompareSubStrings( MakroAus.getSelText(), DOCUMENT_NAME ) ) + case MATCH_NONE : warnlog ( "The document is not listed at the expected position" ) + case MATCH_EXACT : printlog( "The document is at the expected position and writable" ) + case MATCH_PARTLY : printlog( "The document is at the expected position and write protected" ) + end select printlog( "Select the last node, this should be the standard Library for the document" ) MakroAus.select( cNodeCount ) -- cgit From 191ed5e45a9fca624a133e11281b3d8bf3684d81 Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Tue, 27 Apr 2010 09:36:27 +0200 Subject: npower13_objectmodules: #i111175 - Adjust indexes for scripts belonging to modules, the latest changes caused an index out of bounds error. --- .../optional/includes/basic_vba-compat_import_enabled.inc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc b/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc index f9db06fb9a5d..5a5cb2b8ddea 100644 --- a/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc @@ -67,10 +67,12 @@ testcase tBasicVBACompatImportEnabled() caNodeData( 5 ) = "Tabelle1" caNodeData( 6 ) = "Tabelle2" caNodeData( 7 ) = "Tabelle3" - - dim caScripts( 3 ) as string - caScripts( 2 ) = "ConcatFct Ende" - caScripts( 3 ) = "WriteIt" + + ' These are the scripts belonging to each node above. If multiple scripts exist + ' they are separated by spaces. Example: "Modul1" has "ConcatFct" and "Ende" scripts. + dim caScripts( 7 ) as string + caScripts( 3 ) = "ConcatFct Ende" + caScripts( 4 ) = "WriteIt" dim iCurrentModule as integer dim iCurrentScript as integer @@ -81,7 +83,7 @@ testcase tBasicVBACompatImportEnabled() printlog( "Set macro security to low" ) hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW ) - printlog( "Open Tools/Options" ) + printlog( "Open Tools/Options and set the VBA macro execution mode" ) hSetExcelBasicImportMode( IMPORT_EXCEL_MACROS, EXEC_EXCEL_MACROS ) -- cgit From 27f4a7803bb68b43aafc771075a71be483b53646 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 27 Apr 2010 11:17:28 +0100 Subject: armeabi02: #i105359# fix arm-eabi uno bridge, fix exception handling, and fix struct returning rules --- solenv/inc/unxlngr.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solenv/inc/unxlngr.mk b/solenv/inc/unxlngr.mk index 1bcbb6626219..a7be4c2044de 100644 --- a/solenv/inc/unxlngr.mk +++ b/solenv/inc/unxlngr.mk @@ -30,5 +30,5 @@ CDEFAULTOPT=-Os .INCLUDE : unxlng.mk CDEFS+=-DARM32 -CFLAGS+=-fno-omit-frame-pointer +CFLAGS+=-fno-omit-frame-pointer -Wno-psabi DLLPOSTFIX=lr -- cgit From dce434e245a25a28a2bcd4aae8a40dd3bb3c2f63 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 27 Apr 2010 11:17:28 +0100 Subject: armeabi02: #i105359# fix arm-eabi uno bridge, fix exception handling, and fix struct returning rules --- bridges/source/cpp_uno/gcc3_linux_arm/armhelper.S | 38 +++++++++ bridges/source/cpp_uno/gcc3_linux_arm/armhelper.s | 22 ----- bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx | 30 +++---- bridges/source/cpp_uno/gcc3_linux_arm/except.cxx | 6 +- bridges/source/cpp_uno/gcc3_linux_arm/makefile.mk | 2 +- bridges/source/cpp_uno/gcc3_linux_arm/share.hxx | 7 ++ bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx | 99 ++++++++++++++++------- 7 files changed, 133 insertions(+), 71 deletions(-) create mode 100644 bridges/source/cpp_uno/gcc3_linux_arm/armhelper.S delete mode 100644 bridges/source/cpp_uno/gcc3_linux_arm/armhelper.s diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/armhelper.S b/bridges/source/cpp_uno/gcc3_linux_arm/armhelper.S new file mode 100644 index 000000000000..8db287174680 --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_linux_arm/armhelper.S @@ -0,0 +1,38 @@ +@ ARM support code for OpenOffice C++/UNO bridging +@ +@ Written by Peter Naulls +@ Modified by Caolan McNamara +@ Fixed by Michael Casadevall + +#ifdef __ARM_EABI__ +# define UNWIND +#else +# define UNWIND @ +#endif + + .file "armhelper.s" + .text + .align 4 + .global privateSnippetExecutor + .type privateSnippetExecutor, %function +privateSnippetExecutor: + UNWIND .fnstart @ start of unwinder entry + + stmfd sp!, {r0-r3} @ follow other parameters on stack + UNWIND .pad #16 @ throw this data away on exception + mov r0, ip @ r0 points to functionoffset/vtable + mov r1, sp @ r1 points to this and params + @ (see cppuno.cxx:codeSnippet()) + stmfd sp!, {r4,lr} @ save return address + @ (r4 pushed to preserve stack alignment) + UNWIND .save {r4,lr} @ restore these regs on exception + + bl cpp_vtable_call(PLT) + + add sp, sp, #4 @ no need to restore r4 (we didn't touch it) + ldr pc, [sp], #20 @ return, discarding function arguments + + UNWIND .fnend @ end of unwinder entry + + .size privateSnippetExecutor, . - privateSnippetExecutor + .section .note.GNU-stack,"",%progbits diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/armhelper.s b/bridges/source/cpp_uno/gcc3_linux_arm/armhelper.s deleted file mode 100644 index 8fd1a38e4f51..000000000000 --- a/bridges/source/cpp_uno/gcc3_linux_arm/armhelper.s +++ /dev/null @@ -1,22 +0,0 @@ -@ ARM support code for OpenOffice C++/UNO bridging -@ -@ Written by Peter Naulls -@ Modified by Caolan McNamara - .file "armhelper.s" - .text - .align 4 - .global privateSnippetExecutor - .type privateSnippetExecutor, %function -privateSnippetExecutor: - stmfd sp!, {r0-r3} @ follow other parameters on stack - mov r0, ip @ r0 points to functionoffset/vtable - mov ip, sp @ fix up the ip - stmfd sp!, {fp,ip,lr,pc} @ 8 x 4 => stack remains 8 aligned - sub fp, ip, #4 @ set frame pointer - - add r1, sp, #16 @ r1 points to this and params - bl cpp_vtable_call(PLT) - - add sp, sp, #32 @ restore stack - ldr fp, [sp, #-32] @ restore frame pointer - ldr pc, [sp, #-24] @ return diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx index 98c213a53a83..54239945df19 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx @@ -76,10 +76,8 @@ namespace if (pReturnTypeDescr) { - if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr )) - { + if (!arm::return_in_hidden_param(pReturnTypeRef)) pUnoReturn = pRegisterReturn; // direct way for simple types - } else // complex return via ptr (pCppReturn) { pCppReturn = *(void **)pCppStack; @@ -422,9 +420,9 @@ namespace const int codeSnippetSize = 20; unsigned char *codeSnippet(unsigned char* code, sal_Int32 functionIndex, - sal_Int32 vtableOffset, bool simple_ret_type ) + sal_Int32 vtableOffset, bool bHasHiddenParam) { - if (!simple_ret_type) + if (bHasHiddenParam) functionIndex |= 0x80000000; unsigned long * p = (unsigned long *)code; @@ -478,24 +476,25 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( switch (member->eTypeClass) { case typelib_TypeClass_INTERFACE_ATTRIBUTE: + { + typelib_InterfaceAttributeTypeDescription *pAttrTD = + reinterpret_cast( member ); + // Getter: (s++)->fn = code + writetoexecdiff; code = codeSnippet( code, functionOffset++, vtableOffset, - bridges::cpp_uno::shared::isSimpleType( - reinterpret_cast< - typelib_InterfaceAttributeTypeDescription * >( - member)->pAttributeTypeRef)); + arm::return_in_hidden_param( pAttrTD->pAttributeTypeRef )); + // Setter: - if (!reinterpret_cast< - typelib_InterfaceAttributeTypeDescription * >( - member)->bReadOnly) + if (!pAttrTD->bReadOnly) { (s++)->fn = code + writetoexecdiff; code = codeSnippet( - code, functionOffset++, vtableOffset, true); + code, functionOffset++, vtableOffset, false); } break; + } case typelib_TypeClass_INTERFACE_METHOD: { (s++)->fn = code + writetoexecdiff; @@ -504,11 +503,8 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( reinterpret_cast< typelib_InterfaceMethodTypeDescription * >(member); - bool issimple = bridges::cpp_uno::shared::isSimpleType( - pMethodTD->pReturnTypeRef); - code = codeSnippet(code, functionOffset++, vtableOffset, - issimple); + arm::return_in_hidden_param(pMethodTD->pReturnTypeRef)); break; } default: diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/except.cxx b/bridges/source/cpp_uno/gcc3_linux_arm/except.cxx index df717fe1f279..ec1e671a72ba 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_arm/except.cxx @@ -162,8 +162,8 @@ namespace CPPU_CURRENT_NAMESPACE else { // try to lookup the symbol in the generated rtti map - t_rtti_map::const_iterator iFind( m_generatedRttis.find( unoName ) ); - if (iFind == m_generatedRttis.end()) + t_rtti_map::const_iterator iFind2( m_generatedRttis.find( unoName ) ); + if (iFind2 == m_generatedRttis.end()) { // we must generate it ! // symbol and rtti-name is nearly identical, @@ -192,7 +192,7 @@ namespace CPPU_CURRENT_NAMESPACE } else // taking already generated rtti { - rtti = iFind->second; + rtti = iFind2->second; } } } diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/makefile.mk b/bridges/source/cpp_uno/gcc3_linux_arm/makefile.mk index 44c557795510..0900ec11f41f 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/makefile.mk +++ b/bridges/source/cpp_uno/gcc3_linux_arm/makefile.mk @@ -80,5 +80,5 @@ SHL1STDLIBS= \ .INCLUDE : target.mk -$(SLO)$/%.obj: %.s +$(SLO)$/%.obj: %.S $(CXX) -c -o $(SLO)$/$(@:b).o $< -fPIC ; touch $@ diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/share.hxx b/bridges/source/cpp_uno/gcc3_linux_arm/share.hxx index cfe220abaf17..fb72c360fd45 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/share.hxx +++ b/bridges/source/cpp_uno/gcc3_linux_arm/share.hxx @@ -89,5 +89,12 @@ namespace CPPU_CURRENT_NAMESPACE void fillUnoException( __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno ); } + +namespace arm +{ + enum armlimits { MAX_GPR_REGS = 4 }; + bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef ); +} + #endif /* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx index 154ae52027bb..8d40be39b5ab 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx @@ -105,17 +105,58 @@ using namespace ::com::sun::star::uno; namespace arm { - enum armlimits { MAX_GPR_REGS = 4 }; + bool is_complex_struct(const typelib_TypeDescription * type) + { + const typelib_CompoundTypeDescription * p + = reinterpret_cast< const typelib_CompoundTypeDescription * >(type); + for (sal_Int32 i = 0; i < p->nMembers; ++i) + { + if (p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_STRUCT || + p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_EXCEPTION) + { + typelib_TypeDescription * t = 0; + TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]); + bool b = is_complex_struct(t); + TYPELIB_DANGER_RELEASE(t); + if (b) { + return true; + } + } + else if (!bridges::cpp_uno::shared::isSimpleType(p->ppTypeRefs[i]->eTypeClass)) + return true; + } + if (p->pBaseTypeDescription != 0) + return is_complex_struct(&p->pBaseTypeDescription->aBase); + return false; + } + + bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef ) + { + if (bridges::cpp_uno::shared::isSimpleType(pTypeRef)) + return false; + else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION) + { + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); + + //A Composite Type not larger than 4 bytes is returned in r0 + bool bRet = pTypeDescr->nSize > 4 || is_complex_struct(pTypeDescr); + + TYPELIB_DANGER_RELEASE( pTypeDescr ); + return bRet; + } + return true; + } } -void MapReturn(long r0, long r1, typelib_TypeClass eReturnType, void *pRegisterReturn) +void MapReturn(long r0, long r1, typelib_TypeDescriptionReference * pReturnType, void *pRegisterReturn) { #if !defined(__ARM_EABI__) && !defined(__SOFTFP__) register float fret asm("f0"); register double dret asm("f0"); #endif - switch( eReturnType ) + switch( pReturnType->eTypeClass ) { case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: @@ -149,6 +190,13 @@ void MapReturn(long r0, long r1, typelib_TypeClass eReturnType, void *pRegisterR *(double*)pRegisterReturn = dret; #endif break; + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_EXCEPTION: + { + if (!arm::return_in_hidden_param(pReturnType)) + ((long*)pRegisterReturn)[0] = r0; + break; + } default: break; } @@ -162,7 +210,7 @@ void callVirtualMethod( void * pThis, sal_Int32 nVtableIndex, void * pRegisterReturn, - typelib_TypeClass eReturnType, + typelib_TypeDescriptionReference * pReturnType, sal_uInt32 *pStack, sal_uInt32 nStack, sal_uInt32 *pGPR, @@ -172,7 +220,7 @@ void callVirtualMethod( void * pThis, sal_Int32 nVtableIndex, void * pRegisterReturn, - typelib_TypeClass eReturnType, + typelib_TypeDescriptionReference * pReturnType, sal_uInt32 *pStack, sal_uInt32 nStack, sal_uInt32 *pGPR, @@ -201,23 +249,10 @@ void callVirtualMethod( typedef void (*FunctionCall )( sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32); FunctionCall pFunc = (FunctionCall)pMethod; - // fill registers - __asm__ __volatile__ ( - "ldr r0, [%0, #0]\n\t" - "ldr r1, [%0, #4]\n\t" - "ldr r2, [%0, #8]\n\t" - "ldr r3, [%0, #12]\n\t" - : : "r" (pGPR) - : "r0", "r1", "r2", "r3" - ); - - // tell gcc that r0 to r3 are not available to it - register sal_uInt32 r0 asm("r0"); - register sal_uInt32 r1 asm("r1"); - register sal_uInt32 r2 asm("r2"); - register sal_uInt32 r3 asm("r3"); - - (*pFunc)(r0, r1, r2, r3); + (*pFunc)(pGPR[0], pGPR[1], pGPR[2], pGPR[3]); + + sal_uInt32 r0; + sal_uInt32 r1; // get return value __asm__ __volatile__ ( @@ -225,7 +260,7 @@ void callVirtualMethod( "mov %1, r1\n\t" : "=r" (r0), "=r" (r1) : ); - MapReturn(r0, r1, eReturnType, pRegisterReturn); + MapReturn(r0, r1, pReturnType, pRegisterReturn); } } @@ -312,14 +347,14 @@ static void cpp_call( void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion bool bOverFlow = false; - + bool bSimpleReturn = true; if (pReturnTypeDescr) { + if (arm::return_in_hidden_param( pReturnTypeRef ) ) + bSimpleReturn = false; - if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr )) - { + if (bSimpleReturn) pCppReturn = pUnoReturn; // direct way for simple types - } else { // complex return via ptr @@ -390,6 +425,8 @@ static void cpp_call( case typelib_TypeClass_DOUBLE: INSERT_DOUBLE( pCppArgs[nPos], nGPR, pGPR, pStack, pStackStart, bOverFlow ); break; + default: + break; } // no longer needed TYPELIB_DANGER_RELEASE( pParamTypeDescr ); @@ -431,7 +468,7 @@ static void cpp_call( { callVirtualMethod( pAdjustedThisPtr, aVtableSlot.index, - pCppReturn, pReturnTypeDescr->eTypeClass, + pCppReturn, pReturnTypeRef, pStackStart, (pStack - pStackStart), pGPR, nGPR); @@ -504,15 +541,19 @@ void unoInterfaceProxyDispatch( // is my surrogate bridges::cpp_uno::shared::UnoInterfaceProxy * pThis = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI); +#if OSL_DEBUG_LEVEL > 0 typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr; +#endif switch (pMemberDescr->eTypeClass) { case typelib_TypeClass_INTERFACE_ATTRIBUTE: { +#if OSL_DEBUG_LEVEL > 0 // determine vtable call index sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" ); +#endif VtableSlot aVtableSlot( getVtableSlot( @@ -557,9 +598,11 @@ void unoInterfaceProxyDispatch( } case typelib_TypeClass_INTERFACE_METHOD: { +#if OSL_DEBUG_LEVEL > 0 // determine vtable call index sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" ); +#endif VtableSlot aVtableSlot( getVtableSlot( -- cgit From bf7e511ee990e956ff4bdf438425a00c05262624 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Tue, 27 Apr 2010 15:50:49 +0200 Subject: gridcontrol_03:bug fixes for resizing columns --- svtools/source/table/tablecontrol_impl.cxx | 189 ++++++++++++++-------------- svtools/source/table/tablecontrol_impl.hxx | 1 + toolkit/source/controls/grid/gridcolumn.cxx | 2 + 3 files changed, 96 insertions(+), 96 deletions(-) diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 37717c5c1833..1526dbdb778d 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -578,109 +578,111 @@ namespace svt { namespace table m_aColumnWidthsPixel.reserve( colCount ); m_aAccColumnWidthsPixel.reserve( colCount ); - std::vector aPrePixelWidths(0); - long accumulatedPixelWidth = 0; - int lastResizableCol = -1; - double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width(); - if(m_pModel->hasRowHeaders()) - { - TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); - gridWidth-= m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); - } - if(m_pModel->hasVerticalScrollbar()) + if(colCount>0) { - sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); - gridWidth-=scrollbarWidth; - } - double colWidthsSum = 0.0; - double colWithoutFixedWidthsSum = 0.0; - double minColWithoutFixedSum = 0.0; - for ( ColPos col = 0; col < colCount; ++col ) - { - PColumnModel pColumn = m_pModel->getColumnModel( col ); - DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); - if ( !pColumn ) - continue; - TableMetrics colWidth = 0; - TableMetrics colPrefWidth = pColumn->getPreferredWidth(); - bool bResizable = pColumn->isResizable(); - if(pColumn->getMinWidth() == 0 && bResizable) + std::vector aPrePixelWidths(0); + long accumulatedPixelWidth = 0; + int lastResizableCol = -1; + double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width(); + if(m_pModel->hasRowHeaders()) { - pColumn->setMinWidth(1); - minColWithoutFixedSum+=m_rAntiImpl.LogicToPixel( Size( 1, 0 ), MAP_APPFONT ).Width(); + TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); + gridWidth-= m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); } - if(pColumn->getMaxWidth() == 0 && bResizable) - pColumn->setMaxWidth(m_rAntiImpl.LogicToPixel( Size( (int)gridWidth, 0 ), MAP_APPFONT ).Width()); - if( colPrefWidth != 0) + if(m_pModel->hasVerticalScrollbar()) { - if(m_bResizingGrid) + sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); + gridWidth-=scrollbarWidth; + } + double colWidthsSum = 0.0; + double colWithoutFixedWidthsSum = 0.0; + double minColWithoutFixedSum = 0.0; + for ( ColPos col = 0; col < colCount; ++col ) + { + PColumnModel pColumn = m_pModel->getColumnModel( col ); + DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + if ( !pColumn ) + continue; + TableMetrics colWidth = 0; + TableMetrics colPrefWidth = pColumn->getPreferredWidth(); + bool bResizable = pColumn->isResizable(); + if(pColumn->getMinWidth() == 0 && bResizable) { - colWidth = pColumn->getWidth(); - pColumn->setPreferredWidth(0); + pColumn->setMinWidth(1); + minColWithoutFixedSum+=m_rAntiImpl.LogicToPixel( Size( 1, 0 ), MAP_APPFONT ).Width(); + } + if(pColumn->getMaxWidth() == 0 && bResizable) + pColumn->setMaxWidth(m_rAntiImpl.LogicToPixel( Size( (int)gridWidth, 0 ), MAP_APPFONT ).Width()); + if( colPrefWidth != 0) + { + if(m_bResizingGrid) + { + colWidth = pColumn->getWidth(); + pColumn->setPreferredWidth(0); + } + else + { + colWidth = colPrefWidth; + pColumn->setWidth(colPrefWidth); + } } else + colWidth = pColumn->getWidth(); + long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + if(bResizable && colPrefWidth == 0) { - colWidth = colPrefWidth; - pColumn->setWidth(colPrefWidth); + colWithoutFixedWidthsSum+=pixelWidth; + lastResizableCol = col; } + colWidthsSum+=pixelWidth; + aPrePixelWidths.push_back(pixelWidth); } - else - colWidth = pColumn->getWidth(); - long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - if(bResizable && colPrefWidth == 0) + double gridWidthWithoutFixed = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; + double scalingFactor = 1.0; + if(m_bResizingGrid) { - colWithoutFixedWidthsSum+=pixelWidth; - lastResizableCol = col; + if(gridWidthWithoutFixed > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum)) + scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; } - colWidthsSum+=pixelWidth; - aPrePixelWidths.push_back(pixelWidth); - } - double gridWidthWithoutFixed = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; - double scalingFactor = 1.0; - if(m_bResizingGrid) - { - if(gridWidthWithoutFixed > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum)) - scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; - } - else - { - if(colWidthsSum < gridWidthWithoutFixed) + else { - if(colWithoutFixedWidthsSum>0) - scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; + if(colWidthsSum < gridWidthWithoutFixed) + { + if(colWithoutFixedWidthsSum>0) + scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; + } } - } - long pixelWidth = 0; - for ( ColPos i = 0; i < colCount; ++i ) - { - PColumnModel pColumn = m_pModel->getColumnModel( i ); - DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); - if ( !pColumn ) - continue; - if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) + for ( ColPos i = 0; i < colCount; ++i ) { - aPrePixelWidths[i]*=scalingFactor; - TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width(); - pColumn->setWidth(logicColWidth); + PColumnModel pColumn = m_pModel->getColumnModel( i ); + DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + if ( !pColumn ) + continue; + if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) + { + aPrePixelWidths[i]*=scalingFactor; + TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width(); + pColumn->setWidth(logicColWidth); + } + m_aColumnWidthsPixel.push_back( aPrePixelWidths[i] ); + m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += aPrePixelWidths[i] ); } - m_aColumnWidthsPixel.push_back( aPrePixelWidths[i] ); - m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += aPrePixelWidths[i] ); - } - if(gridWidth > m_aAccColumnWidthsPixel[colCount-1]) - { - if(lastResizableCol >= 0) + if(gridWidth > m_aAccColumnWidthsPixel[colCount-1]) { - PColumnModel pColumn = m_pModel->getColumnModel(lastResizableCol); - m_aColumnWidthsPixel[lastResizableCol]+=gridWidth-m_aAccColumnWidthsPixel[colCount-1]; - TableMetrics logicColWidth1 = m_rAntiImpl.PixelToLogic( Size( m_aColumnWidthsPixel[lastResizableCol], 0 ), MAP_APPFONT ).Width(); - pColumn->setWidth(logicColWidth1); - while(lastResizableCol < colCount) + if(lastResizableCol >= 0) { - if(lastResizableCol == 0) - m_aAccColumnWidthsPixel[0] = m_aColumnWidthsPixel[lastResizableCol]; - else - m_aAccColumnWidthsPixel[lastResizableCol]=m_aAccColumnWidthsPixel[lastResizableCol-1]+m_aColumnWidthsPixel[lastResizableCol]; - ++lastResizableCol; + PColumnModel pColumn = m_pModel->getColumnModel(lastResizableCol); + m_aColumnWidthsPixel[lastResizableCol]+=gridWidth-m_aAccColumnWidthsPixel[colCount-1]; + TableMetrics logicColWidth1 = m_rAntiImpl.PixelToLogic( Size( m_aColumnWidthsPixel[lastResizableCol], 0 ), MAP_APPFONT ).Width(); + pColumn->setWidth(logicColWidth1); + while(lastResizableCol < colCount) + { + if(lastResizableCol == 0) + m_aAccColumnWidthsPixel[0] = m_aColumnWidthsPixel[lastResizableCol]; + else + m_aAccColumnWidthsPixel[lastResizableCol]=m_aAccColumnWidthsPixel[lastResizableCol-1]+m_aColumnWidthsPixel[lastResizableCol]; + ++lastResizableCol; + } } } } @@ -932,11 +934,15 @@ namespace svt { namespace table } } else + { //In the case that column headers are defined but data hasn't yet been set, //only column headers will be shown if(m_pModel->hasColumnHeaders()) if(m_nColHeaderHeightPixel>1) m_pDataWindow->SetSizePixel( m_rAntiImpl.GetOutputSizePixel()); + if(m_nColumnCount != 0) + impl_ni_updateScrollbars(); + } } //-------------------------------------------------------------------- @@ -1060,14 +1066,8 @@ namespace svt { namespace table //to avoid double lines if( aRowIterator.getRow() != 0 ) --aRect.Top(); - else - if(m_nColHeaderHeightPixel>1) - --aRect.Top(); if(m_nLeftColumn != 0) --aRect.Left(); - else - if(m_pModel->hasRowHeaders()) - --aRect.Left(); // give the redenderer a chance to prepare the row pRenderer->PrepareRow( aRowIterator.getRow(), isActiveRow, isSelectedRow, *m_pDataWindow, aRect, rStyle ); @@ -1904,7 +1904,7 @@ namespace svt { namespace table //------------------------------------------------------------------------------- ::rtl::OUString& TableControl_Impl::setTooltip(const Point& rPoint ) { - ::rtl::OUString& aTooltipText(::rtl::OUString::createFromAscii("")); + ::rtl::OUString aTooltipText; RowPos current = getCurrentRow(rPoint); com::sun::star::uno::Sequence< sal_Int32 > cols = m_rAntiImpl.getColumnsForTooltip(); com::sun::star::uno::Sequence< ::rtl::OUString > text = m_rAntiImpl.getTextForTooltip(); @@ -1971,7 +1971,7 @@ namespace svt { namespace table } } } - return aTooltipText; + return m_aTooltipText = aTooltipText; } //-------------------------------------------------------------------- void TableControl_Impl::resizeColumn(const Point& rPoint) @@ -2081,7 +2081,6 @@ namespace svt { namespace table { TableSize nVisCols = impl_getVisibleColumns(true); int widthsPixel = 0; - int pixelWidth = 0; m_aVisibleColumnWidthsPixel.resize(0); m_aVisibleColumnWidthsPixel.reserve(nVisCols); int headerRowWidth = 0; @@ -2093,8 +2092,6 @@ namespace svt { namespace table int col = m_nLeftColumn; while(nVisCols) { - // PColumnModel pColumn = m_pModel->getColumnModel(col); - // pixelWidth = m_rAntiImpl.LogicToPixel( Size( pColumn->getWidth(), 0 ), MAP_APPFONT ).Width(); m_aVisibleColumnWidthsPixel.push_back(widthsPixel+=m_aColumnWidthsPixel[col]); col++; nVisCols--; diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 6e009ffd6fd9..0a487c77c76c 100644 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -120,6 +120,7 @@ namespace svt { namespace table bool m_bResizing; ColPos m_nResizingColumn; bool m_bResizingGrid; + rtl::OUString m_aTooltipText; #if DBG_UTIL #define INV_SCROLL_POSITION 1 diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index ea1337561389..6720d639f5c1 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -61,6 +61,8 @@ GridColumn::GridColumn() ,index(0) ,columnWidth(4) ,preferredWidth(0) +,maxWidth(0) +,minWidth(0) ,bResizeable(true) ,horizontalAlign(HorizontalAlignment(0)) { -- cgit From 655b91ccd37e88bdac6d482b12ff8be7b079ae53 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 27 Apr 2010 15:10:05 +0100 Subject: #i105359# remove -Wno-psabi, only in >= 4.4.0 and I haven't the interest in hooking up a version test just to silence a arm-specific warning --- solenv/inc/unxlngr.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solenv/inc/unxlngr.mk b/solenv/inc/unxlngr.mk index a7be4c2044de..1bcbb6626219 100644 --- a/solenv/inc/unxlngr.mk +++ b/solenv/inc/unxlngr.mk @@ -30,5 +30,5 @@ CDEFAULTOPT=-Os .INCLUDE : unxlng.mk CDEFS+=-DARM32 -CFLAGS+=-fno-omit-frame-pointer -Wno-psabi +CFLAGS+=-fno-omit-frame-pointer DLLPOSTFIX=lr -- cgit From 29e00d08352b602be0425b9c14385ec38a835b6d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 28 Apr 2010 10:55:22 +0200 Subject: sw33bf03: #i110454#: fix warning by moving member to Impl struct --- sw/inc/shellio.hxx | 8 +------- sw/source/filter/writer/writer.cxx | 17 +++++++++-------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 931e6d117ead..28dcdf26a352 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -436,8 +436,6 @@ class SW_DLLPUBLIC Writer : public SvRefBase SwAsciiOptions aAscOpts; String sBaseURL; - SvStream * m_pStream; - void _AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ); void _AddFontItems( SfxItemPool& rPool, USHORT nWhichId ); @@ -535,12 +533,8 @@ public: inline SvStream& OutLong( long nVal ) { return OutLong( Strm(), nVal ); } inline SvStream& OutULong( ULONG nVal ) { return OutULong( Strm(), nVal ); } - void SetStream(SvStream *const pStream) { m_pStream = pStream; } -#ifndef DBG_UTIL - SvStream& Strm() { return *m_pStream; } -#else + void SetStream(SvStream *const pStream); SvStream& Strm(); -#endif void SetOrganizerMode( BOOL bSet ) { bOrganizerMode = bSet; } }; diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index bcd61fda6af0..bde2e253d947 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -58,6 +58,8 @@ DECLARE_TABLE( SwBookmarkNodeTable, SvPtrarr* ) struct Writer_Impl { + SvStream * m_pStream; + SvStringsSortDtor *pSrcArr, *pDestArr; SvPtrarr* pFontRemoveLst, *pBkmkArr; SwBookmarkNodeTable* pBkmkNodePos; @@ -70,7 +72,8 @@ struct Writer_Impl }; Writer_Impl::Writer_Impl( const SwDoc& /*rDoc*/ ) - : pSrcArr( 0 ), pDestArr( 0 ), pFontRemoveLst( 0 ), pBkmkNodePos( 0 ) + : m_pStream(0) + , pSrcArr( 0 ), pDestArr( 0 ), pFontRemoveLst( 0 ), pBkmkNodePos( 0 ) { } @@ -142,7 +145,6 @@ void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk) Writer::Writer() : pImpl(0) - , m_pStream(0) , pOrigPam(0), pOrigFileName(0), pDoc(0), pCurPam(0) { bWriteAll = bShowProgress = bUCS2_WithStartChar = true; @@ -179,7 +181,6 @@ void Writer::ResetWriter() pCurPam = 0; pOrigFileName = 0; pDoc = 0; - m_pStream = 0; bShowProgress = bUCS2_WithStartChar = TRUE; bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR = @@ -248,13 +249,13 @@ SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, ///////////////////////////////////////////////////////////////////////////// // Stream-spezifisches -#ifdef DBG_UTIL SvStream& Writer::Strm() { - ASSERT( m_pStream, "Oh-oh. Writer with no Stream!" ); - return *m_pStream; + ASSERT( pImpl->m_pStream, "Oh-oh. Writer with no Stream!" ); + return *pImpl->m_pStream; } -#endif + +void Writer::SetStream(SvStream *const pStream) { pImpl->m_pStream = pStream; } SvStream& Writer::OutHex( SvStream& rStrm, ULONG nHex, BYTE nLen ) @@ -316,10 +317,10 @@ ULONG Writer::Write( SwPaM& rPaM, SvStream& rStrm, const String* pFName ) return nResult; } - m_pStream = &rStrm; pDoc = rPaM.GetDoc(); pOrigFileName = pFName; pImpl = new Writer_Impl( *pDoc ); + pImpl->m_pStream = &rStrm; // PaM kopieren, damit er veraendert werden kann pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() ); -- cgit From 94e9b98a8341459bcdb7781a4f711cb5458c89ee Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 28 Apr 2010 17:13:01 +0200 Subject: sw33bf03: #i110454#: try to fix harebrained lifecycle of Writer_Impl --- sw/inc/shellio.hxx | 9 ++++-- sw/source/filter/writer/writer.cxx | 64 ++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 28dcdf26a352..b92cc26ca38e 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -24,8 +24,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _SHELLIO_HXX -#define _SHELLIO_HXX +#ifndef SW_SHELLIO_HXX +#define SW_SHELLIO_HXX + +#include #include #include @@ -439,8 +441,9 @@ class SW_DLLPUBLIC Writer : public SvRefBase void _AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ); void _AddFontItems( SfxItemPool& rPool, USHORT nWhichId ); + ::std::auto_ptr m_pImpl; + protected: - Writer_Impl* pImpl; SwPaM* pOrigPam; // der letze zu bearbeitende Pam const String* pOrigFileName; diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index bde2e253d947..d70b6d6c754e 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -64,14 +64,14 @@ struct Writer_Impl SvPtrarr* pFontRemoveLst, *pBkmkArr; SwBookmarkNodeTable* pBkmkNodePos; - Writer_Impl( const SwDoc& rDoc ); + Writer_Impl(); ~Writer_Impl(); void RemoveFontList( SwDoc& rDoc ); void InsertBkmk( const ::sw::mark::IMark& rBkmk ); }; -Writer_Impl::Writer_Impl( const SwDoc& /*rDoc*/ ) +Writer_Impl::Writer_Impl() : m_pStream(0) , pSrcArr( 0 ), pDestArr( 0 ), pFontRemoveLst( 0 ), pBkmkNodePos( 0 ) { @@ -144,7 +144,7 @@ void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk) */ Writer::Writer() - : pImpl(0) + : m_pImpl(new Writer_Impl) , pOrigPam(0), pOrigFileName(0), pDoc(0), pCurPam(0) { bWriteAll = bShowProgress = bUCS2_WithStartChar = true; @@ -168,9 +168,11 @@ const IDocumentStylePoolAccess* Writer::getIDocumentStylePoolAccess() const { re void Writer::ResetWriter() { - if( pImpl && pImpl->pFontRemoveLst ) - pImpl->RemoveFontList( *pDoc ); - delete pImpl, pImpl = 0; + if (m_pImpl->pFontRemoveLst) + { + m_pImpl->RemoveFontList( *pDoc ); + } + m_pImpl.reset(new Writer_Impl); if( pCurPam ) { @@ -251,11 +253,12 @@ SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, // Stream-spezifisches SvStream& Writer::Strm() { - ASSERT( pImpl->m_pStream, "Oh-oh. Writer with no Stream!" ); - return *pImpl->m_pStream; + ASSERT( m_pImpl->m_pStream, "Oh-oh. Writer with no Stream!" ); + return *m_pImpl->m_pStream; } -void Writer::SetStream(SvStream *const pStream) { pImpl->m_pStream = pStream; } +void Writer::SetStream(SvStream *const pStream) +{ m_pImpl->m_pStream = pStream; } SvStream& Writer::OutHex( SvStream& rStrm, ULONG nHex, BYTE nLen ) @@ -319,8 +322,7 @@ ULONG Writer::Write( SwPaM& rPaM, SvStream& rStrm, const String* pFName ) pDoc = rPaM.GetDoc(); pOrigFileName = pFName; - pImpl = new Writer_Impl( *pDoc ); - pImpl->m_pStream = &rStrm; + m_pImpl->m_pStream = &rStrm; // PaM kopieren, damit er veraendert werden kann pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() ); @@ -371,20 +373,20 @@ BOOL Writer::CopyLocalFileToINet( String& rFileNm ) INET_PROT_NEWS >= aTargetUrl.GetProtocol() ) ) return bRet; - if( pImpl->pSrcArr ) + if (m_pImpl->pSrcArr) { // wurde die Datei schon verschoben USHORT nPos; - if( pImpl->pSrcArr->Seek_Entry( &rFileNm, &nPos )) + if (m_pImpl->pSrcArr->Seek_Entry( &rFileNm, &nPos )) { - rFileNm = *(*pImpl->pDestArr)[ nPos ]; + rFileNm = *(*m_pImpl->pDestArr)[ nPos ]; return TRUE; } } else { - pImpl->pSrcArr = new SvStringsSortDtor( 4, 4 ); - pImpl->pDestArr = new SvStringsSortDtor( 4, 4 ); + m_pImpl->pSrcArr = new SvStringsSortDtor( 4, 4 ); + m_pImpl->pDestArr = new SvStringsSortDtor( 4, 4 ); } String *pSrc = new String( rFileNm ); @@ -403,8 +405,8 @@ BOOL Writer::CopyLocalFileToINet( String& rFileNm ) if( bRet ) { - pImpl->pSrcArr->Insert( pSrc ); - pImpl->pDestArr->Insert( pDest ); + m_pImpl->pSrcArr->Insert( pSrc ); + m_pImpl->pDestArr->Insert( pDest ); rFileNm = *pDest; } else @@ -418,9 +420,6 @@ BOOL Writer::CopyLocalFileToINet( String& rFileNm ) void Writer::PutNumFmtFontsInAttrPool() { - if( !pImpl ) - pImpl = new Writer_Impl( *pDoc ); - // dann gibt es noch in den NumRules ein paar Fonts // Diese in den Pool putten. Haben sie danach einen RefCount > 1 // kann es wieder entfernt werden - ist schon im Pool @@ -460,9 +459,6 @@ void Writer::PutNumFmtFontsInAttrPool() void Writer::PutEditEngFontsInAttrPool( BOOL bIncl_CJK_CTL ) { - if( !pImpl ) - pImpl = new Writer_Impl( *pDoc ); - SfxItemPool& rPool = pDoc->GetAttrPool(); if( rPool.GetSecondaryPool() ) { @@ -477,9 +473,6 @@ void Writer::PutEditEngFontsInAttrPool( BOOL bIncl_CJK_CTL ) void Writer::PutCJKandCTLFontsInAttrPool() { - if( !pImpl ) - pImpl = new Writer_Impl( *pDoc ); - SfxItemPool& rPool = pDoc->GetAttrPool(); _AddFontItems( rPool, RES_CHRATR_CJK_FONT ); _AddFontItems( rPool, RES_CHRATR_CTL_FONT ); @@ -516,11 +509,13 @@ void Writer::_AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ) rPool.Remove( *pItem ); else { - if( !pImpl->pFontRemoveLst ) - pImpl->pFontRemoveLst = new SvPtrarr( 0, 10 ); + if (!m_pImpl->pFontRemoveLst) + { + m_pImpl->pFontRemoveLst = new SvPtrarr( 0, 10 ); + } void* p = (void*)pItem; - pImpl->pFontRemoveLst->Insert( p, pImpl->pFontRemoveLst->Count() ); + m_pImpl->pFontRemoveLst->Insert( p, m_pImpl->pFontRemoveLst->Count() ); } } @@ -532,7 +527,9 @@ void Writer::CreateBookmarkTbl() for(IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->getBookmarksBegin(); ppBkmk != pMarkAccess->getBookmarksEnd(); ++ppBkmk) - pImpl->InsertBkmk(**ppBkmk); + { + m_pImpl->InsertBkmk(**ppBkmk); + } } @@ -543,7 +540,8 @@ USHORT Writer::GetBookmarks(const SwCntntNode& rNd, xub_StrLen nStt, ASSERT( !rArr.Count(), "es sind noch Eintraege vorhanden" ); ULONG nNd = rNd.GetIndex(); - SvPtrarr* pArr = pImpl->pBkmkNodePos ? pImpl->pBkmkNodePos->Get( nNd ) : 0; + SvPtrarr* pArr = (m_pImpl->pBkmkNodePos) ? + m_pImpl->pBkmkNodePos->Get( nNd ) : 0; if( pArr ) { // there exist some bookmarks, search now all which is in the range @@ -593,7 +591,6 @@ ULONG StgWriter::Write( SwPaM& rPaM, SvStorage& rStg, const String* pFName ) pStg = &rStg; pDoc = rPaM.GetDoc(); pOrigFileName = pFName; - pImpl = new Writer_Impl( *pDoc ); // PaM kopieren, damit er veraendert werden kann pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() ); @@ -615,7 +612,6 @@ ULONG StgWriter::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >& r xStg = rStg; pDoc = rPaM.GetDoc(); pOrigFileName = pFName; - pImpl = new Writer_Impl( *pDoc ); // PaM kopieren, damit er veraendert werden kann pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() ); -- cgit From e1099108f621bb65a5376b103627fbf2635ea0a5 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 29 Apr 2010 14:27:02 +0200 Subject: sw33bf03: #i110454#: fix wntmsci12 build --- sw/inc/shellio.hxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index b92cc26ca38e..0e52ce256754 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -28,6 +28,7 @@ #define SW_SHELLIO_HXX #include +#include #include #include @@ -433,7 +434,9 @@ extern BOOL SetHTMLTemplate( SwDoc &rDoc ); //Fuer Vorlagen aus HTML.vor laden s class IDocumentSettingAccess; class IDocumentStylePoolAccess; -class SW_DLLPUBLIC Writer : public SvRefBase +class SW_DLLPUBLIC Writer + : public SvRefBase + , private ::boost::noncopyable { SwAsciiOptions aAscOpts; String sBaseURL; -- cgit From d9fa74f8d6fe975541d5a44a5afee0ff261b6afc Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 30 Apr 2010 10:22:04 +0200 Subject: gridcontrol_03: bug fixes --- .../framework/optional/input/gridcontrol.odt | Bin 11924 -> 12000 bytes 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 testautomation/framework/optional/input/gridcontrol.odt diff --git a/testautomation/framework/optional/input/gridcontrol.odt b/testautomation/framework/optional/input/gridcontrol.odt old mode 100755 new mode 100644 index 31b43afb8969..d11d70cfbc09 Binary files a/testautomation/framework/optional/input/gridcontrol.odt and b/testautomation/framework/optional/input/gridcontrol.odt differ -- cgit From 54841bec35525663331fcc8081c316d264332277 Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 30 Apr 2010 10:22:04 +0200 Subject: gridcontrol_03: bug fixes --- svtools/inc/svtools/table/tabletypes.hxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/svtools/inc/svtools/table/tabletypes.hxx b/svtools/inc/svtools/table/tabletypes.hxx index f423b64c2faa..645120e30d4b 100644 --- a/svtools/inc/svtools/table/tabletypes.hxx +++ b/svtools/inc/svtools/table/tabletypes.hxx @@ -56,17 +56,17 @@ namespace svt { namespace table /** special column width value which indicates that the column should be automatically resized to fit the view */ -#define COLWIDTH_FIT_TO_VIEW ((TableMetrics)-1) +#define COLWIDTH_FIT_TO_VIEW ((::svt::table::TableMetrics)-1) /// denotes the column containing the row headers -#define COL_ROW_HEADERS ((ColPos)-1) +#define COL_ROW_HEADERS ((::svt::table::ColPos)-1) /// denotes the row containing the column headers -#define ROW_COL_HEADERS ((RowPos)-1) +#define ROW_COL_HEADERS ((::svt::table::RowPos)-1) /// denotes an invalid column index -#define COL_INVALID ((ColPos)-2) +#define COL_INVALID ((::svt::table::ColPos)-2) /// denotes an invalid row index -#define ROW_INVALID ((RowPos)-2) +#define ROW_INVALID ((::svt::table::RowPos)-2) //........................................................................ -- cgit From 771a23df1757f5aecbd2cb722e15691e9a6f28ff Mon Sep 17 00:00:00 2001 From: Mihaela Kedikova Date: Fri, 30 Apr 2010 10:22:04 +0200 Subject: gridcontrol_03: bug fixes --- automation/source/server/statemnt.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/source/server/statemnt.cxx b/automation/source/server/statemnt.cxx index 89be43de60ab..2d1cccd9fc51 100644 --- a/automation/source/server/statemnt.cxx +++ b/automation/source/server/statemnt.cxx @@ -6271,7 +6271,7 @@ protected: ::svt::table::RowPos nLastPos; while ( ( nLastPos = pTC->GetCurrentRow( aPos ) ) != nNr1-1 && nStep > 0 ) { - if ( nLastPos > nNr1-1 ) + if ( nLastPos > nNr1-1 || nLastPos == ROW_INVALID ) aPos.Y() -= nStep; else aPos.Y() += nStep; -- cgit From c6bb7651534f61d513e2947af29e66cd12a88012 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Fri, 30 Apr 2010 10:46:23 +0100 Subject: npower13_objectmodules: #i111245# fix core dump on rename --- basctl/source/basicide/baside2.cxx | 13 ------------- basctl/source/basicide/baside2.hxx | 3 +-- basctl/source/basicide/basides1.cxx | 26 +++++++++++++++++++++++--- basctl/source/basicide/basobj2.cxx | 2 +- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 71dcd25ed51a..9f97e1766c3b 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -1223,19 +1223,6 @@ void __EXPORT ModulWindow::DoScroll( ScrollBar* pCurScrollBar ) } -BOOL ModulWindow::RenameModule( const String& rNewName ) -{ - if ( !BasicIDE::RenameModule( this, GetDocument(), GetLibName(), GetName(), rNewName ) ) - return FALSE; - - SfxBindings* pBindings = BasicIDE::GetBindingsPtr(); - if ( pBindings ) - pBindings->Invalidate( SID_DOC_MODIFIED ); - - return TRUE; -} - - BOOL __EXPORT ModulWindow::IsModified() { return GetEditEngine() ? GetEditEngine()->IsModified() : FALSE; diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 0bcf4a87476b..280bb6ee3ab6 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -390,7 +390,7 @@ public: virtual void SetReadOnly( BOOL bReadOnly ); virtual BOOL IsReadOnly(); - StarBASIC* GetBasic() { return xBasic; } + StarBASIC* GetBasic() { XModule(); return xBasic; } SbModule* GetSbModule() { return xModule; } void SetSbModule( SbModule* pModule ) { xModule = pModule; } @@ -418,7 +418,6 @@ public: // void InsertFromObjectCatalog( ObjectCatalog* pObjDlg ); BOOL ToggleBreakPoint( ULONG nLine ); - BOOL RenameModule( const String& rNewName ); BasicStatus& GetBasicStatus() { return aStatus; } diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 909a28543fae..e361a17ff578 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -430,11 +430,31 @@ void __EXPORT BasicIDEShell::ExecuteGlobal( SfxRequest& rReq ) { String aNewName( rModName.GetValue() ); String aOldName( pWin->GetName() ); - if ( aNewName != aOldName ) { - if ( ( pWin->IsA( TYPE( ModulWindow ) ) && ((ModulWindow*)pWin)->RenameModule( aNewName ) ) - || ( pWin->IsA( TYPE( DialogWindow ) ) && ((DialogWindow*)pWin)->RenameDialog( aNewName ) ) ) + bool bRenameOk = false; + if ( pWin->IsA( TYPE( ModulWindow ) ) ) + { + ModulWindow* pModWin = (ModulWindow*)pWin; + String aLibName = ( pModWin->GetLibName() ); + ScriptDocument aDocument( pWin->GetDocument() ); + + if ( BasicIDE::RenameModule( pModWin, aDocument, aLibName, aOldName, aNewName ) ) + { + bRenameOk = true; + // Because we listen for container events for script + // modules, rename will delete the 'old' window + // pWin has been invalidated, restore now + pWin = FindBasWin( aDocument, aLibName, aNewName, TRUE ); + } + + } + else if ( pWin->IsA( TYPE( DialogWindow ) ) ) + { + DialogWindow* pDlgWin = (DialogWindow*)pWin; + bRenameOk = pDlgWin->RenameDialog( aNewName ); + } + if ( bRenameOk ) { BasicIDE::MarkDocumentModified( pWin->GetDocument() ); } diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx index d2672f39928f..3604866b4202 100644 --- a/basctl/source/basicide/basobj2.cxx +++ b/basctl/source/basicide/basobj2.cxx @@ -191,7 +191,7 @@ bool RenameModule( Window* pErrorParent, const ScriptDocument& rDocument, const BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); if ( pIDEShell ) { - IDEBaseWindow* pWin = pIDEShell->FindWindow( rDocument, rLibName, rOldName, BASICIDE_TYPE_MODULE, FALSE ); + IDEBaseWindow* pWin = pIDEShell->FindWindow( rDocument, rLibName, rNewName, BASICIDE_TYPE_MODULE, TRUE ); if ( pWin ) { // set new name in window -- cgit From 867721d3e825be238785847a703c211d0e61d0ab Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 4 May 2010 14:33:17 +0100 Subject: armeabi02: #i105359# fix arm-eabi uno bridge --- bridges/source/cpp_uno/gcc3_linux_arm/armhelper.S | 2 +- bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx | 24 ++++++++++++++++++++++- bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx | 20 ++++++++----------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/armhelper.S b/bridges/source/cpp_uno/gcc3_linux_arm/armhelper.S index 8db287174680..d5faf15eed6f 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/armhelper.S +++ b/bridges/source/cpp_uno/gcc3_linux_arm/armhelper.S @@ -2,7 +2,7 @@ @ @ Written by Peter Naulls @ Modified by Caolan McNamara -@ Fixed by Michael Casadevall +@ Fixed by Michael Casadevall #ifdef __ARM_EABI__ # define UNWIND diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx index 54239945df19..0e801ab4433e 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx @@ -408,8 +408,30 @@ extern "C" sal_Int64 cpp_vtable_call( long *pFunctionAndOffset, void **pCallStack ) { sal_Int64 nRegReturn; - cpp_mediate( pFunctionAndOffset[0], pFunctionAndOffset[1], pCallStack, + typelib_TypeClass aType = cpp_mediate( pFunctionAndOffset[0], pFunctionAndOffset[1], pCallStack, &nRegReturn ); + + switch( aType ) + { + case typelib_TypeClass_BOOLEAN: + case typelib_TypeClass_BYTE: + nRegReturn = (unsigned long)(*(unsigned char *)&nRegReturn); + break; + case typelib_TypeClass_CHAR: + case typelib_TypeClass_UNSIGNED_SHORT: + case typelib_TypeClass_SHORT: + nRegReturn = (unsigned long)(*(unsigned short *)&nRegReturn); + break; + case typelib_TypeClass_ENUM: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_LONG: + nRegReturn = (unsigned long)(*(unsigned int *)&nRegReturn); + break; + case typelib_TypeClass_VOID: + default: + break; + } + return nRegReturn; } diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx index 8d40be39b5ab..be67ed8fd830 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx @@ -149,7 +149,7 @@ namespace arm } } -void MapReturn(long r0, long r1, typelib_TypeDescriptionReference * pReturnType, void *pRegisterReturn) +void MapReturn(sal_uInt32 r0, sal_uInt32 r1, typelib_TypeDescriptionReference * pReturnType, sal_uInt32* pRegisterReturn) { #if !defined(__ARM_EABI__) && !defined(__SOFTFP__) register float fret asm("f0"); @@ -160,32 +160,28 @@ void MapReturn(long r0, long r1, typelib_TypeDescriptionReference * pReturnType, { case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: - ((long*)pRegisterReturn)[1] = r1; + pRegisterReturn[1] = r1; case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: case typelib_TypeClass_ENUM: - ((long*)pRegisterReturn)[0] = r0; - break; case typelib_TypeClass_CHAR: case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: - *(unsigned short*)pRegisterReturn = (unsigned short)r0; - break; case typelib_TypeClass_BOOLEAN: case typelib_TypeClass_BYTE: - *(unsigned char*)pRegisterReturn = (unsigned char)r0; + pRegisterReturn[0] = r0; break; case typelib_TypeClass_FLOAT: #if defined(__ARM_EABI__) || defined(__SOFTFP__) - ((long*)pRegisterReturn)[0] = r0; + pRegisterReturn[0] = r0; #else *(float*)pRegisterReturn = fret; #endif break; case typelib_TypeClass_DOUBLE: #if defined(__ARM_EABI__) || defined(__SOFTFP__) - ((long*)pRegisterReturn)[1] = r1; - ((long*)pRegisterReturn)[0] = r0; + pRegisterReturn[1] = r1; + pRegisterReturn[0] = r0; #else *(double*)pRegisterReturn = dret; #endif @@ -194,7 +190,7 @@ void MapReturn(long r0, long r1, typelib_TypeDescriptionReference * pReturnType, case typelib_TypeClass_EXCEPTION: { if (!arm::return_in_hidden_param(pReturnType)) - ((long*)pRegisterReturn)[0] = r0; + pRegisterReturn[0] = r0; break; } default: @@ -260,7 +256,7 @@ void callVirtualMethod( "mov %1, r1\n\t" : "=r" (r0), "=r" (r1) : ); - MapReturn(r0, r1, pReturnType, pRegisterReturn); + MapReturn(r0, r1, pReturnType, (sal_uInt32*)pRegisterReturn); } } -- cgit From 442f8716115ad20f75aa3d456727fb51f790d31c Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 5 May 2010 11:41:41 +0100 Subject: fix for insert --- basctl/source/basicide/basides2.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index 831233e78068..bef969db9266 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -260,12 +260,15 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const { pWin = FindBasWin( rDocument, aLibName, aModName, FALSE, TRUE ); if( !pWin ) - { // new module window - pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule ); - nKey = InsertWindowInTable( pWin ); + { + // new module window + pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule ); + nKey = InsertWindowInTable( pWin ); + } + else // we've gotten called recursively ( via listener from createModule above ), get outta here + return pWin; } } - } else { pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED ); -- cgit From 6ddef091efca9cd67d93a806c2ec6303f47adc28 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Thu, 6 May 2010 13:02:31 +0100 Subject: npower13_objectmodules: #i111419# --- basctl/source/basicide/basides1.cxx | 1 - basctl/source/basicide/basidesh.cxx | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index e361a17ff578..40c78f7a4e81 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -109,7 +109,6 @@ void __EXPORT BasicIDEShell::ExecuteCurrent( SfxRequest& rReq ) { if ( aDocument.removeModule( aLibName, aName ) ) { - RemoveWindow( pCurWin, TRUE ); BasicIDE::MarkDocumentModified( aDocument ); } } diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index e22103e3503c..e170c4c7d0fa 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -107,7 +107,7 @@ public: try { uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, FALSE ), uno::UNO_QUERY ); - if ( rScriptDocument.isDocument() && xContainer.is() ) + if ( xContainer.is() ) { uno::Reference< container::XContainerListener > xContainerListener( this ); xContainer->addContainerListener( xContainerListener ); @@ -120,7 +120,7 @@ public: try { uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, FALSE ), uno::UNO_QUERY ); - if ( rScriptDocument.isDocument() && xContainer.is() ) + if ( xContainer.is() ) { uno::Reference< container::XContainerListener > xContainerListener( this ); xContainer->removeContainerListener( xContainerListener ); -- cgit From 3af4e14cffc410527601c268f5adc37a2a9d8144 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 6 May 2010 14:25:12 +0100 Subject: armeabi02: #i111427# fix without-java --- filter/source/config/tools/merge/pyAltFCFGMerge | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filter/source/config/tools/merge/pyAltFCFGMerge b/filter/source/config/tools/merge/pyAltFCFGMerge index faf9b9c34cb7..d9a974eb9fec 100755 --- a/filter/source/config/tools/merge/pyAltFCFGMerge +++ b/filter/source/config/tools/merge/pyAltFCFGMerge @@ -11,7 +11,7 @@ import sys, string, os.path -CFGFILE = "../../../../transex3/source/filter/merge/FCFGMerge.cfg" +CFGFILE = "../../../../l10ntools/source/filter/merge/FCFGMerge.cfg" PROP_XMLVERSION = "xmlversion" # // <= global cfg file PROP_XMLENCODING = "xmlencoding" # // <= global cfg file -- cgit From d6ea16e6223cfa718364b47589b359bac2dea968 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Fri, 7 May 2010 10:54:26 +0100 Subject: ab75: #i110417# add andreas's improvements and additionally don't clear previous err object data --- basic/source/classes/errobject.cxx | 59 +++++++++++++++----------- basic/source/classes/sb.cxx | 43 +++++++------------ basic/source/inc/errobject.hxx | 9 ++++ basic/source/inc/runtime.hxx | 5 ++- basic/source/runtime/methods.cxx | 32 ++++++++++----- basic/source/runtime/props.cxx | 18 +++++--- basic/source/runtime/runtime.cxx | 84 ++++++++++++++++++++++++++++---------- basic/source/runtime/stdobj.cxx | 8 +--- 8 files changed, 161 insertions(+), 97 deletions(-) diff --git a/basic/source/classes/errobject.cxx b/basic/source/classes/errobject.cxx index 406d6f9b1a0b..0ec0454e2bb5 100644 --- a/basic/source/classes/errobject.cxx +++ b/basic/source/classes/errobject.cxx @@ -43,10 +43,9 @@ class ErrObject : public ErrObjectImpl_BASE { rtl::OUString m_sHelpFile; rtl::OUString m_sSource; - rtl::OUString m_sDescription; + rtl::OUString m_sDescription; sal_Int32 m_nNumber; sal_Int32 m_nHelpContext; - bool mbIsInError; public: ErrObject(); @@ -68,6 +67,10 @@ public: virtual void SAL_CALL Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException); // XDefaultProperty virtual ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (uno::RuntimeException); + + // Helper method + void setData( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, + const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException); }; @@ -75,7 +78,7 @@ ErrObject::~ErrObject() { } -ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0), mbIsInError(false) +ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0) { } @@ -88,9 +91,9 @@ ErrObject::getNumber() throw (uno::RuntimeException) void SAL_CALL ErrObject::setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException) { -// m_nNumber = _number; - if ( !mbIsInError ) - Raise( uno::makeAny( _number ), uno::Any(), uno::Any(), uno::Any(), uno::Any() ); + pINST->setErrorVB( _number, String() ); + ::rtl::OUString _description = pINST->GetErrorMsg(); + setData( uno::makeAny( _number ), uno::Any(), uno::makeAny( _description ), uno::Any(), uno::Any() ); } ::sal_Int32 SAL_CALL @@ -154,23 +157,9 @@ ErrObject::Clear( ) throw (uno::RuntimeException) void SAL_CALL ErrObject::Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException) { - if ( !Number.hasValue() ) - throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference< uno::XInterface >() ); - mbIsInError = true; - Clear(); - Description >>= m_sDescription; - Source >>= m_sSource; - HelpFile >>= m_sHelpFile; - HelpContext >>= m_nHelpContext; - Number >>= m_nNumber; + setData( Number, Source, Description, HelpFile, HelpContext ); if ( m_nNumber ) - { - SbError n = StarBASIC::GetSfxFromVBError( m_nNumber ); - if ( !n ) - n = m_nNumber; // force orig number, probably should have a specific table of vb ( localized ) errors - pINST->Error( n, m_sDescription ); - } - mbIsInError = false; + pINST->ErrorVB( m_nNumber, m_sDescription ); } // XDefaultProperty @@ -181,13 +170,30 @@ ErrObject::getDefaultPropertyName( ) throw (uno::RuntimeException) return sDfltPropName; } +void ErrObject::setData( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) + throw (uno::RuntimeException) +{ + if ( !Number.hasValue() ) + throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference< uno::XInterface >() ); + Number >>= m_nNumber; + Description >>= m_sDescription; + Source >>= m_sSource; + HelpFile >>= m_sHelpFile; + HelpContext >>= m_nHelpContext; +} + // SbxErrObject -SbxErrObject::SbxErrObject( const String& rName, const Any& rUnoObj ): SbUnoObject( rName, rUnoObj ) +SbxErrObject::SbxErrObject( const String& rName, const Any& rUnoObj ) + : SbUnoObject( rName, rUnoObj ) + , m_pErrObject( NULL ) { OSL_TRACE("SbxErrObject::SbxErrObject ctor"); rUnoObj >>= m_xErr; if ( m_xErr.is() ) + { SetDfltProperty( uno::Reference< script::XDefaultProperty >( m_xErr, uno::UNO_QUERY_THROW )->getDefaultPropertyName() ) ; + m_pErrObject = static_cast< ErrObject* >( m_xErr.get() ); + } } SbxErrObject::~SbxErrObject() @@ -210,3 +216,10 @@ SbxErrObject::getErrObject() return pGlobErr; } +void SbxErrObject::setNumberAndDescription( ::sal_Int32 _number, const ::rtl::OUString& _description ) + throw (uno::RuntimeException) +{ + if( m_pErrObject != NULL ) + m_pErrObject->setData( uno::makeAny( _number ), uno::Any(), uno::makeAny( _description ), uno::Any(), uno::Any() ); +} + diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index b76453999212..946ecdd93d3c 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -1358,22 +1358,7 @@ BOOL StarBASIC::CError // Umsetzung des Codes fuer String-Transport in SFX-Error if( rMsg.Len() ) - { - // very confusing, even though MakeErrorText sets up the error text - // seems that this is not used ( if rMsg already has content ) - // In the case of VBA MakeErrorText also formats the error to be alittle more - // like vba ( adds an error number etc ) - if ( SbiRuntime::isVBAEnabled() && ( code == SbERR_BASIC_COMPAT ) ) - { - String aTmp = '\''; - aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() ); - aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") ); - aTmp += GetSbData()->aErrMsg.Len() ? GetSbData()->aErrMsg : rMsg; - code = (ULONG)*new StringErrorInfo( code, aTmp ); - } - else code = (ULONG)*new StringErrorInfo( code, String(rMsg) ); - } SetErrorData( code, l, c1, c2 ); GetSbData()->bCompiler = TRUE; @@ -1403,22 +1388,22 @@ BOOL StarBASIC::RTError( SbError code, const String& rMsg, USHORT l, USHORT c1, // Umsetzung des Codes fuer String-Transport in SFX-Error if( rMsg.Len() ) + { + // very confusing, even though MakeErrorText sets up the error text + // seems that this is not used ( if rMsg already has content ) + // In the case of VBA MakeErrorText also formats the error to be alittle more + // like vba ( adds an error number etc ) + if ( SbiRuntime::isVBAEnabled() && ( code == SbERR_BASIC_COMPAT ) ) { - // very confusing, even though MakeErrorText sets up the error text - // seems that this is not used ( if rMsg already has content ) - // In the case of VBA MakeErrorText also formats the error to be alittle more - // like vba ( adds an error number etc ) - if ( SbiRuntime::isVBAEnabled() && ( code == SbERR_BASIC_COMPAT ) ) - { - String aTmp = '\''; - aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() ); - aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") ); - aTmp += GetSbData()->aErrMsg.Len() ? GetSbData()->aErrMsg : rMsg; - code = (ULONG)*new StringErrorInfo( code, aTmp ); - } - else - code = (ULONG)*new StringErrorInfo( code, String(rMsg) ); + String aTmp = '\''; + aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() ); + aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") ); + aTmp += GetSbData()->aErrMsg.Len() ? GetSbData()->aErrMsg : rMsg; + code = (ULONG)*new StringErrorInfo( code, aTmp ); } + else + code = (ULONG)*new StringErrorInfo( code, String(rMsg) ); + } SetErrorData( code, l, c1, c2 ); if( GetSbData()->aErrHdl.IsSet() ) diff --git a/basic/source/inc/errobject.hxx b/basic/source/inc/errobject.hxx index 7a50d2435eb3..39e6e319caae 100644 --- a/basic/source/inc/errobject.hxx +++ b/basic/source/inc/errobject.hxx @@ -33,11 +33,20 @@ class SbxErrObject : public SbUnoObject { + class ErrObject* m_pErrObject; com::sun::star::uno::Reference< ooo::vba::XErrObject > m_xErr; + SbxErrObject( const String& aName_, const com::sun::star::uno::Any& aUnoObj_ ); ~SbxErrObject(); + + class ErrObject* getImplErrObject( void ) + { return m_pErrObject; } + public: static SbxVariableRef getErrObject(); static com::sun::star::uno::Reference< ooo::vba::XErrObject > getUnoErrObject(); + + void setNumberAndDescription( ::sal_Int32 _number, const ::rtl::OUString& _description ) + throw (com::sun::star::uno::RuntimeException); }; #endif diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index 4a3f38c51027..1d4f5ec41093 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -219,6 +219,8 @@ public: void Error( SbError ); // trappable Error void Error( SbError, const String& rMsg ); // trappable Error mit Message + void ErrorVB( sal_Int32 nVBNumber, const String& rMsg ); + void setErrorVB( sal_Int32 nVBNumber, const String& rMsg ); void FatalError( SbError ); // non-trappable Error void FatalError( SbError, const String& ); // non-trappable Error void Abort(); // Abbruch mit aktuellem Fehlercode @@ -441,10 +443,11 @@ public: SbiRuntime( SbModule*, SbMethod*, UINT32 ); ~SbiRuntime(); - void Error( SbError ); // Fehler setzen, falls != 0 + void Error( SbError, bool bVBATranslationAlreadyDone = false ); // Fehler setzen, falls != 0 void Error( SbError, const String& ); // Fehler setzen, falls != 0 void FatalError( SbError ); // Fehlerbehandlung=Standard, Fehler setzen void FatalError( SbError, const String& ); // Fehlerbehandlung=Standard, Fehler setzen + static sal_Int32 translateErrorToVba( SbError nError, String& rMsg ); void DumpPCode(); BOOL Step(); // Einzelschritt (ein Opcode) void Stop() { bRun = FALSE; } diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 0a5a2b1736dd..4f7c70d688ef 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -271,17 +271,27 @@ RTLFUNC(Error) else nErr = StarBASIC::GetSfxFromVBError( (USHORT)nCode ); } - pBasic->MakeErrorText( nErr, aErrorMsg ); - String tmpErrMsg( pBasic->GetErrorText() ); - // If this rtlfunc 'Error' passed a errcode the same as the active Err Objects's - // current err then return the description for the error message if it is set - // ( complicated isn't it ? ) - if ( SbiRuntime::isVBAEnabled() && rPar.Count() > 1 ); - { - com::sun::star::uno::Reference< ooo::vba::XErrObject > xErrObj( SbxErrObject::getUnoErrObject() ); - if ( xErrObj.is() && xErrObj->getNumber() == nCode && xErrObj->getDescription().getLength() ) - tmpErrMsg = xErrObj->getDescription(); - } + + bool bVBA = SbiRuntime::isVBAEnabled(); + String tmpErrMsg; + if( bVBA && aErrorMsg.Len() > 0 ) + { + tmpErrMsg = aErrorMsg; + } + else + { + pBasic->MakeErrorText( nErr, aErrorMsg ); + tmpErrMsg = pBasic->GetErrorText(); + } + // If this rtlfunc 'Error' passed a errcode the same as the active Err Objects's + // current err then return the description for the error message if it is set + // ( complicated isn't it ? ) + if ( bVBA && rPar.Count() > 1 ) + { + com::sun::star::uno::Reference< ooo::vba::XErrObject > xErrObj( SbxErrObject::getUnoErrObject() ); + if ( xErrObj.is() && xErrObj->getNumber() == nCode && xErrObj->getDescription().getLength() ) + tmpErrMsg = xErrObj->getDescription(); + } rPar.Get( 0 )->PutString( tmpErrMsg ); } } diff --git a/basic/source/runtime/props.cxx b/basic/source/runtime/props.cxx index 9b4b35f551e2..cec74444e7a2 100644 --- a/basic/source/runtime/props.cxx +++ b/basic/source/runtime/props.cxx @@ -31,6 +31,7 @@ #include "runtime.hxx" #include "stdobj.hxx" #include "rtlproto.hxx" +#include "errobject.hxx" // Properties und Methoden legen beim Get (bWrite = FALSE) den Returnwert @@ -50,14 +51,21 @@ RTLFUNC(Err) (void)pBasic; (void)bWrite; - if( bWrite ) + if( SbiRuntime::isVBAEnabled() ) { - INT32 nVal = rPar.Get( 0 )->GetLong(); - if( nVal <= 65535L ) - StarBASIC::Error( StarBASIC::GetSfxFromVBError( (USHORT) nVal ) ); + rPar.Get( 0 )->PutObject( SbxErrObject::getErrObject() ); } else - rPar.Get( 0 )->PutLong( StarBASIC::GetVBErrorCode( StarBASIC::GetErrBasic() ) ); + { + if( bWrite ) + { + INT32 nVal = rPar.Get( 0 )->GetLong(); + if( nVal <= 65535L ) + StarBASIC::Error( StarBASIC::GetSfxFromVBError( (USHORT) nVal ) ); + } + else + rPar.Get( 0 )->PutLong( StarBASIC::GetVBErrorCode( StarBASIC::GetErrBasic() ) ); + } } RTLFUNC(False) diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 761955f6e877..295bfaa7f185 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -45,6 +45,8 @@ #include "sbunoobj.hxx" #include "errobject.hxx" +using namespace ::com::sun::star; + bool SbiRuntime::isVBAEnabled() { bool result = false; @@ -423,6 +425,35 @@ void SbiInstance::Error( SbError n, const String& rMsg ) } } +void SbiInstance::ErrorVB( sal_Int32 nVBNumber, const String& rMsg ) +{ + if( !bWatchMode ) + { + SbError n = StarBASIC::GetSfxFromVBError( static_cast< USHORT >( nVBNumber ) ); + if ( !n ) + n = nVBNumber; // force orig number, probably should have a specific table of vb ( localized ) errors + + aErrorMsg = rMsg; + SbiRuntime::translateErrorToVba( n, aErrorMsg ); + + bool bVBATranslationAlreadyDone = true; + pRun->Error( SbERR_BASIC_COMPAT, bVBATranslationAlreadyDone ); + } +} + +void SbiInstance::setErrorVB( sal_Int32 nVBNumber, const String& rMsg ) +{ + SbError n = StarBASIC::GetSfxFromVBError( static_cast< USHORT >( nVBNumber ) ); + if( !n ) + n = nVBNumber; // force orig number, probably should have a specific table of vb ( localized ) errors + + aErrorMsg = rMsg; + SbiRuntime::translateErrorToVba( n, aErrorMsg ); + + nErr = n; +} + + void SbiInstance::FatalError( SbError n ) { pRun->FatalError( n ); @@ -792,33 +823,20 @@ BOOL SbiRuntime::Step() return bRun; } -void SbiRuntime::Error( SbError n ) +void SbiRuntime::Error( SbError n, bool bVBATranslationAlreadyDone ) { if( n ) { nError = n; - if ( isVBAEnabled() ) + if( isVBAEnabled() && !bVBATranslationAlreadyDone ) { String aMsg = pInst->GetErrorMsg(); - // If a message is defined use that ( in preference to - // the defined one for the error ) NB #TODO - // if there is an error defined it more than likely - // is not the one you want ( some are the same though ) - // we really need a new vba compatible error list - if ( !aMsg.Len() ) - { - // is the error number vb or ( sb ) - SbError nTmp = StarBASIC::GetSfxFromVBError( n ); - if ( !nTmp ) - nTmp = n; - StarBASIC::MakeErrorText( nTmp, aMsg ); - aMsg = StarBASIC::GetErrorText(); - if ( !aMsg.Len() ) // no message for err no. - // need localized resource here - aMsg = String( RTL_CONSTASCII_USTRINGPARAM("Internal Object Error:") ); - } - // no num? most likely then it *is* really a vba err - SbxErrObject::getUnoErrObject()->setNumber( ( StarBASIC::GetVBErrorCode( n ) == 0 ) ? n : StarBASIC::GetVBErrorCode( n ) ); + sal_Int32 nVBAErrorNumber = translateErrorToVba( nError, aMsg ); + SbxVariable* pSbxErrObjVar = SbxErrObject::getErrObject(); + SbxErrObject* pGlobErr = static_cast< SbxErrObject* >( pSbxErrObjVar ); + if( pGlobErr != NULL ) + pGlobErr->setNumberAndDescription( nVBAErrorNumber, aMsg ); + pInst->aErrorMsg = aMsg; nError = SbERR_BASIC_COMPAT; } @@ -854,6 +872,30 @@ void SbiRuntime::FatalError( SbError _errCode, const String& _details ) Error( _errCode, _details ); } +sal_Int32 SbiRuntime::translateErrorToVba( SbError nError, String& rMsg ) +{ + // If a message is defined use that ( in preference to + // the defined one for the error ) NB #TODO + // if there is an error defined it more than likely + // is not the one you want ( some are the same though ) + // we really need a new vba compatible error list + if ( !rMsg.Len() ) + { + // TEST, has to be vb here always + SbError nTmp = StarBASIC::GetSfxFromVBError( nError ); + DBG_ASSERT( nTmp, "No VB error!" ); + + StarBASIC::MakeErrorText( nError, rMsg ); + rMsg = StarBASIC::GetErrorText(); + if ( !rMsg.Len() ) // no message for err no, need localized resource here + rMsg = String( RTL_CONSTASCII_USTRINGPARAM("Internal Object Error:") ); + } + // no num? most likely then it *is* really a vba err + USHORT nVBErrorCode = StarBASIC::GetVBErrorCode( nError ); + sal_Int32 nVBAErrorNumber = ( nVBErrorCode == 0 ) ? nError : nVBErrorCode; + return nVBAErrorNumber; +} + ////////////////////////////////////////////////////////////////////////// // // Parameter, Locals, Caller diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index fd4cacc646d5..13bc8810144a 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -33,7 +33,6 @@ #include #include "rtlproto.hxx" #include "sbintern.hxx" -#include "errobject.hxx" // Das nArgs-Feld eines Tabelleneintrags ist wie folgt verschluesselt: // Zur Zeit wird davon ausgegangen, dass Properties keine Parameter @@ -231,7 +230,7 @@ static Methods aMethods[] = { { "EOF", SbxBOOL, 1 | _FUNCTION, RTLNAME(EOF),0 }, { "Channel", SbxINTEGER, 0,NULL,0 }, { "Erl", SbxLONG, _ROPROP, RTLNAME( Erl ),0 }, -{ "Err", SbxLONG, _RWPROP, RTLNAME( Err ),0 }, +{ "Err", SbxVARIANT, _RWPROP, RTLNAME( Err ),0 }, { "Error", SbxSTRING, 1 | _FUNCTION, RTLNAME( Error ),0 }, { "code", SbxLONG, 0,NULL,0 }, { "Exp", SbxDOUBLE, 1 | _FUNCTION, RTLNAME(Exp),0 }, @@ -653,11 +652,6 @@ SbiStdObject::~SbiStdObject() SbxVariable* SbiStdObject::Find( const String& rName, SbxClassType t ) { - // #TODO #FIXME hack for substituting ooo-basic Err with vba-ish - // ErrObject object - static String sErr( RTL_CONSTASCII_USTRINGPARAM("Err") ); - if ( SbiRuntime::isVBAEnabled() && rName.EqualsIgnoreCaseAscii( sErr ) ) - return SbxErrObject::getErrObject(); // Bereits eingetragen? SbxVariable* pVar = SbxObject::Find( rName, t ); if( !pVar ) -- cgit From c554ca32cb7f116516760546dcb80e5d8ba56352 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Fri, 7 May 2010 15:39:09 +0200 Subject: ab75: #i111453# Open storage file for reading only --- basic/source/uno/scriptcont.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index 096d497a4c50..620536304644 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -942,7 +942,7 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary try { xElementRootStorage = ::comphelper::OStorageHelper::GetStorageFromURL( aElementPath, - embed::ElementModes::READWRITE ); + embed::ElementModes::READ ); } catch( uno::Exception& ) { // TODO: error handling -- cgit From 3d877b87f36943b4e7c722f98638da2f144808ba Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 11 May 2010 11:10:53 +0200 Subject: ab75: #i110417# Fixed warning --- basic/source/runtime/runtime.cxx | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 basic/source/runtime/runtime.cxx diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx old mode 100644 new mode 100755 index 295bfaa7f185..9c591d4d4f7a --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -882,8 +882,10 @@ sal_Int32 SbiRuntime::translateErrorToVba( SbError nError, String& rMsg ) if ( !rMsg.Len() ) { // TEST, has to be vb here always +#ifdef DBG_UTIL SbError nTmp = StarBASIC::GetSfxFromVBError( nError ); DBG_ASSERT( nTmp, "No VB error!" ); +#endif StarBASIC::MakeErrorText( nError, rMsg ); rMsg = StarBASIC::GetErrorText(); -- cgit From 67edcd669363101648408035737f33c73c78da01 Mon Sep 17 00:00:00 2001 From: obo Date: Wed, 12 May 2010 10:45:45 +0200 Subject: obo48: #i109700# lucene indexer generates segments_n (n>3) files --- l10ntools/source/help/HelpIndexerTool.java | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/l10ntools/source/help/HelpIndexerTool.java b/l10ntools/source/help/HelpIndexerTool.java index 1245247c3c9a..2a49f964d48f 100644 --- a/l10ntools/source/help/HelpIndexerTool.java +++ b/l10ntools/source/help/HelpIndexerTool.java @@ -69,6 +69,7 @@ public class HelpIndexerTool String aModule = ""; String aTargetZipFileStr = ""; String aCfsName = ""; + String aSegmentName = ""; // Scan arguments boolean bLang = false; @@ -77,6 +78,7 @@ public class HelpIndexerTool boolean bSrcDir = false; boolean bOutput = false; boolean bCfsName = false; + boolean bSegmentName = false; int nArgCount = args.length; for( int i = 0 ; i < nArgCount ; i++ ) @@ -126,7 +128,7 @@ public class HelpIndexerTool } i++; } - else if( "-checkcfsname".equals(args[i]) ) + else if( "-checkcfsandsegname".equals(args[i]) ) { if( i + 1 < nArgCount ) { @@ -134,6 +136,17 @@ public class HelpIndexerTool bCfsName = true; } i++; + if( i + 1 < nArgCount ) + { + aSegmentName = "segments" + args[i + 1]; + bSegmentName = true; + } + i++; + if (!(bCfsName && bSegmentName)) + { + System.out.println("Usage: HelpIndexer -checkcfsandsegname _0 _3 (2 arguments needed)"); + System.exit( -1 ); + } } } @@ -173,12 +186,17 @@ public class HelpIndexerTool writer.close(); boolean bCfsFileOk = true; - if( bCfsName && !bExtensionMode && nRet != -1 ) + boolean bSegmentFileOk = true; + if( bCfsName && bSegmentName && !bExtensionMode && nRet != -1 ) { String aCompleteCfsFileName = aDirToZipStr + File.separator + aIndexDirName + File.separator + aCfsName; + String aCompleteSegmentFileName = aDirToZipStr + File.separator + aIndexDirName + File.separator + aSegmentName; File aCfsFile = new File( aCompleteCfsFileName ); + File aSegmentFile = new File( aCompleteSegmentFileName ); bCfsFileOk = aCfsFile.exists(); + bSegmentFileOk = aSegmentFile.exists(); System.out.println( "Checking cfs file " + aCfsName+ ": " + (bCfsFileOk ? "Found" : "Not found") ); + System.out.println( "Checking segment file " + aSegmentName+ ": " + (bSegmentFileOk ? "Found" : "Not found") ); } if( bExtensionMode ) @@ -194,7 +212,7 @@ public class HelpIndexerTool if( nRet == -1 ) deleteRecursively( aIndexDir ); - if( bCfsFileOk ) + if( bCfsFileOk && bSegmentFileOk ) System.out.println( "Zipping ..." ); File aDirToZipFile = new File( aDirToZipStr ); createZipFile( aDirToZipFile, aTargetZipFileStr ); @@ -207,6 +225,12 @@ public class HelpIndexerTool System.exit( -1 ); } + if( !bSegmentFileOk ) + { + System.out.println( "segment file check failed, terminating..." ); + System.exit( -1 ); + } + Date end = new Date(); if( !bExtensionMode ) System.out.println(end.getTime() - start.getTime() + " total milliseconds"); -- cgit From e5f7d2ba5749113bf392d95bf629d95b9f5ee2d6 Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Wed, 12 May 2010 11:27:30 +0200 Subject: npower13_objectmodules: #i110672 - Wrote automated test that found issue #i111553. Needed to enhance the treelist-tools to do fuzzy filename matching as the document can be readonly under certain conditions. --- .../framework/optional/f_basic_vba-compat.bas | 19 +-- .../includes/basic_vba-compat_thisworkbook.inc | 143 +++++++++++++++++++++ .../optional/input/vba-compat/vba-thisworkbook.xls | Bin 0 -> 39424 bytes .../tools/includes/optional/t_treelist_tools.inc | 10 ++ 4 files changed, 164 insertions(+), 8 deletions(-) create mode 100755 testautomation/framework/optional/includes/basic_vba-compat_thisworkbook.inc create mode 100644 testautomation/framework/optional/input/vba-compat/vba-thisworkbook.xls mode change 100644 => 100755 testautomation/global/tools/includes/optional/t_treelist_tools.inc diff --git a/testautomation/framework/optional/f_basic_vba-compat.bas b/testautomation/framework/optional/f_basic_vba-compat.bas index a4dc91b70aac..9a6f30d3e61d 100755 --- a/testautomation/framework/optional/f_basic_vba-compat.bas +++ b/testautomation/framework/optional/f_basic_vba-compat.bas @@ -33,15 +33,17 @@ sub main - use "framework\optional\includes\basic_vba-compat_import_nothing.inc" - use "framework\optional\includes\basic_vba-compat_import_disabled.inc" - use "framework\optional\includes\basic_vba-compat_import_enabled.inc" + 'use "framework\optional\includes\basic_vba-compat_import_nothing.inc" + 'use "framework\optional\includes\basic_vba-compat_import_disabled.inc" + 'use "framework\optional\includes\basic_vba-compat_import_enabled.inc" + use "framework\optional\includes\basic_vba-compat_thisworkbook.inc" - call hStatusIn( "framework" , "f_basic_vba-compat.bas" ) - call tBasicVBACompatImportNothing() - call tBasicVBACompatImportDisabled() - call tBasicVBACompatImportEnabled() - call hStatusOut() + 'call hStatusIn( "framework" , "f_basic_vba-compat.bas" ) + 'call tBasicVBACompatImportNothing() + 'call tBasicVBACompatImportDisabled() + 'call tBasicVBACompatImportEnabled() + call tBasicVBACompatThisWorkBook() + 'call hStatusOut() end sub @@ -55,6 +57,7 @@ sub LoadIncludeFiles use "global\tools\includes\optional\t_basic_organizer_tools.inc" use "global\tools\includes\optional\t_treelist_tools.inc" use "global\tools\includes\optional\t_stringtools.inc" + use "global\tools\includes\optional\t_macro_tools.inc" use "framework\optional\includes\basic_vba_compat_tools.inc" diff --git a/testautomation/framework/optional/includes/basic_vba-compat_thisworkbook.inc b/testautomation/framework/optional/includes/basic_vba-compat_thisworkbook.inc new file mode 100755 index 000000000000..03c52146a8fb --- /dev/null +++ b/testautomation/framework/optional/includes/basic_vba-compat_thisworkbook.inc @@ -0,0 +1,143 @@ +'encoding UTF-8 Do not remove or change this line! +'******************************************************************************* +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org 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 Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : joerg.skottke@sun.com +'* +'* short description : Test VBA compatibility switches +'* +'\****************************************************************************** + +testcase tBasicVBACompatThisWorkBook() + + printlog( "Functionality of .thisWorkbook" ) + ' Based on issue #i110672 + + const IMPORT_EXCEL_MACROS = TRUE + const EXEC_EXCEL_MACROS = TRUE + const DOCUMENT_NAME = "vba-thisworkbook.xls" + const LIBRARY_NAME = "Standard" + const MODULE_NAME = "Module1" + const EXPECTED_MACRO_COUNT = 2 + const MAX_REPEAT_COUNT = 2 + const MAX_WAIT = 2 + + dim macro_identifier( EXPECTED_MACRO_COUNT ) + macro_identifier( 1 ) = "Test 1 passed." + macro_identifier( 2 ) = "Test 2 passed." + + dim cTestFile as string + cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/" & DOCUMENT_NAME + + dim iMacroPosition as integer + dim iCurrentMacro as integer + dim iRepeat as integer + + printlog( "Set macro security to low" ) + hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW ) + + printlog( "Open Tools/Options" ) + hSetExcelBasicImportMode( IMPORT_EXCEL_MACROS, EXEC_EXCEL_MACROS ) + + printlog( "Load the test file" ) + hFileOpen( cTestFile ) + + printlog( "Execute the procedure twice to trigger issue 111553" ) + for iRepeat = 1 to MAX_REPEAT_COUNT + + ToolsMacro_uno + + kontext "Makro" + if ( Makro.exists( MAX_WAIT ) ) then + + iMacroPosition = hSelectNodeByName( MakroAus, DOCUMENT_NAME ) + hExpandNode( MakroAus, iMacroPosition ) + + printlog( "Move to node <" & LIBRARY_NAME & ">" ) + iMacroPosition = hSelectNextNode( MakroAus ) + if ( not hVerifyNodeName( MakroAus, LIBRARY_NAME ) ) then + warnlog( "This is not the expected library" ) + endif + + printlog( "Move to node <" & MODULE_NAME & ">" ) + hSelectNextNode( MakroAus ) + if ( not hVerifyNodeName( MakroAus, MODULE_NAME ) ) then + warnlog( "This is not the expected module" ) + endif + + printlog( "Click to execute the macro" ) + iMacroPosition = hClickButton( Ausfuehren ) + + printlog( "Check for two expected messageboxes" ) + for iCurrentMacro = 1 to EXPECTED_MACRO_COUNT + + kontext "Active" + printlog( "Check for messagebox: " & macro_identifier( iCurrentMacro ) ) + if ( Active.exists( MAX_WAIT ) ) then + + if ( Active.getText() = macro_identifier( iCurrentMacro ) ) then + printlog( "Correct macro executed" ) + else + printlog( "Macro execution error, trying to identify..." ) + if ( instr( Active.getText(), "BASIC runtime error." ) > 0 ) then + if ( iRepeat = MAX_REPEAT_COUNT ) then + warnlog( "#i111533 - Cannot execute ThisWorkbook macro twice" ) + Active.ok() + hFileCloseAll() + goto endsub + else + warnlog( "Executing macro failed" ) + goto endsub + endif + else + warnlog( "Unknown messagebox. Aborting test" ) + goto endsub + endif + endif + + Active.ok() + + else + warnlog( "Expected messagebox not displayed within reasonable timeframe" ) + goto endsub + endif + + next iCurrentMacro + else + warnlog( "A macro with the name <" & MODULE_NAME & "> could not be found" ) + goto endsub + endif + + next iRepeat + + printlog( "Cleanup" ) + hCloseDocument() + hSetExcelImportModeDefault() + hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT ) + +endcase + + diff --git a/testautomation/framework/optional/input/vba-compat/vba-thisworkbook.xls b/testautomation/framework/optional/input/vba-compat/vba-thisworkbook.xls new file mode 100644 index 000000000000..f275fd9cca0e Binary files /dev/null and b/testautomation/framework/optional/input/vba-compat/vba-thisworkbook.xls differ diff --git a/testautomation/global/tools/includes/optional/t_treelist_tools.inc b/testautomation/global/tools/includes/optional/t_treelist_tools.inc old mode 100644 new mode 100755 index b459b2c0f4a0..36cfe7370901 --- a/testautomation/global/tools/includes/optional/t_treelist_tools.inc +++ b/testautomation/global/tools/includes/optional/t_treelist_tools.inc @@ -356,6 +356,16 @@ function hSelectNodeByName( oControl as object , _name as string ) as integer iThisNode = iCurrentNode exit for endif + + if ( instr( cNodeName, _name ) > 0 ) then + if ( instr( cNodeName, "(" ) > 0 ) then + printlog( CFN & "Node has readonly marker" ) + iThisNode = iCurrentNode + exit for + else + qaerrorlog( CFN & "Fuzzy match. This might or might not be the correct node" ) + endif + endif next iCurrentNode endcatch -- cgit From eeb5df7198d067da77e4f885bf7c5eb36f98854f Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Wed, 12 May 2010 14:37:02 +0200 Subject: npower13_objectmodules: #i110724 - Created test case. I wonder if it works when run from our internal servers. There might be an issue with the accessrights. However, i then just need to update the Strings to check for. --- .../framework/optional/f_basic_vba-compat.bas | 18 +-- .../basic_vba-compat_application-union.inc | 126 +++++++++++++++++++++ .../input/vba-compat/vba-application-union.xls | Bin 0 -> 31744 bytes 3 files changed, 136 insertions(+), 8 deletions(-) create mode 100755 testautomation/framework/optional/includes/basic_vba-compat_application-union.inc create mode 100755 testautomation/framework/optional/input/vba-compat/vba-application-union.xls diff --git a/testautomation/framework/optional/f_basic_vba-compat.bas b/testautomation/framework/optional/f_basic_vba-compat.bas index 9a6f30d3e61d..6f4cbeba8da8 100755 --- a/testautomation/framework/optional/f_basic_vba-compat.bas +++ b/testautomation/framework/optional/f_basic_vba-compat.bas @@ -33,17 +33,19 @@ sub main - 'use "framework\optional\includes\basic_vba-compat_import_nothing.inc" - 'use "framework\optional\includes\basic_vba-compat_import_disabled.inc" - 'use "framework\optional\includes\basic_vba-compat_import_enabled.inc" + use "framework\optional\includes\basic_vba-compat_import_nothing.inc" + use "framework\optional\includes\basic_vba-compat_import_disabled.inc" + use "framework\optional\includes\basic_vba-compat_import_enabled.inc" use "framework\optional\includes\basic_vba-compat_thisworkbook.inc" + use "framework\optional\includes\basic_vba-compat_application-union.inc" - 'call hStatusIn( "framework" , "f_basic_vba-compat.bas" ) - 'call tBasicVBACompatImportNothing() - 'call tBasicVBACompatImportDisabled() - 'call tBasicVBACompatImportEnabled() + call hStatusIn( "framework" , "f_basic_vba-compat.bas" ) + call tBasicVBACompatImportNothing() + call tBasicVBACompatImportDisabled() + call tBasicVBACompatImportEnabled() call tBasicVBACompatThisWorkBook() - 'call hStatusOut() + call tBasicVBACompatApplicationUnion() + call hStatusOut() end sub diff --git a/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc b/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc new file mode 100755 index 000000000000..4f0ab6c11922 --- /dev/null +++ b/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc @@ -0,0 +1,126 @@ +'encoding UTF-8 Do not remove or change this line! +'******************************************************************************* +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org 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 Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : joerg.skottke@sun.com +'* +'* short description : Test VBA compatibility switches +'* +'\****************************************************************************** + +testcase tBasicVBACompatApplicationUnion() + + printlog( "Functionality of Application.Union" ) + ' Based on issue #i110724 + + const IMPORT_EXCEL_MACROS = TRUE + const EXEC_EXCEL_MACROS = TRUE + const DOCUMENT_NAME = "vba-application-union.xls" + const LIBRARY_NAME = "Standard" + const MODULE_NAME = "Module1" + const EXPECTED_MACRO_COUNT = 6 + const MAX_WAIT = 2 + + dim macro_identifier( EXPECTED_MACRO_COUNT ) + macro_identifier( 1 ) = "1: True" + macro_identifier( 2 ) = "2: True" + macro_identifier( 3 ) = "3: True" + macro_identifier( 4 ) = "4: True" + macro_identifier( 5 ) = "5: True" + macro_identifier( 6 ) = "6: True" + + dim cTestFile as string + cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/" & DOCUMENT_NAME + + dim iMacroPosition as integer + dim iCurrentMacro as integer + dim iRepeat as integer + + printlog( "Set macro security to low" ) + hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW ) + + printlog( "Open Tools/Options" ) + hSetExcelBasicImportMode( IMPORT_EXCEL_MACROS, EXEC_EXCEL_MACROS ) + + printlog( "Load the test file" ) + hFileOpen( cTestFile ) + + ToolsMacro_uno + + kontext "Makro" + if ( Makro.exists( MAX_WAIT ) ) then + + iMacroPosition = hSelectNodeByName( MakroAus, DOCUMENT_NAME ) + hExpandNode( MakroAus, iMacroPosition ) + + printlog( "Move to node <" & LIBRARY_NAME & ">" ) + iMacroPosition = hSelectNextNode( MakroAus ) + if ( not hVerifyNodeName( MakroAus, LIBRARY_NAME ) ) then + warnlog( "This is not the expected library" ) + endif + + printlog( "Move to node <" & MODULE_NAME & ">" ) + hSelectNextNode( MakroAus ) + if ( not hVerifyNodeName( MakroAus, MODULE_NAME ) ) then + warnlog( "This is not the expected module" ) + endif + + printlog( "Click to execute the macro" ) + iMacroPosition = hClickButton( Ausfuehren ) + + printlog( "Check for the " & EXPECTED_MACRO_COUNT & " expected messageboxes" ) + for iCurrentMacro = 1 to EXPECTED_MACRO_COUNT + + kontext "Active" + printlog( iCurrentMacro & ": Check for messagebox: " & macro_identifier( iCurrentMacro ) ) + if ( Active.exists( MAX_WAIT ) ) then + + if ( Active.getText() = macro_identifier( iCurrentMacro ) ) then + printlog( "The expected macro was executed" ) + else + warnlog( "Unexpected macro executed: " & Active.getText() ) + printlog( Active.getText() ) + endif + Active.ok() + + else + warnlog( "Expected messagebox not displayed within reasonable timeframe" ) + goto endsub + endif + + next iCurrentMacro + else + warnlog( "Failed to open BASIC organizer" ) + endif + + printlog( "Cleanup" ) + hCloseDocument() + hSetExcelImportModeDefault() + hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT ) + +endcase + + diff --git a/testautomation/framework/optional/input/vba-compat/vba-application-union.xls b/testautomation/framework/optional/input/vba-compat/vba-application-union.xls new file mode 100755 index 000000000000..b1f1be816b7b Binary files /dev/null and b/testautomation/framework/optional/input/vba-compat/vba-application-union.xls differ -- cgit From b53b7f648f0e84d1972dbfffe5c56bf037cd06c3 Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Mon, 17 May 2010 13:04:20 +0200 Subject: npower13_objectmodules: #i111007, #110724 - Provided test case (which is as of yet untested because the issues that are tested herein are not yet fixed) --- .../framework/optional/f_basic_vba-compat.bas | 2 + .../includes/basic_vba-compat_xlsm-xlsb.inc | 129 +++++++++++++++++++++ .../optional/input/vba-compat/vba-project.xlsb | Bin 0 -> 19603 bytes .../optional/input/vba-compat/vba-project.xlsm | Bin 0 -> 20276 bytes 4 files changed, 131 insertions(+) create mode 100755 testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc create mode 100755 testautomation/framework/optional/input/vba-compat/vba-project.xlsb create mode 100755 testautomation/framework/optional/input/vba-compat/vba-project.xlsm diff --git a/testautomation/framework/optional/f_basic_vba-compat.bas b/testautomation/framework/optional/f_basic_vba-compat.bas index 6f4cbeba8da8..9b102496591f 100755 --- a/testautomation/framework/optional/f_basic_vba-compat.bas +++ b/testautomation/framework/optional/f_basic_vba-compat.bas @@ -38,6 +38,7 @@ sub main use "framework\optional\includes\basic_vba-compat_import_enabled.inc" use "framework\optional\includes\basic_vba-compat_thisworkbook.inc" use "framework\optional\includes\basic_vba-compat_application-union.inc" + use "framework\optional\includes\basic_vba-compat_xlsm-xlsb.inc" call hStatusIn( "framework" , "f_basic_vba-compat.bas" ) call tBasicVBACompatImportNothing() @@ -45,6 +46,7 @@ sub main call tBasicVBACompatImportEnabled() call tBasicVBACompatThisWorkBook() call tBasicVBACompatApplicationUnion() + call tBasicVBACompatXLSM_XLSB() call hStatusOut() end sub diff --git a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc new file mode 100755 index 000000000000..825afe5d581e --- /dev/null +++ b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc @@ -0,0 +1,129 @@ +'encoding UTF-8 Do not remove or change this line! +'******************************************************************************* +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org 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 Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : joerg.skottke@sun.com +'* +'* short description : Test VBA compatibility switches +'* +'\****************************************************************************** + +testcase tBasicVBACompatXLSM_XLSB() + + printlog( "Functionality of macros in XLSM/XLSB files" ) + ' Based on issue #i110672 + + const IMPORT_EXCEL_MACROS = TRUE + const EXEC_EXCEL_MACROS = TRUE + + const FILE_COUNT = 2 + const MODULE_COUNT = 7 + + const MODULE_NOT_FOUND = 0 + const MAX_DELAY = 3 + + const RELATIVE_PATH = "framework/optional/input/vba-compat/" + + ' We have two files to load, on e .xlsm and one .xlsb + dim cFileList( FILE_COUNT ) as string + cFileList( 1 ) = "vba-project.xlsm" + cFileList( 2 ) = "vba-project.xlsb" + + ' both documents import the same modules + dim cTestModuleList( MODULE_COUNT ) + cTestModuleList( 1 ) = "MyChartModule" + cTestModuleList( 2 ) = "MyCodeModule" + cTestModuleList( 3 ) = "MyPrivateClassModule" + cTestModuleList( 4 ) = "MyPublicClassModule" + cTestModuleList( 5 ) = "MySheetModule" + cTestModuleList( 6 ) = "MyUserForm" + cTestModuleList( 7 ) = "MyWorkbookModule" + + dim cTestFile as string + dim iCurrentFile as integer + dim iCurrentModule as integer + + printlog( "Set macro security to low" ) + hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW ) + + printlog( "Open Tools/Options" ) + hSetExcelBasicImportMode( IMPORT_EXCEL_MACROS, EXEC_EXCEL_MACROS ) + + for iCurrentFile = 1 to FILE_COUNT + + cTestFile = gTesttoolPath & RELATIVE_PATH & cFileList( iCurrentFile ) + + printlog( "Loading document: " & cTestFile ) + hFileOpen( cTestFile ) + + for iCurrentModule = 1 to MODULE_COUNT + + printlog( "Tryng to execute macro: " & cTestModuleList( iCurrentModule ) ) + ToolsMacro_uno + + kontext "Makro" + if ( Makro.exists( MAX_DELAY ) ) then + + if ( hSelectNodeByName( MakroAus, cTestModuleList( iCurrentModule ) ) <> MODULE_NOT_FOUND ) then + + printlog( "Execute the default macro for the current module" ) + Ausfuehren.click() + + kontext "Active" + printlog( "Probe for messagebox containing the module name" ) + if ( Active.exists( MAX_DELAY ) ) then + + if ( Active.getText() = cTestModuleList( iCurrentModule ) ) then + printlog( "The correct macro has been executed: " & cTestModuleList( iCurrentModule ) + else + warnlog( "Incorrect macro executed:" ) + printlog( "Expected: " & cTestModuleList( iCurrentModule ) ) + printlog( "Found...: " & Active.getText() ) + endif + + else + warnlog( "Macro was not executed" ) + endif + else + warnlog( "the expected macro module could not be found" ) + endif + else + warnlog( "BASIC Macro organizer did not open" ) + endif + + next iCurrentModule + + printlog( "Close the document" ) + hFileClose() + + next iCurrentFile + + hSetExcelImportModeDefault() + hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT ) + +endcase + + diff --git a/testautomation/framework/optional/input/vba-compat/vba-project.xlsb b/testautomation/framework/optional/input/vba-compat/vba-project.xlsb new file mode 100755 index 000000000000..9fd88a8e545c Binary files /dev/null and b/testautomation/framework/optional/input/vba-compat/vba-project.xlsb differ diff --git a/testautomation/framework/optional/input/vba-compat/vba-project.xlsm b/testautomation/framework/optional/input/vba-compat/vba-project.xlsm new file mode 100755 index 000000000000..6a8896e18599 Binary files /dev/null and b/testautomation/framework/optional/input/vba-compat/vba-project.xlsm differ -- cgit From 44f143f6d07761ef859028ff7d7df23c82871b27 Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Mon, 17 May 2010 13:10:34 +0200 Subject: npower13_objectmodules: #i110724 - Changed logging slightly because some of the printings where confusing as it duplicated some errormessages making it hard to tell which one was relevant --- .../framework/optional/includes/basic_vba-compat_application-union.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc b/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc index 4f0ab6c11922..7f57bc89130e 100755 --- a/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc @@ -94,6 +94,7 @@ testcase tBasicVBACompatApplicationUnion() printlog( "Check for the " & EXPECTED_MACRO_COUNT & " expected messageboxes" ) for iCurrentMacro = 1 to EXPECTED_MACRO_COUNT + printlog( "" ) kontext "Active" printlog( iCurrentMacro & ": Check for messagebox: " & macro_identifier( iCurrentMacro ) ) if ( Active.exists( MAX_WAIT ) ) then @@ -102,7 +103,6 @@ testcase tBasicVBACompatApplicationUnion() printlog( "The expected macro was executed" ) else warnlog( "Unexpected macro executed: " & Active.getText() ) - printlog( Active.getText() ) endif Active.ok() -- cgit From 57856accd784aa87fb7b72585c5be5626fe33f7f Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Mon, 17 May 2010 13:31:30 +0200 Subject: npower13_objectmodules: #i111007 - Need to close messagebox after identification --- .../framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc index 825afe5d581e..888bc3402f95 100755 --- a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc @@ -103,7 +103,8 @@ testcase tBasicVBACompatXLSM_XLSB() printlog( "Expected: " & cTestModuleList( iCurrentModule ) ) printlog( "Found...: " & Active.getText() ) endif - + Active.ok() + WaitSlot() else warnlog( "Macro was not executed" ) endif -- cgit From 4d2c2b749c5c352f7087afd521e565cc88c3a33f Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Mon, 17 May 2010 13:36:12 +0200 Subject: npower13_objectmodules: #i111007 - Add timeout to button. --- .../includes/basic_vba-compat_xlsm-xlsb.inc | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc index 888bc3402f95..89a09468ea27 100755 --- a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc @@ -44,6 +44,7 @@ testcase tBasicVBACompatXLSM_XLSB() const MODULE_NOT_FOUND = 0 const MAX_DELAY = 3 + const RC_TIMEOUT = -1 const RELATIVE_PATH = "framework/optional/input/vba-compat/" @@ -90,23 +91,27 @@ testcase tBasicVBACompatXLSM_XLSB() if ( hSelectNodeByName( MakroAus, cTestModuleList( iCurrentModule ) ) <> MODULE_NOT_FOUND ) then printlog( "Execute the default macro for the current module" ) - Ausfuehren.click() - kontext "Active" - printlog( "Probe for messagebox containing the module name" ) - if ( Active.exists( MAX_DELAY ) ) then - - if ( Active.getText() = cTestModuleList( iCurrentModule ) ) then - printlog( "The correct macro has been executed: " & cTestModuleList( iCurrentModule ) + if ( hClickButton( Ausfuehren ) > RC_TIMEOUT ) then + + kontext "Active" + printlog( "Probe for messagebox containing the module name" ) + if ( Active.exists( MAX_DELAY ) ) then + + if ( Active.getText() = cTestModuleList( iCurrentModule ) ) then + printlog( "The correct macro has been executed: " & cTestModuleList( iCurrentModule ) + else + warnlog( "Incorrect macro executed:" ) + printlog( "Expected: " & cTestModuleList( iCurrentModule ) ) + printlog( "Found...: " & Active.getText() ) + endif + Active.ok() + WaitSlot() else - warnlog( "Incorrect macro executed:" ) - printlog( "Expected: " & cTestModuleList( iCurrentModule ) ) - printlog( "Found...: " & Active.getText() ) + warnlog( "Macro was not executed" ) endif - Active.ok() - WaitSlot() else - warnlog( "Macro was not executed" ) + warnlog( "No executable macro found for the current module / button is disabled" ) endif else warnlog( "the expected macro module could not be found" ) -- cgit From e6f2d72f070caeb486f5bc8dd6d30d7a9e9d7525 Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Mon, 17 May 2010 13:57:18 +0200 Subject: npower13_objectmodules: #i111007 - The test macros deliver slightly unexpected verification strings which requires a second list to be maintained which holds the verification strings (in addition to the list of modules). This is bad but the nicer fix would require to checkin another version of a binary file which i prefer to avoid. --- .../optional/includes/basic_vba-compat_xlsm-xlsb.inc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc index 89a09468ea27..a90e77561704 100755 --- a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc @@ -34,7 +34,7 @@ testcase tBasicVBACompatXLSM_XLSB() printlog( "Functionality of macros in XLSM/XLSB files" ) - ' Based on issue #i110672 + ' Based on issue #i111007 const IMPORT_EXCEL_MACROS = TRUE const EXEC_EXCEL_MACROS = TRUE @@ -63,6 +63,15 @@ testcase tBasicVBACompatXLSM_XLSB() cTestModuleList( 6 ) = "MyUserForm" cTestModuleList( 7 ) = "MyWorkbookModule" + dim cTestVerificationStrings( MODULE_COUNT ) + cTestVerificationStrings( 1 ) = "MyChartModule" + cTestVerificationStrings( 2 ) = "MyCodeModule" + cTestVerificationStrings( 3 ) = "MyPrivateClassModule" + cTestVerificationStrings( 4 ) = "MyPublicClassModule" + cTestVerificationStrings( 5 ) = "MySheetModule" + cTestVerificationStrings( 6 ) = "MyUserForm initialized" + cTestVerificationStrings( 7 ) = "MyUserForm" + dim cTestFile as string dim iCurrentFile as integer dim iCurrentModule as integer @@ -98,11 +107,11 @@ testcase tBasicVBACompatXLSM_XLSB() printlog( "Probe for messagebox containing the module name" ) if ( Active.exists( MAX_DELAY ) ) then - if ( Active.getText() = cTestModuleList( iCurrentModule ) ) then - printlog( "The correct macro has been executed: " & cTestModuleList( iCurrentModule ) + if ( Active.getText() = cTestVerificationStrings( iCurrentModule ) ) then + printlog( "The correct macro has been executed: " & cTestVerificationStrings( iCurrentModule ) else warnlog( "Incorrect macro executed:" ) - printlog( "Expected: " & cTestModuleList( iCurrentModule ) ) + printlog( "Expected: " & cTestVerificationStrings( iCurrentModule ) ) printlog( "Found...: " & Active.getText() ) endif Active.ok() @@ -123,7 +132,7 @@ testcase tBasicVBACompatXLSM_XLSB() next iCurrentModule printlog( "Close the document" ) - hFileClose() + hFileCloseAll() next iCurrentFile -- cgit From b9468485ff8bb120ea01651ec28dd753eac1cb1b Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Mon, 17 May 2010 13:58:17 +0200 Subject: npower13_objectmodules: #i110724 - hClickButton() has a returnvalue which should be evaluated. --- .../basic_vba-compat_application-union.inc | 40 +++++++++++++--------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc b/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc index 7f57bc89130e..222b99215f81 100755 --- a/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_application-union.inc @@ -43,6 +43,7 @@ testcase tBasicVBACompatApplicationUnion() const MODULE_NAME = "Module1" const EXPECTED_MACRO_COUNT = 6 const MAX_WAIT = 2 + const RC_FAILURE = -1 dim macro_identifier( EXPECTED_MACRO_COUNT ) macro_identifier( 1 ) = "1: True" @@ -89,29 +90,34 @@ testcase tBasicVBACompatApplicationUnion() endif printlog( "Click to execute the macro" ) - iMacroPosition = hClickButton( Ausfuehren ) + if ( hClickButton( Ausfuehren ) <> RC_FAILURE ) then - printlog( "Check for the " & EXPECTED_MACRO_COUNT & " expected messageboxes" ) - for iCurrentMacro = 1 to EXPECTED_MACRO_COUNT + printlog( "Check for the " & EXPECTED_MACRO_COUNT & " expected messageboxes" ) + for iCurrentMacro = 1 to EXPECTED_MACRO_COUNT - printlog( "" ) - kontext "Active" - printlog( iCurrentMacro & ": Check for messagebox: " & macro_identifier( iCurrentMacro ) ) - if ( Active.exists( MAX_WAIT ) ) then + printlog( "" ) + kontext "Active" + printlog( iCurrentMacro & ": Check for messagebox: " & macro_identifier( iCurrentMacro ) ) + if ( Active.exists( MAX_WAIT ) ) then + + if ( Active.getText() = macro_identifier( iCurrentMacro ) ) then + printlog( "The expected macro was executed" ) + else + warnlog( "Unexpected macro executed: " & Active.getText() ) + endif + Active.ok() - if ( Active.getText() = macro_identifier( iCurrentMacro ) ) then - printlog( "The expected macro was executed" ) else - warnlog( "Unexpected macro executed: " & Active.getText() ) + warnlog( "Expected messagebox not displayed within reasonable timeframe" ) + goto endsub endif - Active.ok() - - else - warnlog( "Expected messagebox not displayed within reasonable timeframe" ) - goto endsub - endif - next iCurrentMacro + next iCurrentMacro + else + warnlog( "Unable to execute macro, the button is disabled" ) + kontext "Makro" + Makro.close() + endif else warnlog( "Failed to open BASIC organizer" ) endif -- cgit From ac07edec79149c8e90846b8a794a893e91c65c0d Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 17 May 2010 14:10:13 +0200 Subject: npower13_objectmodules: #i111007# do not close output stream of tempfile for OLE storage too early --- oox/source/dump/oledumper.cxx | 2 +- oox/source/ole/olestorage.cxx | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx index 4e358801a513..cc49ee050ea6 100644 --- a/oox/source/dump/oledumper.cxx +++ b/oox/source/dump/oledumper.cxx @@ -942,7 +942,7 @@ void ComCtlTreeViewObject::implDumpProperties() mnStringFlags = dumpHex< sal_uInt32 >( "string-flags", "COMCTL-TREEVIEW-STRINGFLAGS" ); } -void ComCtlTreeViewObject::implDumpCommonExtra( sal_Int64 nEndPos ) +void ComCtlTreeViewObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ ) { dumpOleColor( "text-color" ); dumpOleColor( "back-color" ); diff --git a/oox/source/ole/olestorage.cxx b/oox/source/ole/olestorage.cxx index 39ecbb84a062..0ca2992d47ad 100755 --- a/oox/source/ole/olestorage.cxx +++ b/oox/source/ole/olestorage.cxx @@ -252,8 +252,11 @@ void OleStorage::initStorage( const Reference< XInputStream >& rxInStream ) Reference< XStream > xTempFile( mxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TempFile" ) ), UNO_QUERY_THROW ); { Reference< XOutputStream > xOutStrm( xTempFile->getOutputStream(), UNO_SET_THROW ); - BinaryXOutputStream aOutStrm( xOutStrm, true ); // true = close output stream on destruction of aOutStrm - BinaryXInputStream aInStrm( xInStrm, false ); // false = do not close intput stream on destruction of aInStrm + /* Pass false to both binary stream objects to keep the UNO + streams alive. Life time of these streams is controlled by the + tempfile implementation. */ + BinaryXOutputStream aOutStrm( xOutStrm, false ); + BinaryXInputStream aInStrm( xInStrm, false ); aInStrm.copyToStream( aOutStrm ); } // scope closes output stream of tempfile xInStrm = xTempFile->getInputStream(); -- cgit From 3153efba3a79e0488c328f839240e08d31efdb6a Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Mon, 17 May 2010 14:45:57 +0200 Subject: npower13_objectmodules: #i111007 - One of the macros triggers two messages. Additionally we only have a fuzzy match then. Make my day. --- .../includes/basic_vba-compat_xlsm-xlsb.inc | 92 ++++++++++++++++------ 1 file changed, 67 insertions(+), 25 deletions(-) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc index a90e77561704..365fc3b073d5 100755 --- a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc @@ -45,6 +45,8 @@ testcase tBasicVBACompatXLSM_XLSB() const MODULE_NOT_FOUND = 0 const MAX_DELAY = 3 const RC_TIMEOUT = -1 + + const THE_MODULE_THAT_BEHAVES_DIFFERENTLY = 6 const RELATIVE_PATH = "framework/optional/input/vba-compat/" @@ -63,15 +65,6 @@ testcase tBasicVBACompatXLSM_XLSB() cTestModuleList( 6 ) = "MyUserForm" cTestModuleList( 7 ) = "MyWorkbookModule" - dim cTestVerificationStrings( MODULE_COUNT ) - cTestVerificationStrings( 1 ) = "MyChartModule" - cTestVerificationStrings( 2 ) = "MyCodeModule" - cTestVerificationStrings( 3 ) = "MyPrivateClassModule" - cTestVerificationStrings( 4 ) = "MyPublicClassModule" - cTestVerificationStrings( 5 ) = "MySheetModule" - cTestVerificationStrings( 6 ) = "MyUserForm initialized" - cTestVerificationStrings( 7 ) = "MyUserForm" - dim cTestFile as string dim iCurrentFile as integer dim iCurrentModule as integer @@ -91,6 +84,7 @@ testcase tBasicVBACompatXLSM_XLSB() for iCurrentModule = 1 to MODULE_COUNT + printlog( "" ) printlog( "Tryng to execute macro: " & cTestModuleList( iCurrentModule ) ) ToolsMacro_uno @@ -101,23 +95,13 @@ testcase tBasicVBACompatXLSM_XLSB() printlog( "Execute the default macro for the current module" ) - if ( hClickButton( Ausfuehren ) > RC_TIMEOUT ) then - - kontext "Active" - printlog( "Probe for messagebox containing the module name" ) - if ( Active.exists( MAX_DELAY ) ) then - - if ( Active.getText() = cTestVerificationStrings( iCurrentModule ) ) then - printlog( "The correct macro has been executed: " & cTestVerificationStrings( iCurrentModule ) - else - warnlog( "Incorrect macro executed:" ) - printlog( "Expected: " & cTestVerificationStrings( iCurrentModule ) ) - printlog( "Found...: " & Active.getText() ) - endif - Active.ok() - WaitSlot() + if ( hClickButton( Ausfuehren ) <> RC_TIMEOUT ) then + if ( iCurrentModule = THE_MODULE_THAT_BEHAVES_DIFFERENTLY ) then + ' Fuzzy matching message string + hTestMacroType2( cTestModuleList( iCurrentModule ) ) else - warnlog( "Macro was not executed" ) + ' Exact matching message string + hTestMacroType1( cTestModuleList( iCurrentModule ) ) endif else warnlog( "No executable macro found for the current module / button is disabled" ) @@ -141,4 +125,62 @@ testcase tBasicVBACompatXLSM_XLSB() endcase +'******************************************************************************* + +function hTestMacroType1( cMessage as string ) as boolean + + ' exact matching + + kontext "Active" + if ( Active.exists( 2 ) ) then + if ( Active.getText() = cMessage ) then + printlog( "Correct macro has been executed" ) + hTestMacroType1() = true + else + warnlog( "Incorrect macro executed: " ) + printlog( "Expected: " & cMessage ) + printlog( "Found...: " & Active.getText() ) + hTestMacroType1() = false + endif + + Active.ok() + WaitSlot() + + else + warnlog( "Messagebox missing, macro was not executed" ) + hTestMacroType1() = false + endif + +end function + +'******************************************************************************* + +function hTestMacroType2( cMessage as string ) as boolean + + ' fuzzy matching + + dim iCurrentMessage as integer + + for iCurrentMessage = 1 to 2 + + kontext "Active" + if ( Active.exists( 2 ) ) then + if ( if ( instr( Active.getText() , cMessage ) > 0 ) then + printlog( "Correct macro has been executed" ) + hTestMacroType2() = true + else + warnlog( "Incorrect macro executed: " ) + printlog( "Expected: " & cMessage ) + printlog( "Found...: " & Active.getText() ) + hTestMacroType2() = false + endif + + Active.ok() + WaitSlot() + + else + warnlog( "Messagebox missing, macro not executed" ) + hTestMacroType2() = false + endif +end function \ No newline at end of file -- cgit From ef1021b6f38ad92d1f9adad7dd19b6e908d2ecb5 Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Mon, 17 May 2010 16:41:30 +0200 Subject: npower13_objectmodules: #i111007 - Just some more fixes --- .../framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc index 365fc3b073d5..cfc8f06072e3 100755 --- a/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_xlsm-xlsb.inc @@ -165,7 +165,7 @@ function hTestMacroType2( cMessage as string ) as boolean kontext "Active" if ( Active.exists( 2 ) ) then - if ( if ( instr( Active.getText() , cMessage ) > 0 ) then + if ( instr( Active.getText() , cMessage ) > 0 ) then printlog( "Correct macro has been executed" ) hTestMacroType2() = true else @@ -182,5 +182,6 @@ function hTestMacroType2( cMessage as string ) as boolean warnlog( "Messagebox missing, macro not executed" ) hTestMacroType2() = false endif + next iCurrentMessage end function \ No newline at end of file -- cgit From 8c4bcfd63d6f473d67b4e2138676092aa313673d Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 18 May 2010 11:36:28 +0200 Subject: ab75: #110417# Added dependency to oovbaapi --- basic/prj/build.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 basic/prj/build.lst diff --git a/basic/prj/build.lst b/basic/prj/build.lst old mode 100644 new mode 100755 index 994901580c86..2cd1d3dc0466 --- a/basic/prj/build.lst +++ b/basic/prj/build.lst @@ -1,4 +1,4 @@ -sb basic : l10n offuh svtools xmlscript framework NULL +sb basic : l10n offuh oovbaapi svtools xmlscript framework NULL sb basic usr1 - all sb_mkout NULL sb basic\inc nmake - all sb_inc NULL sb basic\source\app nmake - all sb_app sb_class sb_inc NULL -- cgit From 34813c1b45edec0aeaf2a04f8d4741712b02af78 Mon Sep 17 00:00:00 2001 From: Ingo Schmidt Date: Fri, 21 May 2010 10:20:45 +0200 Subject: #162191# unopkg writes ERROR into log file --- solenv/bin/modules/installer/simplepackage.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/solenv/bin/modules/installer/simplepackage.pm b/solenv/bin/modules/installer/simplepackage.pm index 08f6eacf9e24..314bcef64ee2 100644 --- a/solenv/bin/modules/installer/simplepackage.pm +++ b/solenv/bin/modules/installer/simplepackage.pm @@ -148,12 +148,15 @@ sub register_extensions } close (UNOPKG); - for ( my $j = 0; $j <= $#unopkgoutput; $j++ ) { push( @installer::globals::logfileinfo, "$unopkgoutput[$j]"); } - my $returnvalue = $?; # $? contains the return value of the systemcall if ($returnvalue) { + # Writing content of @unopkgoutput only in the error case into the log file. Sometimes it + # contains strings like "Error" even in the case of success. This causes a packaging error + # when the log file is analyzed at the end, even if there is no real error. + for ( my $j = 0; $j <= $#unopkgoutput; $j++ ) { push( @installer::globals::logfileinfo, "$unopkgoutput[$j]"); } + $infoline = "ERROR: Could not execute \"$systemcall\"!\nExitcode: '$returnvalue'\n"; push( @installer::globals::logfileinfo, $infoline); installer::exiter::exit_program("ERROR: $systemcall failed!", "register_extensions"); -- cgit From fcb30d8748933b47cf796b86c19aceb44defccad Mon Sep 17 00:00:00 2001 From: Ingo Schmidt Date: Fri, 21 May 2010 11:45:08 +0200 Subject: #i111725# names for download files --- instsetoo_native/util/openoffice.lst | 2 -- 1 file changed, 2 deletions(-) diff --git a/instsetoo_native/util/openoffice.lst b/instsetoo_native/util/openoffice.lst index 5ce50111d519..30da95e51c97 100644 --- a/instsetoo_native/util/openoffice.lst +++ b/instsetoo_native/util/openoffice.lst @@ -213,7 +213,6 @@ OpenOffice_Dev PACKAGEREVISION {milestone} LICENSENAME LGPL SERVICESPROJEKT 1 - WITHJREPRODUCT 1 GLOBALFILEGID gid_File_Lib_Vcl GLOBALPATCHFILEGID gid_File_Txt_Patchfiles SPELLCHECKERFILE spellchecker_selection.txt @@ -565,7 +564,6 @@ BrOffice_Dev PACKAGEREVISION {milestone} LICENSENAME LGPL SERVICESPROJEKT 1 - WITHJREPRODUCT 1 SETSTATICPATH 1 GLOBALFILEGID gid_File_Lib_Vcl GLOBALPATCHFILEGID gid_File_Txt_Patchfiles -- cgit From 7a0b82b2e808926d776341670a97eecfa6c2c1f4 Mon Sep 17 00:00:00 2001 From: Ingo Schmidt Date: Fri, 21 May 2010 11:46:05 +0200 Subject: #i111725# logging into correct log file --- solenv/bin/modules/installer/scriptitems.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solenv/bin/modules/installer/scriptitems.pm b/solenv/bin/modules/installer/scriptitems.pm index ecda4f9a4e0b..cee8b1e0cfe8 100644 --- a/solenv/bin/modules/installer/scriptitems.pm +++ b/solenv/bin/modules/installer/scriptitems.pm @@ -1880,7 +1880,7 @@ sub remove_Languagepacklibraries_from_Installset } $infoline = "\n"; - push( @installer::globals::globallogfileinfo, $infoline); + push( @installer::globals::logfileinfo, $infoline); return \@newitemsarray; } -- cgit From c97d52ec74f2129b7c6cb3e1506fbebe02c27e30 Mon Sep 17 00:00:00 2001 From: "Joerg Skottke [jsk]" Date: Fri, 21 May 2010 14:22:21 +0200 Subject: npower13_objectmodules: Fix incorrect merges --- testautomation/framework/optional/f_basic_vba-compat.bas | 6 ------ .../optional/includes/basic_vba-compat_import_disabled.inc | 9 --------- .../optional/includes/basic_vba-compat_import_enabled.inc | 9 --------- .../optional/includes/basic_vba-compat_import_nothing.inc | 11 +---------- 4 files changed, 1 insertion(+), 34 deletions(-) diff --git a/testautomation/framework/optional/f_basic_vba-compat.bas b/testautomation/framework/optional/f_basic_vba-compat.bas index db181dbaa973..80b48eb5c1e6 100755 --- a/testautomation/framework/optional/f_basic_vba-compat.bas +++ b/testautomation/framework/optional/f_basic_vba-compat.bas @@ -60,16 +60,10 @@ sub LoadIncludeFiles use "global\tools\includes\optional\t_basic_organizer_tools.inc" use "global\tools\includes\optional\t_treelist_tools.inc" -<<<<<<< local use "global\tools\includes\optional\t_stringtools.inc" -======= use "global\tools\includes\optional\t_security_tools.inc" ->>>>>>> other use "global\tools\includes\optional\t_macro_tools.inc" -<<<<<<< local -======= use "global\tools\includes\optional\t_docfuncs.inc" ->>>>>>> other use "framework\optional\includes\basic_vba_compat_tools.inc" diff --git a/testautomation/framework/optional/includes/basic_vba-compat_import_disabled.inc b/testautomation/framework/optional/includes/basic_vba-compat_import_disabled.inc index e1e13ddc60c9..764ba407236a 100755 --- a/testautomation/framework/optional/includes/basic_vba-compat_import_disabled.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_import_disabled.inc @@ -68,15 +68,6 @@ testcase tBasicVBACompatImportDisabled() dim iCurrentModule as integer dim cCurrentModule as string dim bFound as boolean - - ' Depending on the mode of macro import we have differtent basic libraries listed - const NODE_COUNT_OOO = 78 ' OpenOffice.org - const NODE_COUNT = 80 ' branded product - - const DOCUMENT_POSITION_OFFSET = -7 - - const IMPORT_EXCEL_MACROS = TRUE - const EXEC_EXCEL_MACROS = FALSE printlog( "Set macro security to low" ) hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW ) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc b/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc index a6a60fe41f74..98173ee8ba48 100755 --- a/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_import_enabled.inc @@ -80,15 +80,6 @@ testcase tBasicVBACompatImportEnabled() dim cTempString as string dim bFound as boolean - ' Depending on the mode of macro import we have differtent basic libraries listed - const NODE_COUNT_OOO = 74 - const NODE_COUNT = 76 - - const DOCUMENT_POSITION_OFFSET = -3 - - const IMPORT_EXCEL_MACROS = TRUE - const EXEC_EXCEL_MACROS = TRUE - printlog( "Set macro security to low" ) hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW ) diff --git a/testautomation/framework/optional/includes/basic_vba-compat_import_nothing.inc b/testautomation/framework/optional/includes/basic_vba-compat_import_nothing.inc index cafe378c765e..50c59cf88e10 100755 --- a/testautomation/framework/optional/includes/basic_vba-compat_import_nothing.inc +++ b/testautomation/framework/optional/includes/basic_vba-compat_import_nothing.inc @@ -55,16 +55,7 @@ testcase tBasicVBACompatImportNothing() cTestFile = gTesttoolPath & "framework/optional/input/vba-compat/" & DOCUMENT_NAME dim cNodeCount as integer - - ' Depending on the mode of macro import we have differtent basic libraries listed - const NODE_COUNT = 74 ' Do not import Microsoft(R) Excel(R) macros at all - const NODE_COUNT_OOO = 72 - const MACRO_LIST = 0 ' The document library should have no scripts listed - const DOCUMENT_POSITION_OFFSET = -1 - - const IMPORT_EXCEL_MACROS = FALSE - const EXEC_EXCEL_MACROS = FALSE - + printlog( "Set macro security to low" ) hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW ) -- cgit From d0317057eb7e0f10889a33961a9d6f3ff2b9828b Mon Sep 17 00:00:00 2001 From: Release Engineering Date: Fri, 21 May 2010 19:27:36 +0200 Subject: DEV300 --- solenv/inc/minor.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/solenv/inc/minor.mk b/solenv/inc/minor.mk index ec992a075900..a1d5c1fdcb5c 100644 --- a/solenv/inc/minor.mk +++ b/solenv/inc/minor.mk @@ -1,5 +1,5 @@ RSCVERSION=300 -RSCREVISION=300m78(Build:9501) -BUILD=9501 -LAST_MINOR=m78 +RSCREVISION=300m79(Build:9504) +BUILD=9504 +LAST_MINOR=m79 SOURCEVERSION=DEV300 -- cgit From b1e4920d78abdc470c496c1fd0c5abb2a398f28d Mon Sep 17 00:00:00 2001 From: Ruediger Timm Date: Tue, 25 May 2010 17:13:26 +0200 Subject: masterfix #i10000#, #i111360#: checkdeliver.pl's check for srcroot breaks on windows if srcroot points to a volume root dir (C:) because that is not a valid directory. The whole source directory detection should be reworked, for now just disable the check. --- postprocess/checkdeliver/checkdeliver.pl | 3 --- 1 file changed, 3 deletions(-) diff --git a/postprocess/checkdeliver/checkdeliver.pl b/postprocess/checkdeliver/checkdeliver.pl index 90a01be3a0a0..afd52ae0fec5 100644 --- a/postprocess/checkdeliver/checkdeliver.pl +++ b/postprocess/checkdeliver/checkdeliver.pl @@ -93,9 +93,6 @@ sub get_globals if ( ! ( $platform && $srcrootdir && $solverdir ) ) { die "Error: please set environment\n"; } - if ( ! -d $srcrootdir ) { - die "Error: cannot find source directory '$srcrootdir'\n"; - } if ( ! -d $solverdir ) { die "Error: cannot find solver directory '$solverdir'\n"; } -- cgit