Apache OpenOffice (AOO) Bugzilla – Full Text Issue Listing |
Summary: | Module cui - Add new color | ||||||
---|---|---|---|---|---|---|---|
Product: | App Dev | Reporter: | ivanpoot <ivan.pootdiaz> | ||||
Component: | api | Assignee: | AOO issues mailing list <issues> | ||||
Status: | UNCONFIRMED --- | QA Contact: | |||||
Severity: | Normal | ||||||
Priority: | P3 | CC: | Armin.Le.Grand, issues, pescetti | ||||
Version: | 4.0.0-dev | ||||||
Target Milestone: | --- | ||||||
Hardware: | All | ||||||
OS: | All | ||||||
Issue Type: | PATCH | Latest Confirmation in: | --- | ||||
Developer Difficulty: | --- | ||||||
Attachments: |
|
ALG: Thanks, will have a look ASAP, grepping.. Reset assigne to the default "issues@openoffice.apache.org". |
Created attachment 80906 [details] new color Hi all, This patch "registrodom.patch": This code snippet allows Auto Registration the colors to Apache OpenOffice Drawing , ie the self-colored. Through this patch allows the user to add new colors in the color palette without entering a name. If the color name already exists, it is automatically assigned a number to the name, eg open open4509 open0267 open8160 open1094 ... This code I've been working in the module cui (file: tpcolor.cxx). I would like that the community to help implement this code in AOO. The Auto Registration of colors: I think an excellent idea as draw integrated this functionality in AOO and allow the user to add new colors without many's restrictions, this process could be done more quickly and efficiently. No doubt it would be very useful in my humble opinion. Best Regards. registrodom.patch: --- tpcparche.cxx 2013-04-08 19:41:41.000000000 -0500 +++ tpcolor.cxx 2013-05-07 14:03:05.890419322 -0500 @@ -24,6 +24,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_cui.hxx" +#include <rtl/ustrbuf.hxx> +#include <cstdlib> +using std::rand; +using rtl::OUStringBuffer; + // include --------------------------------------------------------------- #include <tools/shl.hxx> #include <tools/urlobj.hxx> @@ -480,10 +485,10 @@ sal_Bool bDifferent = sal_True; // Pruefen, ob Name schon vorhanden ist - for ( long i = 0; i < nCount && bDifferent; i++ ) + /*for ( long i = 0; i < nCount && bDifferent; i++ ) if ( aName == pColorTab->GetColor( i )->GetName() ) - bDifferent = sal_False; - + bDifferent = sal_False;*/ + // Wenn ja, wird wiederholt ein neuer Name angefordert if ( !bDifferent ) { @@ -516,16 +521,115 @@ } delete( pDlg ); } - + // Wenn nicht vorhanden, wird Eintrag aufgenommen if( bDifferent ) { + // string concatination + + // give it an initial size + OUStringBuffer buf( 128 ); + + //append aName to String + buf.append( aName ); + + //checks if the name already exists + for ( long i = 0; i < nCount && bDifferent; i++ ) + if ( aName == pColorTab->GetColor( i )->GetName() ) + bDifferent = sal_False; + + if ( !bDifferent ) + { + sal_Int32 nLen = buf.getLength(); + String ab = buf.charAt(nLen - 1); + + sal_Int32 xx = std::rand() % 5000 + 1000; + + if (ab == '1' || ab == '2' || ab == '3' || ab == '4' || ab == '5' || ab == '6' || ab == '7' || ab == '8' || ab == '9' || ab == '0') + { + buf.setLength(nLen - 4); + buf.append( xx ); + }else{ + buf.append( xx ); + } + + } + + // now transfer the buffer into the string. + String lstring = buf.makeStringAndClear(); + if (eCM != CM_RGB) ConvertColorValues (aAktuellColor, CM_RGB); - pEntry = new XColorEntry( aAktuellColor, aName ); + pEntry = new XColorEntry( aAktuellColor, lstring ); pColorTab->Insert( pColorTab->Count(), pEntry ); - + aLbColor.Append( pEntry ); aValSetColorTable.InsertItem( aValSetColorTable.GetItemCount() + 1, pEntry->GetColor(), pEntry->GetName() );